Skip to content

Package: LocalApplicationContainer

LocalApplicationContainer

nameinstructionbranchcomplexitylinemethod
LocalApplicationContainer(WsTool, WsTool)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
deploy(DeployedService)
M: 54 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
getTransport()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
patchWsdl(DeployedService, File)
M: 93 C: 0
0%
M: 10 C: 0
0%
M: 6 C: 0
0%
M: 22 C: 0
0%
M: 1 C: 0
0%
shutdown()
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
start()
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 1997, 2019 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Distribution License v. 1.0, which is available at
6: * http://www.eclipse.org/org/documents/edl-v10.php.
7: *
8: * SPDX-License-Identifier: BSD-3-Clause
9: */
10:
11: package com.sun.xml.ws.test.container.local;
12:
13: import com.sun.istack.NotNull;
14: import com.sun.xml.ws.test.container.AbstractApplicationContainer;
15: import com.sun.xml.ws.test.container.Application;
16: import com.sun.xml.ws.test.container.ApplicationContainer;
17: import com.sun.xml.ws.test.container.DeployedService;
18: import com.sun.xml.ws.test.container.WAR;
19: import com.sun.xml.ws.test.tool.WsTool;
20: import com.sun.xml.ws.test.util.XMLUtil;
21:
22: import java.io.File;
23: import java.io.FileOutputStream;
24: import java.net.URI;
25: import java.util.List;
26: import org.w3c.dom.Attr;
27: import org.w3c.dom.Document;
28: import org.w3c.dom.Element;
29: import org.w3c.dom.NodeList;
30:
31: /**
32: * {@link ApplicationContainer} for the local transport.
33: *
34: * @deprecated
35: * To be removed once in-vm transport becomes ready
36: * @author Kohsuke Kawaguchi
37: */
38: @Deprecated
39: public class LocalApplicationContainer extends AbstractApplicationContainer {
40:
41: public LocalApplicationContainer(WsTool wsimport, WsTool wsgen) {
42: super(wsimport,wsgen,false);
43: }
44:
45: public String getTransport() {
46: return "local";
47: }
48:
49: public void start() {
50: // noop
51: }
52:
53: public void shutdown() {
54: // noop
55: }
56:
57: @NotNull
58: public Application deploy(DeployedService service) throws Exception {
59: WAR war = assembleWar(service);
60:• if (service.service.isSTS) {
61: String newLocation = "local://" + service.warDir.getAbsolutePath() + "/";
62: newLocation = newLocation.replace('\\', '/');
63: updateWsitClient(war, service, newLocation);
64: }
65:• for (File wsdl : war.getWSDL())
66: patchWsdl(service,wsdl);
67: return new LocalApplication(war,new URI("local://" +
68: service.warDir.getAbsolutePath().replace('\\','/')));
69: }
70:
71: /**
72: * Fix the address in the WSDL. to the local address.
73: */
74: private void patchWsdl(DeployedService service, File wsdl) throws Exception {
75: Document doc = XMLUtil.readXML(wsdl, null);
76: List<Element> ports = XMLUtil.getElements(doc, "//*[local-name()='service']/*");
77:
78:• for (Element port : ports) {
79: String portName = port.getAttribute("name");
80:
81: Element address = (Element)port.getFirstChild();
82:
83: Attr locationAttr = address.getAttributeNode("location");
84: String newLocation =
85: "local://" + service.warDir.getAbsolutePath() + "?" + portName;
86: newLocation = newLocation.replace('\\', '/');
87: locationAttr.setValue(newLocation);
88:
89: //Patch wsa:Address in wsa:EndpointReference as well
90: NodeList nl = port.getElementsByTagNameNS("http://www.w3.org/2005/08/addressing", "EndpointReference");
91:• Element wsaEprEl = nl.getLength() > 0 ? (Element) nl.item(0) : null;
92:• if (wsaEprEl != null) {
93: nl = wsaEprEl.getElementsByTagNameNS("http://www.w3.org/2005/08/addressing", "Address");
94:• Element wsaAddrEl = nl.getLength() > 0 ? (Element) nl.item(0) : null;
95:• if (wsaAddrEl != null) {
96: wsaAddrEl.setTextContent(newLocation);
97: }
98:
99: }
100: }
101:
102: // save file
103: FileOutputStream os = new FileOutputStream(wsdl);
104: XMLUtil.writeXML(doc, os);
105: os.close();
106: }
107:
108: }