You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2015/05/22 20:14:36 UTC
[1/3] cxf git commit: [CXF-6392] Schema imports are not handled
correctly in generated WSDL and XSD files
Repository: cxf
Updated Branches:
refs/heads/master 1d29e0af1 -> 6ef5be586
[CXF-6392] Schema imports are not handled correctly in generated WSDL
and XSD files
- test case demonstrating incorrect behaviour
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/78d79f44
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/78d79f44
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/78d79f44
Branch: refs/heads/master
Commit: 78d79f449f71a530f0d2739dbb888a913439463d
Parents: 1d29e0a
Author: Tomas Hofman <th...@redhat.com>
Authored: Wed May 6 16:48:18 2015 +0200
Committer: Daniel Kulp <dk...@apache.org>
Committed: Fri May 22 13:25:08 2015 -0400
----------------------------------------------------------------------
.../cxf/systest/jaxws/OASISCatalogTest.java | 98 +++++++++++++++-----
.../main/resources/META-INF/jax-ws-catalog.xml | 1 +
.../wsdl/others/d/d/hello_world_schema4.xsd | 27 ++++++
.../wsdl/others/d/hello_world_schema4.xsd | 30 ++++++
.../wsdl/others/hello_world_schema.xsd | 2 +-
.../wsdl/others/hello_world_schema2.xsd | 4 +
.../wsdl/others/hello_world_schema3.xsd | 27 ++++++
7 files changed, 167 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/78d79f44/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/OASISCatalogTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/OASISCatalogTest.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/OASISCatalogTest.java
index f4553e9..3245517 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/OASISCatalogTest.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/OASISCatalogTest.java
@@ -19,6 +19,7 @@
package org.apache.cxf.systest.jaxws;
+import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
@@ -61,27 +62,69 @@ public class OASISCatalogTest extends Assert {
public void testWSDLPublishWithCatalogs() throws Exception {
Endpoint ep = Endpoint.publish("http://localhost:" + PORT + "/SoapContext/SoapPort",
new GreeterImpl());
- try {
- URL url = new URL("http://localhost:" + PORT + "/SoapContext/SoapPort?"
- + "xsd=hello_world_schema2.xsd");
- assertNotNull(url.getContent());
- String result = IOUtils.toString((InputStream)url.getContent());
- assertTrue(result, result.contains("xsd=hello_world_schema.xsd"));
-
-
- url = new URL("http://localhost:" + PORT + "/SoapContext/SoapPort"
- + "?xsd=hello_world_schema.xsd");
- result = IOUtils.toString((InputStream)url.getContent());
- assertTrue(result, result.contains("xsd=hello_world_schema2.xsd"));
-
- url = new URL("http://localhost:" + PORT + "/SoapContext/SoapPort"
- + "?wsdl=testutils/others/hello_world_messages_catalog.wsdl");
- result = IOUtils.toString((InputStream)url.getContent());
- assertTrue(result, result.contains("xsd=hello_world_schema.xsd"));
-
- } finally {
- ep.stop();
- }
+
+ String result = readUrl("http://localhost:" + PORT + "/SoapContext/SoapPort?"
+ + "xsd=hello_world_schema2.xsd");
+ assertTrue(result, result.contains("xsd=hello_world_schema.xsd"));
+ assertTrue(result, result.contains("xsd=hello_world_schema3.xsd"));
+ assertTrue(result, result.contains("xsd=d/hello_world_schema4.xsd"));
+
+ result = readUrl("http://localhost:" + PORT + "/SoapContext/SoapPort?"
+ + "xsd=hello_world_schema3.xsd");
+ assertTrue(result.length() > 0);
+
+ result = readUrl("http://localhost:" + PORT + "/SoapContext/SoapPort?"
+ + "xsd=d/hello_world_schema4.xsd");
+ assertTrue(result, result.contains("xsd=d/d/hello_world_schema4.xsd"));
+
+ result = readUrl("http://localhost:" + PORT + "/SoapContext/SoapPort"
+ + "?xsd=hello_world_schema.xsd");
+ assertTrue(result, result.contains("xsd=http://apache.org/hello_world/types2/hello_world_schema2.xsd"));
+
+ result = readUrl("http://localhost:" + PORT + "/SoapContext/SoapPort"
+ + "?wsdl=testutils/others/hello_world_messages_catalog.wsdl");
+ assertTrue(result, result.contains("xsd=hello_world_schema.xsd"));
+
+ ep.stop();
+ }
+
+ /**
+ * This is test case for https://issues.apache.org/jira/browse/CXF-6234
+ *
+ * It's using paths that will be rewritten by following catalog rule:
+ *
+ * <rewriteSystem systemIdStartString="http://apache.org/hello_world/types2/"
+ * rewritePrefix="/wsdl/others/"/>
+ *
+ */
+ @Test
+ public void testWSDLPublishWithCatalogsRewritePaths() {
+ Endpoint ep = Endpoint.publish("http://localhost:" + PORT + "/SoapContext/SoapPort",
+ new GreeterImpl());
+
+ String result = readUrl("http://localhost:" + PORT + "/SoapContext/SoapPort?"
+ + "xsd=http://apache.org/hello_world/types2/hello_world_schema2.xsd");
+ assertTrue(result, result.contains("xsd=http://apache.org/hello_world/types2/hello_world_schema.xsd"));
+ assertTrue(result, result.contains("xsd=http://apache.org/hello_world/types2/hello_world_schema3.xsd"));
+ assertTrue(result, result.contains("xsd=http://apache.org/hello_world/types2/d/hello_world_schema4.xsd"));
+
+ result = readUrl("http://localhost:" + PORT + "/SoapContext/SoapPort?"
+ + "xsd=http://apache.org/hello_world/types2/hello_world_schema.xsd");
+ assertTrue(result, result.contains("xsd=http://apache.org/hello_world/types2/hello_world_schema2.xsd"));
+
+ result = readUrl("http://localhost:" + PORT + "/SoapContext/SoapPort?"
+ + "xsd=http://apache.org/hello_world/types2/hello_world_schema3.xsd");
+ assertTrue(result.length() > 0);
+
+ result = readUrl("http://localhost:" + PORT + "/SoapContext/SoapPort?"
+ + "xsd=http://apache.org/hello_world/types2/d/hello_world_schema4.xsd");
+ assertTrue(result, result.contains("xsd=http://apache.org/hello_world/types2/d/d/hello_world_schema4.xsd"));
+
+ result = readUrl("http://localhost:" + PORT + "/SoapContext/SoapPort?"
+ + "xsd=http://apache.org/hello_world/types2/d/d/hello_world_schema4.xsd");
+ assertTrue(result.length() > 0);
+
+ ep.stop();
}
@Test
@@ -170,4 +213,17 @@ public class OASISCatalogTest extends Assert {
}
}
+ private String readUrl(String address) {
+ String content = null;
+ try {
+ URL url = new URL(address);
+ assertNotNull(url.getContent());
+ content = IOUtils.toString((InputStream) url.getContent());
+ } catch (IOException e) {
+ e.printStackTrace(System.err);
+ Assert.fail("Couldn't read URL: " + e.getMessage());
+ }
+ return content;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/78d79f44/testutils/src/main/resources/META-INF/jax-ws-catalog.xml
----------------------------------------------------------------------
diff --git a/testutils/src/main/resources/META-INF/jax-ws-catalog.xml b/testutils/src/main/resources/META-INF/jax-ws-catalog.xml
index 5b5322c..28d5907 100644
--- a/testutils/src/main/resources/META-INF/jax-ws-catalog.xml
+++ b/testutils/src/main/resources/META-INF/jax-ws-catalog.xml
@@ -18,6 +18,7 @@
under the License.
-->
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
+ <rewriteSystem systemIdStartString="http://apache.org/hello_world/types2/" rewritePrefix="/wsdl/others/"/>
<rewriteSystem systemIdStartString="doesnotexist" rewritePrefix="../wsdl/catalog"/>
<rewriteSystem systemIdStartString="nopath" rewritePrefix="../wsdl"/>
<rewriteSystem systemIdStartString="testutils" rewritePrefix="classpath:/wsdl"/>
http://git-wip-us.apache.org/repos/asf/cxf/blob/78d79f44/testutils/src/main/resources/wsdl/others/d/d/hello_world_schema4.xsd
----------------------------------------------------------------------
diff --git a/testutils/src/main/resources/wsdl/others/d/d/hello_world_schema4.xsd b/testutils/src/main/resources/wsdl/others/d/d/hello_world_schema4.xsd
new file mode 100644
index 0000000..3868647
--- /dev/null
+++ b/testutils/src/main/resources/wsdl/others/d/d/hello_world_schema4.xsd
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://apache.org/hello_world/types5"
+ elementFormDefault="qualified">
+
+ <xsd:element name="sayHi5">
+ <xsd:complexType/>
+ </xsd:element>
+</xsd:schema>
http://git-wip-us.apache.org/repos/asf/cxf/blob/78d79f44/testutils/src/main/resources/wsdl/others/d/hello_world_schema4.xsd
----------------------------------------------------------------------
diff --git a/testutils/src/main/resources/wsdl/others/d/hello_world_schema4.xsd b/testutils/src/main/resources/wsdl/others/d/hello_world_schema4.xsd
new file mode 100644
index 0000000..44852a0
--- /dev/null
+++ b/testutils/src/main/resources/wsdl/others/d/hello_world_schema4.xsd
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://apache.org/hello_world/types4"
+ elementFormDefault="qualified">
+
+ <xsd:import namespace="http://apache.org/hello_world/types5"
+ schemaLocation="d/hello_world_schema4.xsd"/>
+
+ <xsd:element name="sayHi4">
+ <xsd:complexType/>
+ </xsd:element>
+</xsd:schema>
http://git-wip-us.apache.org/repos/asf/cxf/blob/78d79f44/testutils/src/main/resources/wsdl/others/hello_world_schema.xsd
----------------------------------------------------------------------
diff --git a/testutils/src/main/resources/wsdl/others/hello_world_schema.xsd b/testutils/src/main/resources/wsdl/others/hello_world_schema.xsd
index b9480ec..5c0e655 100644
--- a/testutils/src/main/resources/wsdl/others/hello_world_schema.xsd
+++ b/testutils/src/main/resources/wsdl/others/hello_world_schema.xsd
@@ -24,7 +24,7 @@
elementFormDefault="qualified">
<import namespace="http://apache.org/hello_world/types2"
- schemaLocation="hello_world_schema2.xsd"/>
+ schemaLocation="http://apache.org/hello_world/types2/hello_world_schema2.xsd"/>
<element name="sayHi">
http://git-wip-us.apache.org/repos/asf/cxf/blob/78d79f44/testutils/src/main/resources/wsdl/others/hello_world_schema2.xsd
----------------------------------------------------------------------
diff --git a/testutils/src/main/resources/wsdl/others/hello_world_schema2.xsd b/testutils/src/main/resources/wsdl/others/hello_world_schema2.xsd
index 45f9a38..c8fa92a 100644
--- a/testutils/src/main/resources/wsdl/others/hello_world_schema2.xsd
+++ b/testutils/src/main/resources/wsdl/others/hello_world_schema2.xsd
@@ -23,6 +23,10 @@
<xsd:import namespace="http://apache.org/hello_world/types"
schemaLocation="hello_world_schema.xsd"/>
+ <xsd:import namespace="http://apache.org/hello_world/types4"
+ schemaLocation="d/hello_world_schema4.xsd"/>
+
+ <xsd:include schemaLocation="hello_world_schema3.xsd"/>
<xsd:element name="sayHi2">
<xsd:complexType/>
http://git-wip-us.apache.org/repos/asf/cxf/blob/78d79f44/testutils/src/main/resources/wsdl/others/hello_world_schema3.xsd
----------------------------------------------------------------------
diff --git a/testutils/src/main/resources/wsdl/others/hello_world_schema3.xsd b/testutils/src/main/resources/wsdl/others/hello_world_schema3.xsd
new file mode 100644
index 0000000..0b779b6
--- /dev/null
+++ b/testutils/src/main/resources/wsdl/others/hello_world_schema3.xsd
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://apache.org/hello_world/types2"
+ elementFormDefault="qualified">
+
+ <xsd:element name="sayHi3">
+ <xsd:complexType/>
+ </xsd:element>
+</xsd:schema>
[2/3] cxf git commit: [CXF-6392] Schema imports are not handled
correctly in generated WSDL and XSD files
Posted by dk...@apache.org.
[CXF-6392] Schema imports are not handled correctly in generated WSDL
and XSD files
- proposed fix
Closes #68
Closes #69
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/36b432c8
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/36b432c8
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/36b432c8
Branch: refs/heads/master
Commit: 36b432c8a47b411d9a408d0adffeb780ebe3116a
Parents: 78d79f4
Author: Tomas Hofman <th...@redhat.com>
Authored: Wed May 6 16:48:18 2015 +0200
Committer: Daniel Kulp <dk...@apache.org>
Committed: Fri May 22 14:12:49 2015 -0400
----------------------------------------------------------------------
.../org/apache/cxf/frontend/WSDLGetUtils.java | 118 ++++++++++---------
1 file changed, 60 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/36b432c8/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
----------------------------------------------------------------------
diff --git a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
index 8ab1437..9213e67 100644
--- a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
+++ b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
@@ -72,7 +72,7 @@ import org.apache.cxf.wsdl11.ResourceManagerWSDLLocator;
import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
/**
- *
+ *
*/
public class WSDLGetUtils {
@@ -83,9 +83,9 @@ public class WSDLGetUtils {
private static final String WSDLS_KEY = WSDLGetUtils.class.getName() + ".WSDLs";
private static final String SCHEMAS_KEY = WSDLGetUtils.class.getName() + ".Schemas";
-
+
private static final Logger LOG = LogUtils.getL7dLogger(WSDLGetInterceptor.class);
-
+
public WSDLGetUtils() {
}
@@ -96,10 +96,10 @@ public class WSDLGetUtils {
EndpointInfo endpointInfo) {
Map<String, String> params = new HashMap<String, String>();
params.put("wsdl", "");
- getDocument(message, base,
- params, ctxUri,
+ getDocument(message, base,
+ params, ctxUri,
endpointInfo);
-
+
Map<String, Definition> mp = CastUtils.cast((Map<?, ?>)endpointInfo.getService()
.getProperty(WSDLS_KEY));
return mp.keySet();
@@ -110,19 +110,19 @@ public class WSDLGetUtils {
EndpointInfo endpointInfo) {
Map<String, String> params = new HashMap<String, String>();
params.put("wsdl", "");
- getDocument(message, base,
- params, ctxUri,
+ getDocument(message, base,
+ params, ctxUri,
endpointInfo);
-
+
Map<String, SchemaReference> mp = CastUtils.cast((Map<?, ?>)endpointInfo.getService()
.getProperty(SCHEMAS_KEY));
-
+
Map<String, String> schemas = new HashMap<String, String>();
for (Map.Entry<String, SchemaReference> ent : mp.entrySet()) {
params.clear();
params.put("xsd", ent.getKey());
Document doc = getDocument(message, base, params, ctxUri, endpointInfo);
- schemas.put(doc.getDocumentElement().getAttribute("targetNamespace"),
+ schemas.put(doc.getDocumentElement().getAttribute("targetNamespace"),
buildUrl(base, ctxUri, "xsd=" + ent.getKey()));
}
return schemas;
@@ -161,16 +161,25 @@ public class WSDLGetUtils {
}
return doc;
}
-
- protected String mapUri(String base, Map<String, SchemaReference> smp, String loc, String xsd)
+
+ protected String mapUri(Bus bus, String base, Map<String, SchemaReference> smp, String loc, String xsd)
throws UnsupportedEncodingException {
String key = loc;
try {
boolean absoluteLocUri = new URI(loc).isAbsolute();
- if (!absoluteLocUri && xsd != null) {
+ if (!absoluteLocUri && xsd != null) { // XSD request
+ // resolve requested location with relative import path
key = new URI(xsd).resolve(loc).toString();
- }
- if (!absoluteLocUri && xsd == null) {
+
+ if (!smp.containsKey(URLDecoder.decode(key, "utf-8"))) {
+ // if the result is not known, check if we can resolve it into something known
+ String resolved = resolveWithCatalogs(OASISCatalogManager.getCatalogManager(bus), key, base);
+ if (smp.containsKey(URLDecoder.decode(resolved, "utf-8"))) {
+ // if it is resolvable, we can use it
+ return base + "?xsd=" + key.replace(" ", "%20");
+ }
+ }
+ } else if (!absoluteLocUri && xsd == null) { // WSDL request
key = new URI(".").resolve(loc).toString();
}
} catch (URISyntaxException e) {
@@ -190,6 +199,7 @@ public class WSDLGetUtils {
Message message,
String xsd,
String wsdl) {
+ Bus bus = message.getExchange().getBus();
List<Element> elementList = null;
try {
@@ -197,7 +207,7 @@ public class WSDLGetUtils {
"http://www.w3.org/2001/XMLSchema", "import");
for (Element el : elementList) {
String sl = el.getAttribute("schemaLocation");
- sl = mapUri(base, smp, sl, xsd);
+ sl = mapUri(bus, base, smp, sl, xsd);
if (sl != null) {
el.setAttribute("schemaLocation", sl);
}
@@ -208,7 +218,7 @@ public class WSDLGetUtils {
"include");
for (Element el : elementList) {
String sl = el.getAttribute("schemaLocation");
- sl = mapUri(base, smp, sl, xsd);
+ sl = mapUri(bus, base, smp, sl, xsd);
if (sl != null) {
el.setAttribute("schemaLocation", sl);
}
@@ -218,7 +228,7 @@ public class WSDLGetUtils {
"redefine");
for (Element el : elementList) {
String sl = el.getAttribute("schemaLocation");
- sl = mapUri(base, smp, sl, xsd);
+ sl = mapUri(bus, base, smp, sl, xsd);
if (sl != null) {
el.setAttribute("schemaLocation", sl);
}
@@ -393,7 +403,7 @@ public class WSDLGetUtils {
: CastUtils.cast(types.getExtensibilityElements(), ExtensibilityElement.class)) {
if (el instanceof Schema) {
Schema see = (Schema)el;
- updateSchemaImports(bus, see, see.getDocumentBaseURI(), doneSchemas, base, null);
+ updateSchemaImports(bus, see, see.getDocumentBaseURI(), doneSchemas, base);
}
}
}
@@ -450,8 +460,7 @@ public class WSDLGetUtils {
Schema schema,
String docBase,
Map<String, SchemaReference> doneSchemas,
- String base,
- String parent) {
+ String base) {
OASISCatalogManager catalogs = OASISCatalogManager.getCatalogManager(bus);
Collection<List<?>> imports = CastUtils.cast((Collection<?>)schema.getImports().values());
for (List<?> lst : imports) {
@@ -476,36 +485,23 @@ public class WSDLGetUtils {
String resolvedSchemaLocation = resolveWithCatalogs(catalogs, start, base);
if (resolvedSchemaLocation == null) {
resolvedSchemaLocation = resolveWithCatalogs(catalogs, imp.getSchemaLocationURI(), base);
- }
+ }
if (resolvedSchemaLocation == null) {
try {
//check to see if it's already in a URL format. If so, leave it.
new URL(start);
} catch (MalformedURLException e) {
if (doneSchemas.put(decodedStart, imp) == null) {
- try {
- //CHECKSTYLE:OFF:NestedIfDepth
- if (!(new URI(decodedStart).isAbsolute()) && parent != null) {
- resolvedSchemaLocation = new URI(parent).resolve(decodedStart).toString();
- decodedStart = URLDecoder.decode(resolvedSchemaLocation, "utf-8");
- doneSchemas.put(resolvedSchemaLocation, imp);
- }
- //CHECKSTYLE:ON:NestedIfDepth
- } catch (URISyntaxException ex) {
- // ignore
- } catch (UnsupportedEncodingException ex) {
- // ignore
- }
+ putResolvedSchemaLocationIfRelative(doneSchemas, decodedStart, imp);
updateSchemaImports(bus, imp.getReferencedSchema(), docBase,
- doneSchemas, base, decodedStart);
+ doneSchemas, base);
}
}
} else {
if (doneSchemas.put(decodedStart, imp) == null) {
doneSchemas.put(resolvedSchemaLocation, imp);
doneSchemas.put(imp.getSchemaLocationURI(), imp);
- updateSchemaImports(bus, imp.getReferencedSchema(), docBase,
- doneSchemas, base, decodedStart);
+ updateSchemaImports(bus, imp.getReferencedSchema(), docBase, doneSchemas, base);
}
}
}
@@ -538,8 +534,8 @@ public class WSDLGetUtils {
new URL(start);
} catch (MalformedURLException e) {
if (doneSchemas.put(decodedStart, included) == null) {
- updateSchemaImports(bus, included.getReferencedSchema(),
- docBase, doneSchemas, base, decodedStart);
+ putResolvedSchemaLocationIfRelative(doneSchemas, decodedStart, included);
+ updateSchemaImports(bus, included.getReferencedSchema(), docBase, doneSchemas, base);
}
}
}
@@ -547,7 +543,7 @@ public class WSDLGetUtils {
|| !doneSchemas.containsKey(resolvedSchemaLocation)) {
doneSchemas.put(decodedStart, included);
doneSchemas.put(resolvedSchemaLocation, included);
- updateSchemaImports(bus, included.getReferencedSchema(), docBase, doneSchemas, base, decodedStart);
+ updateSchemaImports(bus, included.getReferencedSchema(), docBase, doneSchemas, base);
}
}
}
@@ -576,21 +572,8 @@ public class WSDLGetUtils {
new URL(start);
} catch (MalformedURLException e) {
if (doneSchemas.put(decodedStart, included) == null) {
- try {
- //CHECKSTYLE:OFF:NestedIfDepth
- if (!(new URI(decodedStart).isAbsolute()) && parent != null) {
- resolvedSchemaLocation = new URI(parent).resolve(decodedStart).toString();
- decodedStart = URLDecoder.decode(resolvedSchemaLocation, "utf-8");
- doneSchemas.put(resolvedSchemaLocation, included);
- }
- //CHECKSTYLE:ON:NestedIfDepth
- } catch (URISyntaxException ex) {
- // ignore
- } catch (UnsupportedEncodingException ex) {
- // ignore
- }
- updateSchemaImports(bus, included.getReferencedSchema(),
- docBase, doneSchemas, base, decodedStart);
+ putResolvedSchemaLocationIfRelative(doneSchemas, decodedStart, included);
+ updateSchemaImports(bus, included.getReferencedSchema(), docBase, doneSchemas, base);
}
}
}
@@ -598,12 +581,31 @@ public class WSDLGetUtils {
|| !doneSchemas.containsKey(resolvedSchemaLocation)) {
doneSchemas.put(decodedStart, included);
doneSchemas.put(resolvedSchemaLocation, included);
- updateSchemaImports(bus, included.getReferencedSchema(), docBase, doneSchemas, base, decodedStart);
+ updateSchemaImports(bus, included.getReferencedSchema(), docBase, doneSchemas, base);
}
}
}
}
+ /**
+ * If given decodedStart is relative path, resolves a real location of given schema and puts it into schema map.
+ *
+ * @param doneSchemas schema map
+ * @param decodedStart path referencing schema
+ * @param schemaReference referenced schema
+ */
+ private void putResolvedSchemaLocationIfRelative(Map<String, SchemaReference> doneSchemas, String decodedStart,
+ SchemaReference schemaReference) {
+ try {
+ if (!(new URI(decodedStart).isAbsolute())) {
+ String resolved = schemaReference.getReferencedSchema().getDocumentBaseURI();
+ doneSchemas.put(resolved, schemaReference);
+ }
+ } catch (URISyntaxException ex) {
+ // ignore
+ }
+ }
+
private String findSchemaLocation(Map<String, SchemaReference> doneSchemas,
SchemaReference imp,
String docBase) {
[3/3] cxf git commit: Update EndpointImpl to implement AutoCloseable
and then use that in tests to make sure things are shutdown
Posted by dk...@apache.org.
Update EndpointImpl to implement AutoCloseable and then use that in tests to make sure things are shutdown
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/6ef5be58
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/6ef5be58
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/6ef5be58
Branch: refs/heads/master
Commit: 6ef5be5869eb0c076f8bc8ed30775028a0b314c7
Parents: 36b432c
Author: Daniel Kulp <dk...@apache.org>
Authored: Fri May 22 13:59:15 2015 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Fri May 22 14:14:25 2015 -0400
----------------------------------------------------------------------
.../cxf/jca/inbound/MDBActivationWork.java | 1 +
.../aegis/client/ClientServiceConfigTest.java | 12 +-
.../java/org/apache/cxf/jaxws/EndpointImpl.java | 7 +-
.../org/apache/cxf/jaxws/CodeFirstTest.java | 317 ++++++++++---------
.../org/apache/cxf/jaxws/EndpointImplTest.java | 223 ++++++-------
.../apache/cxf/jaxws/EndpointReferenceTest.java | 236 +++++++-------
.../apache/cxf/jaxws/provider/ProviderTest.java | 50 +--
.../factory_pattern/HttpNumberFactoryImpl.java | 1 +
.../ManualHttpMulitplexClientServerTest.java | 8 +-
.../ManualNumberFactoryImpl.java | 1 +
.../MultiplexClientServerTest.java | 9 +-
.../MultiplexHttpAddressClientServerTest.java | 7 +-
.../factory_pattern/NumberFactoryImpl.java | 13 +
.../cxf/systest/ws/addr_responses/Server.java | 9 +-
14 files changed, 481 insertions(+), 413 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/6ef5be58/integration/jca/src/main/java/org/apache/cxf/jca/inbound/MDBActivationWork.java
----------------------------------------------------------------------
diff --git a/integration/jca/src/main/java/org/apache/cxf/jca/inbound/MDBActivationWork.java b/integration/jca/src/main/java/org/apache/cxf/jca/inbound/MDBActivationWork.java
index bebaac4..0b7168a 100644
--- a/integration/jca/src/main/java/org/apache/cxf/jca/inbound/MDBActivationWork.java
+++ b/integration/jca/src/main/java/org/apache/cxf/jca/inbound/MDBActivationWork.java
@@ -220,6 +220,7 @@ public class MDBActivationWork implements Work {
*/
private Server createServerFromJaxwsEndpoint(JaxWsServerFactoryBean factory) {
+ @SuppressWarnings("resource")
EndpointImpl endpoint = new EndpointImpl(factory.getBus(), null, factory);
endpoint.setWsdlLocation(factory.getWsdlURL());
http://git-wip-us.apache.org/repos/asf/cxf/blob/6ef5be58/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/client/ClientServiceConfigTest.java
----------------------------------------------------------------------
diff --git a/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/client/ClientServiceConfigTest.java b/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/client/ClientServiceConfigTest.java
index 55a71ec..fcfe88e 100644
--- a/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/client/ClientServiceConfigTest.java
+++ b/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/client/ClientServiceConfigTest.java
@@ -24,7 +24,6 @@ import javax.xml.ws.Holder;
import org.apache.cxf.aegis.AbstractAegisTest;
import org.apache.cxf.aegis.databinding.AegisDatabinding;
-
import org.apache.cxf.frontend.ClientProxyFactoryBean;
import org.apache.cxf.frontend.ServerFactoryBean;
import org.apache.cxf.jaxws.EndpointImpl;
@@ -32,11 +31,13 @@ import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.service.invoker.BeanInvoker;
import org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class ClientServiceConfigTest extends AbstractAegisTest {
-
+ EndpointImpl impl;
+
@Before
public void before() throws Exception {
super.setUp();
@@ -53,10 +54,15 @@ public class ClientServiceConfigTest extends AbstractAegisTest {
svrFac.create();
Endpoint endpoint = Endpoint.create(new EchoImpl());
- EndpointImpl impl = (EndpointImpl) endpoint;
+ impl = (EndpointImpl) endpoint;
impl.setDataBinding(new AegisDatabinding());
endpoint.publish("local://JaxWsEcho");
}
+ @After
+ public void after() throws Exception {
+ impl.close();
+ impl = null;
+ }
@Test
public void talkToJaxWsHolder() throws Exception {
http://git-wip-us.apache.org/repos/asf/cxf/blob/6ef5be58/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
index 793f6ba..690cbca 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
@@ -79,7 +79,7 @@ import org.apache.cxf.wsdl.WSDLManager;
import org.apache.cxf.wsdl11.WSDLServiceBuilder;
public class EndpointImpl extends javax.xml.ws.Endpoint
- implements InterceptorProvider, Configurable {
+ implements InterceptorProvider, Configurable, AutoCloseable {
/**
* This property controls whether the 'publishEndpoint' permission is checked
* using only the AccessController (i.e. when SecurityManager is not installed).
@@ -855,6 +855,11 @@ public class EndpointImpl extends javax.xml.ws.Endpoint
sf.setDestinationFactory(new JAXWSHttpSpiTransportFactory(context));
}
publish(context.getPath());
+ }
+
+ @Override
+ public void close() throws Exception {
+ stop();
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/6ef5be58/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
index 1392adb..f6d5f5b 100644
--- a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
+++ b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
@@ -168,115 +168,118 @@ public class CodeFirstTest extends AbstractJaxWsTest {
public void testEndpoint() throws Exception {
Hello service = new Hello();
- EndpointImpl ep = new EndpointImpl(getBus(), service, (String) null);
- ep.setExecutor(new Executor() {
- public void execute(Runnable r) {
- new Thread(r).start();
- }
- });
- ep.publish("local://localhost:9090/hello");
-
- Node res = invoke("local://localhost:9090/hello",
- LocalTransportFactory.TRANSPORT_ID,
- "sayHi.xml");
-
- assertNotNull(res);
-
- addNamespace("h", "http://service.jaxws.cxf.apache.org/");
- assertValid("//s:Body/h:sayHiResponse/return", res);
-
- res = invoke("local://localhost:9090/hello",
- LocalTransportFactory.TRANSPORT_ID,
- "getGreetings.xml");
-
- assertNotNull(res);
-
- addNamespace("h", "http://service.jaxws.cxf.apache.org/");
- assertValid("//s:Body/h:getGreetingsResponse/return[1]", res);
- assertValid("//s:Body/h:getGreetingsResponse/return[2]", res);
+ try (EndpointImpl ep = new EndpointImpl(getBus(), service, (String) null)) {
+ ep.setExecutor(new Executor() {
+ public void execute(Runnable r) {
+ new Thread(r).start();
+ }
+ });
+ ep.publish("local://localhost:9090/hello");
+
+ Node res = invoke("local://localhost:9090/hello",
+ LocalTransportFactory.TRANSPORT_ID,
+ "sayHi.xml");
+
+ assertNotNull(res);
+
+ addNamespace("h", "http://service.jaxws.cxf.apache.org/");
+ assertValid("//s:Body/h:sayHiResponse/return", res);
+
+ res = invoke("local://localhost:9090/hello",
+ LocalTransportFactory.TRANSPORT_ID,
+ "getGreetings.xml");
+
+ assertNotNull(res);
+
+ addNamespace("h", "http://service.jaxws.cxf.apache.org/");
+ assertValid("//s:Body/h:getGreetingsResponse/return[1]", res);
+ assertValid("//s:Body/h:getGreetingsResponse/return[2]", res);
+ }
}
@Test
public void testClient() throws Exception {
Hello serviceImpl = new Hello();
- EndpointImpl ep = new EndpointImpl(getBus(), serviceImpl, (String) null);
- ep.publish("local://localhost:9090/hello");
- QName serviceName = new QName("http://service.jaxws.cxf.apache.org/", "HelloService");
- QName portName = new QName("http://service.jaxws.cxf.apache.org/", "HelloPort");
-
- // need to set the same bus with service , so use the ServiceImpl
- ServiceImpl service = new ServiceImpl(getBus(), (URL)null, serviceName, null);
- service.addPort(portName, "http://schemas.xmlsoap.org/soap/", "local://localhost:9090/hello");
-
- HelloInterface proxy = service.getPort(portName, HelloInterface.class, new LoggingFeature());
- Client client = ClientProxy.getClient(proxy);
- boolean found = false;
- for (Interceptor<? extends Message> i : client.getOutInterceptors()) {
- if (i instanceof LoggingOutInterceptor) {
- found = true;
+ try (EndpointImpl ep = new EndpointImpl(getBus(), serviceImpl, (String) null)) {
+ ep.publish("local://localhost:9090/hello");
+ QName serviceName = new QName("http://service.jaxws.cxf.apache.org/", "HelloService");
+ QName portName = new QName("http://service.jaxws.cxf.apache.org/", "HelloPort");
+
+ // need to set the same bus with service , so use the ServiceImpl
+ ServiceImpl service = new ServiceImpl(getBus(), (URL)null, serviceName, null);
+ service.addPort(portName, "http://schemas.xmlsoap.org/soap/", "local://localhost:9090/hello");
+
+ HelloInterface proxy = service.getPort(portName, HelloInterface.class, new LoggingFeature());
+ Client client = ClientProxy.getClient(proxy);
+ boolean found = false;
+ for (Interceptor<? extends Message> i : client.getOutInterceptors()) {
+ if (i instanceof LoggingOutInterceptor) {
+ found = true;
+ }
}
+ assertTrue(found);
+ assertEquals("Get the wrong result", "hello", proxy.sayHi("hello"));
+ String[] strInput = new String[2];
+ strInput[0] = "Hello";
+ strInput[1] = "Bonjour";
+ String[] strings = proxy.getStringArray(strInput);
+ assertEquals(strings.length, 2);
+ assertEquals(strings[0], "HelloHello");
+ assertEquals(strings[1], "BonjourBonjour");
+ List<String> listInput = new ArrayList<String>();
+ listInput.add("Hello");
+ listInput.add("Bonjour");
+ List<String> list = proxy.getStringList(listInput);
+ assertEquals(list.size(), 2);
+ assertEquals(list.get(0), "HelloHello");
+ assertEquals(list.get(1), "BonjourBonjour");
+ //now the client side can't unmarshal the complex type without binding types annoutation
+ List<String> result = proxy.getGreetings();
+ assertEquals(2, result.size());
}
- assertTrue(found);
- assertEquals("Get the wrong result", "hello", proxy.sayHi("hello"));
- String[] strInput = new String[2];
- strInput[0] = "Hello";
- strInput[1] = "Bonjour";
- String[] strings = proxy.getStringArray(strInput);
- assertEquals(strings.length, 2);
- assertEquals(strings[0], "HelloHello");
- assertEquals(strings[1], "BonjourBonjour");
- List<String> listInput = new ArrayList<String>();
- listInput.add("Hello");
- listInput.add("Bonjour");
- List<String> list = proxy.getStringList(listInput);
- assertEquals(list.size(), 2);
- assertEquals(list.get(0), "HelloHello");
- assertEquals(list.get(1), "BonjourBonjour");
- //now the client side can't unmarshal the complex type without binding types annoutation
- List<String> result = proxy.getGreetings();
- assertEquals(2, result.size());
}
@Test
public void testException() throws Exception {
Hello serviceImpl = new Hello();
- EndpointImpl ep = new EndpointImpl(getBus(), serviceImpl, (String) null);
- ep.publish("local://localhost:9090/hello");
- ep.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
- ep.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
- QName serviceName = new QName("http://service.jaxws.cxf.apache.org/", "HelloService");
- QName portName = new QName("http://service.jaxws.cxf.apache.org/", "HelloPort");
-
- // need to set the same bus with service , so use the ServiceImpl
- ServiceImpl service = new ServiceImpl(getBus(), (URL)null, serviceName, null);
- service.addPort(portName, "http://schemas.xmlsoap.org/soap/", "local://localhost:9090/hello");
-
- HelloInterface proxy = service.getPort(portName, HelloInterface.class);
- ClientProxy.getClient(proxy).getInFaultInterceptors().add(new LoggingInInterceptor());
- ClientProxy.getClient(proxy).getInInterceptors().add(new LoggingInInterceptor());
- try {
- proxy.addNumbers(1, -2);
- fail("should throw AddNumbersException");
- } catch (AddNumbersException e) {
- assertEquals(e.getInfo(), "Sum is less than 0.");
- }
-
- try {
- proxy.addNumbers(1, 99);
- fail("should throw AddNumbersSubException");
- } catch (AddNumbersSubException e) {
- assertEquals(e.getSubInfo(), "Sum is 100");
- } catch (AddNumbersException e) {
- fail("should throw AddNumbersSubException");
- }
- try (AutoCloseable c = (AutoCloseable)proxy) {
- assertEquals("Result = 2", proxy.addNumbers(1, 1));
- }
- try {
- proxy.addNumbers(1, 1);
- fail("Proxy should be closed");
- } catch (IllegalStateException t) {
- //this is expected as the client is closed.
+ try (EndpointImpl ep = new EndpointImpl(getBus(), serviceImpl, (String) null)) {
+ ep.publish("local://localhost:9090/hello");
+ ep.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
+ ep.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
+ QName serviceName = new QName("http://service.jaxws.cxf.apache.org/", "HelloService");
+ QName portName = new QName("http://service.jaxws.cxf.apache.org/", "HelloPort");
+
+ // need to set the same bus with service , so use the ServiceImpl
+ ServiceImpl service = new ServiceImpl(getBus(), (URL)null, serviceName, null);
+ service.addPort(portName, "http://schemas.xmlsoap.org/soap/", "local://localhost:9090/hello");
+
+ HelloInterface proxy = service.getPort(portName, HelloInterface.class);
+ ClientProxy.getClient(proxy).getInFaultInterceptors().add(new LoggingInInterceptor());
+ ClientProxy.getClient(proxy).getInInterceptors().add(new LoggingInInterceptor());
+ try {
+ proxy.addNumbers(1, -2);
+ fail("should throw AddNumbersException");
+ } catch (AddNumbersException e) {
+ assertEquals(e.getInfo(), "Sum is less than 0.");
+ }
+
+ try {
+ proxy.addNumbers(1, 99);
+ fail("should throw AddNumbersSubException");
+ } catch (AddNumbersSubException e) {
+ assertEquals(e.getSubInfo(), "Sum is 100");
+ } catch (AddNumbersException e) {
+ fail("should throw AddNumbersSubException");
+ }
+ try (AutoCloseable c = (AutoCloseable)proxy) {
+ assertEquals("Result = 2", proxy.addNumbers(1, 1));
+ }
+ try {
+ proxy.addNumbers(1, 1);
+ fail("Proxy should be closed");
+ } catch (IllegalStateException t) {
+ //this is expected as the client is closed.
+ }
}
}
@@ -284,70 +287,72 @@ public class CodeFirstTest extends AbstractJaxWsTest {
@Test
public void testRpcClient() throws Exception {
SayHiImpl serviceImpl = new SayHiImpl();
- EndpointImpl ep = new EndpointImpl(getBus(), serviceImpl, (String) null);
- ep.publish("local://localhost:9090/hello");
-
- QName serviceName = new QName("http://mynamespace.com/", "SayHiService");
- QName portName = new QName("http://mynamespace.com/", "HelloPort");
-
- // need to set the same bus with service , so use the ServiceImpl
- ServiceImpl service = new ServiceImpl(getBus(), (URL)null, serviceName, null);
- service.addPort(portName, "http://schemas.xmlsoap.org/soap/", "local://localhost:9090/hello");
-
- SayHi proxy = service.getPort(portName, SayHi.class);
- long res = proxy.sayHi(3);
- assertEquals(3, res);
- String[] strInput = new String[2];
- strInput[0] = "Hello";
- strInput[1] = "Bonjour";
- String[] strings = proxy.getStringArray(strInput);
- assertEquals(strings.length, 2);
- assertEquals(strings[0], "HelloHello");
- assertEquals(strings[1], "BonjourBonjour");
-
+ try (EndpointImpl ep = new EndpointImpl(getBus(), serviceImpl, (String) null)) {
+ ep.publish("local://localhost:9090/hello");
+
+ QName serviceName = new QName("http://mynamespace.com/", "SayHiService");
+ QName portName = new QName("http://mynamespace.com/", "HelloPort");
+
+ // need to set the same bus with service , so use the ServiceImpl
+ ServiceImpl service = new ServiceImpl(getBus(), (URL)null, serviceName, null);
+ service.addPort(portName, "http://schemas.xmlsoap.org/soap/", "local://localhost:9090/hello");
+
+ SayHi proxy = service.getPort(portName, SayHi.class);
+ long res = proxy.sayHi(3);
+ assertEquals(3, res);
+ String[] strInput = new String[2];
+ strInput[0] = "Hello";
+ strInput[1] = "Bonjour";
+ String[] strings = proxy.getStringArray(strInput);
+ assertEquals(strings.length, 2);
+ assertEquals(strings[0], "HelloHello");
+ assertEquals(strings[1], "BonjourBonjour");
+ }
}
+
@Test
public void testArrayAndList() throws Exception {
ArrayServiceImpl serviceImpl = new ArrayServiceImpl();
- EndpointImpl ep = new EndpointImpl(getBus(), serviceImpl, (String) null);
- ep.publish("local://localhost:9090/array");
- ep.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
- ep.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
- QName serviceName = new QName("http://service.jaxws.cxf.apache.org/", "ArrayService");
- QName portName = new QName("http://service.jaxws.cxf.apache.org/", "ArrayPort");
-
- // need to set the same bus with service , so use the ServiceImpl
- ServiceImpl service = new ServiceImpl(getBus(), (URL)null, serviceName, null);
- service.addPort(portName, "http://schemas.xmlsoap.org/soap/", "local://localhost:9090/array");
-
- ArrayService proxy = service.getPort(portName, ArrayService.class);
- String[] arrayOut = proxy.arrayOutput();
- assertEquals(arrayOut.length, 3);
- assertEquals(arrayOut[0], "string1");
- assertEquals(arrayOut[1], "string2");
- assertEquals(arrayOut[2], "string3");
- String[] arrayIn = new String[3];
- arrayIn[0] = "string1";
- arrayIn[1] = "string2";
- arrayIn[2] = "string3";
- assertEquals(proxy.arrayInput(arrayIn), "string1string2string3");
- arrayOut = proxy.arrayInputAndOutput(arrayIn);
- assertEquals(arrayOut.length, 3);
- assertEquals(arrayOut[0], "string11");
- assertEquals(arrayOut[1], "string22");
- assertEquals(arrayOut[2], "string33");
-
- List<String> listOut = proxy.listOutput();
- assertEquals(listOut.size(), 3);
- assertEquals(listOut.get(0), "string1");
- assertEquals(listOut.get(1), "string2");
- assertEquals(listOut.get(2), "string3");
- List<String> listIn = new ArrayList<String>();
- listIn.add("list1");
- listIn.add("list2");
- listIn.add("list3");
- assertEquals(proxy.listInput(listIn), "list1list2list3");
+ try (EndpointImpl ep = new EndpointImpl(getBus(), serviceImpl, (String) null)) {
+ ep.publish("local://localhost:9090/array");
+ ep.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
+ ep.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
+ QName serviceName = new QName("http://service.jaxws.cxf.apache.org/", "ArrayService");
+ QName portName = new QName("http://service.jaxws.cxf.apache.org/", "ArrayPort");
+
+ // need to set the same bus with service , so use the ServiceImpl
+ ServiceImpl service = new ServiceImpl(getBus(), (URL)null, serviceName, null);
+ service.addPort(portName, "http://schemas.xmlsoap.org/soap/", "local://localhost:9090/array");
+
+ ArrayService proxy = service.getPort(portName, ArrayService.class);
+ String[] arrayOut = proxy.arrayOutput();
+ assertEquals(arrayOut.length, 3);
+ assertEquals(arrayOut[0], "string1");
+ assertEquals(arrayOut[1], "string2");
+ assertEquals(arrayOut[2], "string3");
+ String[] arrayIn = new String[3];
+ arrayIn[0] = "string1";
+ arrayIn[1] = "string2";
+ arrayIn[2] = "string3";
+ assertEquals(proxy.arrayInput(arrayIn), "string1string2string3");
+ arrayOut = proxy.arrayInputAndOutput(arrayIn);
+ assertEquals(arrayOut.length, 3);
+ assertEquals(arrayOut[0], "string11");
+ assertEquals(arrayOut[1], "string22");
+ assertEquals(arrayOut[2], "string33");
+
+ List<String> listOut = proxy.listOutput();
+ assertEquals(listOut.size(), 3);
+ assertEquals(listOut.get(0), "string1");
+ assertEquals(listOut.get(1), "string2");
+ assertEquals(listOut.get(2), "string3");
+ List<String> listIn = new ArrayList<String>();
+ listIn.add("list1");
+ listIn.add("list2");
+ listIn.add("list3");
+ assertEquals(proxy.listInput(listIn), "list1list2list3");
+ }
}
@Test
http://git-wip-us.apache.org/repos/asf/cxf/blob/6ef5be58/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
index 8da2846..40092d1 100644
--- a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
+++ b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointImplTest.java
@@ -59,34 +59,35 @@ public class EndpointImplTest extends AbstractJaxWsTest {
String address = "http://localhost:8080/test";
GreeterImpl greeter = new GreeterImpl();
- EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String)null);
+ try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String)null)) {
- WebServiceContext ctx = greeter.getContext();
- assertNull(ctx);
- try {
- endpoint.publish(address);
- } catch (IllegalArgumentException ex) {
- assertTrue(ex.getCause() instanceof BusException);
- assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException)ex.getCause()).getCode());
- }
- ctx = greeter.getContext();
-
- assertNotNull(ctx);
-
- // Test that we can't change settings through the JAX-WS API after publishing
-
- try {
- endpoint.publish(address);
- fail("republished an already published endpoint.");
- } catch (IllegalStateException e) {
- // expected
- }
-
- try {
- endpoint.setMetadata(new ArrayList<Source>(0));
- fail("set metadata on an already published endpoint.");
- } catch (IllegalStateException e) {
- // expected
+ WebServiceContext ctx = greeter.getContext();
+ assertNull(ctx);
+ try {
+ endpoint.publish(address);
+ } catch (IllegalArgumentException ex) {
+ assertTrue(ex.getCause() instanceof BusException);
+ assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException)ex.getCause()).getCode());
+ }
+ ctx = greeter.getContext();
+
+ assertNotNull(ctx);
+
+ // Test that we can't change settings through the JAX-WS API after publishing
+
+ try {
+ endpoint.publish(address);
+ fail("republished an already published endpoint.");
+ } catch (IllegalStateException e) {
+ // expected
+ }
+
+ try {
+ endpoint.setMetadata(new ArrayList<Source>(0));
+ fail("set metadata on an already published endpoint.");
+ } catch (IllegalStateException e) {
+ // expected
+ }
}
}
@@ -95,33 +96,33 @@ public class EndpointImplTest extends AbstractJaxWsTest {
String address = "http://localhost:8080/test";
GreeterImpl greeter = new GreeterImpl();
- EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String)null);
-
- WebServiceContext ctx = greeter.getContext();
- assertNull(ctx);
- try {
- endpoint.publish(address);
- } catch (IllegalArgumentException ex) {
- assertTrue(ex.getCause() instanceof BusException);
- assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException)ex.getCause()).getCode());
- }
- ctx = greeter.getContext();
-
- assertNotNull(ctx);
-
- // Test that calling stop on the Endpoint works
- assertTrue(endpoint.isPublished());
- endpoint.stop();
- assertFalse(endpoint.isPublished());
-
- // Test that the Endpoint cannot be restarted.
- try {
- endpoint.publish(address);
- fail("stopped endpoint restarted.");
- } catch (IllegalStateException e) {
- // expected.
+ try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String)null)) {
+
+ WebServiceContext ctx = greeter.getContext();
+ assertNull(ctx);
+ try {
+ endpoint.publish(address);
+ } catch (IllegalArgumentException ex) {
+ assertTrue(ex.getCause() instanceof BusException);
+ assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException)ex.getCause()).getCode());
+ }
+ ctx = greeter.getContext();
+
+ assertNotNull(ctx);
+
+ // Test that calling stop on the Endpoint works
+ assertTrue(endpoint.isPublished());
+ endpoint.stop();
+ assertFalse(endpoint.isPublished());
+
+ // Test that the Endpoint cannot be restarted.
+ try {
+ endpoint.publish(address);
+ fail("stopped endpoint restarted.");
+ } catch (IllegalStateException e) {
+ // expected.
+ }
}
-
}
@@ -133,21 +134,22 @@ public class EndpointImplTest extends AbstractJaxWsTest {
serviceFactory.setInvoker(new BeanInvoker(greeter));
serviceFactory.setServiceClass(GreeterImpl.class);
- EndpointImpl endpoint = new EndpointImpl(getBus(), greeter,
- new JaxWsServerFactoryBean(serviceFactory));
+ try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter,
+ new JaxWsServerFactoryBean(serviceFactory))) {
- WebServiceContext ctx = greeter.getContext();
- assertNull(ctx);
- try {
- String address = "http://localhost:8080/test";
- endpoint.publish(address);
- } catch (IllegalArgumentException ex) {
- assertTrue(ex.getCause() instanceof BusException);
- assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException)ex.getCause()).getCode());
+ WebServiceContext ctx = greeter.getContext();
+ assertNull(ctx);
+ try {
+ String address = "http://localhost:8080/test";
+ endpoint.publish(address);
+ } catch (IllegalArgumentException ex) {
+ assertTrue(ex.getCause() instanceof BusException);
+ assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException)ex.getCause()).getCode());
+ }
+ ctx = greeter.getContext();
+
+ assertNotNull(ctx);
}
- ctx = greeter.getContext();
-
- assertNotNull(ctx);
}
@Test
@@ -158,15 +160,16 @@ public class EndpointImplTest extends AbstractJaxWsTest {
serviceFactory.setInvoker(new BeanInvoker(hello));
serviceFactory.setServiceClass(HelloImpl.class);
- EndpointImpl endpoint = new EndpointImpl(getBus(), hello,
- new JaxWsServerFactoryBean(serviceFactory));
+ try (EndpointImpl endpoint = new EndpointImpl(getBus(), hello,
+ new JaxWsServerFactoryBean(serviceFactory))) {
- try {
- String address = "http://localhost:8080/test";
- endpoint.publish(address);
- } catch (IllegalArgumentException ex) {
- assertTrue(ex.getCause() instanceof BusException);
- assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException)ex.getCause()).getCode());
+ try {
+ String address = "http://localhost:8080/test";
+ endpoint.publish(address);
+ } catch (IllegalArgumentException ex) {
+ assertTrue(ex.getCause() instanceof BusException);
+ assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException)ex.getCause()).getCode());
+ }
}
}
@@ -189,20 +192,21 @@ public class EndpointImplTest extends AbstractJaxWsTest {
@Test
public void testPublishEndpointPermission() throws Exception {
Hello service = new Hello();
- EndpointImpl ep = new EndpointImpl(getBus(), service, (String) null);
-
- System.setProperty(EndpointImpl.CHECK_PUBLISH_ENDPOINT_PERMISSON_PROPERTY, "true");
+ try (EndpointImpl ep = new EndpointImpl(getBus(), service, (String) null)) {
- try {
+ System.setProperty(EndpointImpl.CHECK_PUBLISH_ENDPOINT_PERMISSON_PROPERTY, "true");
+
+ try {
+ ep.publish("local://localhost:9090/hello");
+ fail("Did not throw exception as expected");
+ } catch (SecurityException e) {
+ // that's expected
+ } finally {
+ System.setProperty(EndpointImpl.CHECK_PUBLISH_ENDPOINT_PERMISSON_PROPERTY, "false");
+ }
+
ep.publish("local://localhost:9090/hello");
- fail("Did not throw exception as expected");
- } catch (SecurityException e) {
- // that's expected
- } finally {
- System.setProperty(EndpointImpl.CHECK_PUBLISH_ENDPOINT_PERMISSON_PROPERTY, "false");
}
-
- ep.publish("local://localhost:9090/hello");
}
@Test
@@ -213,20 +217,21 @@ public class EndpointImplTest extends AbstractJaxWsTest {
serviceFactory.setInvoker(new BeanInvoker(greeter));
serviceFactory.setServiceClass(GreeterImpl.class);
- EndpointImpl endpoint = new EndpointImpl(getBus(), greeter,
- new JaxWsServerFactoryBean(serviceFactory));
+ try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter,
+ new JaxWsServerFactoryBean(serviceFactory))) {
- endpoint.getFeatures().add(new WSAddressingFeature());
- try {
- String address = "http://localhost:8080/test";
- endpoint.publish(address);
- } catch (IllegalArgumentException ex) {
- assertTrue(ex.getCause() instanceof BusException);
- assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException)ex.getCause()).getCode());
+ endpoint.getFeatures().add(new WSAddressingFeature());
+ try {
+ String address = "http://localhost:8080/test";
+ endpoint.publish(address);
+ } catch (IllegalArgumentException ex) {
+ assertTrue(ex.getCause() instanceof BusException);
+ assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException)ex.getCause()).getCode());
+ }
+
+ assertTrue(serviceFactory.getFeatures().size() == 1);
+ assertTrue(serviceFactory.getFeatures().get(0) instanceof WSAddressingFeature);
}
-
- assertTrue(serviceFactory.getFeatures().size() == 1);
- assertTrue(serviceFactory.getFeatures().get(0) instanceof WSAddressingFeature);
}
@Test
@@ -237,18 +242,19 @@ public class EndpointImplTest extends AbstractJaxWsTest {
serviceFactory.setInvoker(new BeanInvoker(greeter));
serviceFactory.setServiceClass(HelloWsa.class);
- EndpointImpl endpoint = new EndpointImpl(getBus(), greeter,
- new JaxWsServerFactoryBean(serviceFactory));
- try {
- String address = "http://localhost:8080/test";
- endpoint.publish(address);
- } catch (IllegalArgumentException ex) {
- assertTrue(ex.getCause() instanceof BusException);
- assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException)ex.getCause()).getCode());
+ try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter,
+ new JaxWsServerFactoryBean(serviceFactory))) {
+ try {
+ String address = "http://localhost:8080/test";
+ endpoint.publish(address);
+ } catch (IllegalArgumentException ex) {
+ assertTrue(ex.getCause() instanceof BusException);
+ assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException)ex.getCause()).getCode());
+ }
+
+ assertEquals(1, serviceFactory.getFeatures().size());
+ assertTrue(serviceFactory.getFeatures().get(0) instanceof WSAddressingFeature);
}
-
- assertEquals(1, serviceFactory.getFeatures().size());
- assertTrue(serviceFactory.getFeatures().get(0) instanceof WSAddressingFeature);
}
@Test
@@ -260,6 +266,7 @@ public class EndpointImplTest extends AbstractJaxWsTest {
// CXF-6257
endpoint.publish("http://localhost:8080/test");
+ endpoint.stop();
}
static class EchoObserver implements MessageObserver {
http://git-wip-us.apache.org/repos/asf/cxf/blob/6ef5be58/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java
index 9cc521a..c2de0fc 100644
--- a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java
+++ b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/EndpointReferenceTest.java
@@ -121,138 +121,143 @@ public class EndpointReferenceTest extends AbstractJaxWsTest {
public void testServiceGetPortUsingEndpointReference() throws Exception {
BusFactory.setDefaultBus(getBus());
GreeterImpl greeter1 = new GreeterImpl();
- EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String)null);
- endpoint.publish("http://localhost:8080/test");
-
- javax.xml.ws.Service s = javax.xml.ws.Service
- .create(new QName("http://apache.org/hello_world_soap_http", "SoapPort"));
-
- InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
- Document doc = StaxUtils.read(is);
- DOMSource erXML = new DOMSource(doc);
- EndpointReference endpointReference = EndpointReference.readFrom(erXML);
-
- WebServiceFeature[] wfs = new WebServiceFeature[] {};
-
- Greeter greeter = s.getPort(endpointReference, Greeter.class, wfs);
-
- String response = greeter.greetMe("John");
-
- assertEquals("Hello John", response);
+ try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String)null)) {
+ endpoint.publish("http://localhost:8080/test");
+
+ javax.xml.ws.Service s = javax.xml.ws.Service
+ .create(new QName("http://apache.org/hello_world_soap_http", "SoapPort"));
+
+ InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
+ Document doc = StaxUtils.read(is);
+ DOMSource erXML = new DOMSource(doc);
+ EndpointReference endpointReference = EndpointReference.readFrom(erXML);
+
+ WebServiceFeature[] wfs = new WebServiceFeature[] {};
+
+ Greeter greeter = s.getPort(endpointReference, Greeter.class, wfs);
+
+ String response = greeter.greetMe("John");
+
+ assertEquals("Hello John", response);
+ }
}
@Test
public void testEndpointReferenceGetPort() throws Exception {
BusFactory.setDefaultBus(getBus());
GreeterImpl greeter1 = new GreeterImpl();
- EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String)null);
- endpoint.publish("http://localhost:8080/test");
-
- InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
- Document doc = StaxUtils.read(is);
- DOMSource erXML = new DOMSource(doc);
- EndpointReference endpointReference = EndpointReference.readFrom(erXML);
-
- WebServiceFeature[] wfs = new WebServiceFeature[] {};
-
- Greeter greeter = endpointReference.getPort(Greeter.class, wfs);
-
- String response = greeter.greetMe("John");
- assertEquals("Hello John", response);
+ try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String)null)) {
+ endpoint.publish("http://localhost:8080/test");
+
+ InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
+ Document doc = StaxUtils.read(is);
+ DOMSource erXML = new DOMSource(doc);
+ EndpointReference endpointReference = EndpointReference.readFrom(erXML);
+
+ WebServiceFeature[] wfs = new WebServiceFeature[] {};
+
+ Greeter greeter = endpointReference.getPort(Greeter.class, wfs);
+
+ String response = greeter.greetMe("John");
+ assertEquals("Hello John", response);
+ }
}
@Test
public void testEndpointGetEndpointReferenceSOAPBinding() throws Exception {
GreeterImpl greeter = new GreeterImpl();
- EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String)null);
- endpoint.publish("http://localhost:8080/test");
-
- InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
- Document doc = StaxUtils.read(is);
- Element referenceParameters = fetchElementByNameAttribute(doc.getDocumentElement(),
- "wsa:ReferenceParameters",
- "");
- EndpointReference endpointReference = endpoint.getEndpointReference(referenceParameters);
- assertNotNull(endpointReference);
- assertTrue(endpointReference instanceof W3CEndpointReference);
-
- //A returned W3CEndpointReferenceMUST also contain the specified referenceParameters.
- //W3CEndpointReference wer = (W3CEndpointReference)endpointReference;
-
- endpoint.stop();
- }
+ try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String)null)) {
+ endpoint.publish("http://localhost:8080/test");
- @Test
- @Ignore("Not implemented yet")
- public void testEndpointGetEndpointReferenceXMLBinding() throws Exception {
- org.apache.hello_world_xml_http.bare.Greeter greeter =
- new org.apache.hello_world_xml_http.bare.GreeterImpl();
- EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String)null);
-
- endpoint.publish("http://localhost:8080/test");
-
- try {
InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
Document doc = StaxUtils.read(is);
Element referenceParameters = fetchElementByNameAttribute(doc.getDocumentElement(),
"wsa:ReferenceParameters",
"");
- endpoint.getEndpointReference(referenceParameters);
-
- fail("Did not get expected UnsupportedOperationException");
- } catch (UnsupportedOperationException e) {
- //do nothing
+ EndpointReference endpointReference = endpoint.getEndpointReference(referenceParameters);
+ assertNotNull(endpointReference);
+ assertTrue(endpointReference instanceof W3CEndpointReference);
+
+ //A returned W3CEndpointReferenceMUST also contain the specified referenceParameters.
+ //W3CEndpointReference wer = (W3CEndpointReference)endpointReference;
+ endpoint.stop();
}
-
- endpoint.stop();
}
@Test
- public void testEndpointGetEndpointReferenceW3C() throws Exception {
- GreeterImpl greeter = new GreeterImpl();
- EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String)null);
-
- endpoint.publish("http://localhost:8080/test");
-
- InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
- Document doc = StaxUtils.read(is);
- Element referenceParameters = fetchElementByNameAttribute(doc.getDocumentElement(),
- "wsa:ReferenceParameters",
- "");
- EndpointReference endpointReference = endpoint.getEndpointReference(W3CEndpointReference.class,
- referenceParameters);
- assertNotNull(endpointReference);
-
- assertTrue(endpointReference instanceof W3CEndpointReference);
-
- //A returned W3CEndpointReferenceMUST also contain the specified referenceParameters.
- //W3CEndpointReference wer = (W3CEndpointReference)endpointReference;
+ @Ignore("Not implemented yet")
+ public void testEndpointGetEndpointReferenceXMLBinding() throws Exception {
+ org.apache.hello_world_xml_http.bare.Greeter greeter =
+ new org.apache.hello_world_xml_http.bare.GreeterImpl();
+ try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String)null)) {
- endpoint.stop();
- }
+ endpoint.publish("http://localhost:8080/test");
+ try {
+ InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
+ Document doc = StaxUtils.read(is);
+ Element referenceParameters = fetchElementByNameAttribute(doc.getDocumentElement(),
+ "wsa:ReferenceParameters",
+ "");
+ endpoint.getEndpointReference(referenceParameters);
+
+ fail("Did not get expected UnsupportedOperationException");
+ } catch (UnsupportedOperationException e) {
+ //do nothing
+ }
+
+ endpoint.stop();
+ }
+ }
@Test
- public void testEndpointGetEndpointReferenceInvalid() throws Exception {
+ public void testEndpointGetEndpointReferenceW3C() throws Exception {
GreeterImpl greeter = new GreeterImpl();
- EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String)null);
+ try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String)null)) {
- endpoint.publish("http://localhost:8080/test");
-
- try {
+ endpoint.publish("http://localhost:8080/test");
+
InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
Document doc = StaxUtils.read(is);
Element referenceParameters = fetchElementByNameAttribute(doc.getDocumentElement(),
"wsa:ReferenceParameters",
"");
- endpoint.getEndpointReference(MyEndpointReference.class, referenceParameters);
-
- fail("Did not get expected WebServiceException");
- } catch (WebServiceException e) {
- // do nothing
+ EndpointReference endpointReference = endpoint.getEndpointReference(W3CEndpointReference.class,
+ referenceParameters);
+ assertNotNull(endpointReference);
+
+ assertTrue(endpointReference instanceof W3CEndpointReference);
+
+ //A returned W3CEndpointReferenceMUST also contain the specified referenceParameters.
+ //W3CEndpointReference wer = (W3CEndpointReference)endpointReference;
+
+ endpoint.stop();
+ }
+ }
+
+
+ @Test
+ public void testEndpointGetEndpointReferenceInvalid() throws Exception {
+ GreeterImpl greeter = new GreeterImpl();
+ try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String)null)) {
+
+ endpoint.publish("http://localhost:8080/test");
+
+ try {
+ InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
+ Document doc = StaxUtils.read(is);
+ Element referenceParameters = fetchElementByNameAttribute(doc.getDocumentElement(),
+ "wsa:ReferenceParameters",
+ "");
+ endpoint.getEndpointReference(MyEndpointReference.class, referenceParameters);
+
+ fail("Did not get expected WebServiceException");
+ } catch (WebServiceException e) {
+ // do nothing
+ }
+
+ endpoint.stop();
}
-
- endpoint.stop();
}
@Test
@@ -298,22 +303,23 @@ public class EndpointReferenceTest extends AbstractJaxWsTest {
public void testProviderGetPort() throws Exception {
BusFactory.setDefaultBus(getBus());
GreeterImpl greeter1 = new GreeterImpl();
- EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String)null);
- endpoint.publish("http://localhost:8080/test");
-
- ProviderImpl provider = new ProviderImpl();
-
- InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
- Document doc = StaxUtils.read(is);
- DOMSource erXML = new DOMSource(doc);
- EndpointReference endpointReference = EndpointReference.readFrom(erXML);
-
- WebServiceFeature[] wfs = new WebServiceFeature[] {};
-
- Greeter greeter = provider.getPort(endpointReference, Greeter.class, wfs);
-
- String response = greeter.greetMe("John");
- assertEquals("Hello John", response);
+ try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String)null)) {
+ endpoint.publish("http://localhost:8080/test");
+
+ ProviderImpl provider = new ProviderImpl();
+
+ InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
+ Document doc = StaxUtils.read(is);
+ DOMSource erXML = new DOMSource(doc);
+ EndpointReference endpointReference = EndpointReference.readFrom(erXML);
+
+ WebServiceFeature[] wfs = new WebServiceFeature[] {};
+
+ Greeter greeter = provider.getPort(endpointReference, Greeter.class, wfs);
+
+ String response = greeter.greetMe("John");
+ assertEquals("Hello John", response);
+ }
}
final class MyEndpointReference extends EndpointReference {
http://git-wip-us.apache.org/repos/asf/cxf/blob/6ef5be58/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/provider/ProviderTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/provider/ProviderTest.java b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/provider/ProviderTest.java
index eb25126..5d74c89 100644
--- a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/provider/ProviderTest.java
+++ b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/provider/ProviderTest.java
@@ -28,34 +28,36 @@ import org.junit.Test;
public class ProviderTest extends AbstractJaxWsTest {
@Test
public void testInvocation() throws Exception {
- EndpointImpl ep = new EndpointImpl(getBus(), new PayloadProvider(), (String) null);
- ep.publish("local://localhost:9000/Provider");
-
- Node response = invoke("local://localhost:9000/Provider",
- LocalTransportFactory.TRANSPORT_ID,
- "/org/apache/cxf/jaxws/sayHi.xml");
-
- assertNotNull(response);
- assertNoFault(response);
-
- addNamespace("j", "http://service.jaxws.cxf.apache.org/");
- assertValid("//s:Body/j:sayHi", response);
+ try (EndpointImpl ep = new EndpointImpl(getBus(), new PayloadProvider(), (String) null)) {
+ ep.publish("local://localhost:9000/Provider");
+
+ Node response = invoke("local://localhost:9000/Provider",
+ LocalTransportFactory.TRANSPORT_ID,
+ "/org/apache/cxf/jaxws/sayHi.xml");
+
+ assertNotNull(response);
+ assertNoFault(response);
+
+ addNamespace("j", "http://service.jaxws.cxf.apache.org/");
+ assertValid("//s:Body/j:sayHi", response);
+ }
}
@Test
public void testCXF1852() throws Exception {
- EndpointImpl ep = new EndpointImpl(getBus(), new PayloadProvider2(), (String) null);
- ep.publish("local://localhost:9001/Provider2");
-
- Node response = invoke("local://localhost:9001/Provider2",
- LocalTransportFactory.TRANSPORT_ID,
- "/org/apache/cxf/jaxws/sayHi.xml");
-
- assertNotNull(response);
- assertNoFault(response);
-
- addNamespace("j", "http://service.jaxws.cxf.apache.org/");
- assertValid("//s:Body/j:sayHi", response);
+ try (EndpointImpl ep = new EndpointImpl(getBus(), new PayloadProvider2(), (String) null)) {
+ ep.publish("local://localhost:9001/Provider2");
+
+ Node response = invoke("local://localhost:9001/Provider2",
+ LocalTransportFactory.TRANSPORT_ID,
+ "/org/apache/cxf/jaxws/sayHi.xml");
+
+ assertNotNull(response);
+ assertNoFault(response);
+
+ addNamespace("j", "http://service.jaxws.cxf.apache.org/");
+ assertValid("//s:Body/j:sayHi", response);
+ }
}
public static class PayloadProvider2 extends PayloadProvider {
http://git-wip-us.apache.org/repos/asf/cxf/blob/6ef5be58/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/HttpNumberFactoryImpl.java
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/HttpNumberFactoryImpl.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/HttpNumberFactoryImpl.java
index d51c8a0..16af0ad 100644
--- a/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/HttpNumberFactoryImpl.java
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/HttpNumberFactoryImpl.java
@@ -64,6 +64,7 @@ public class HttpNumberFactoryImpl extends NumberFactoryImpl {
new EndpointImpl(bus, servant, bindingId, wsdlLocation);
ep.setEndpointName(new QName(NUMBER_SERVICE_QNAME.getNamespaceURI(), "NumberPort"));
ep.publish(getServantAddressRoot());
+ endpoints.add(ep);
templateEpr = ep.getServer().getDestination().getAddress();
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/6ef5be58/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/ManualHttpMulitplexClientServerTest.java
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/ManualHttpMulitplexClientServerTest.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/ManualHttpMulitplexClientServerTest.java
index 0ffeb95..3419adf 100644
--- a/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/ManualHttpMulitplexClientServerTest.java
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/ManualHttpMulitplexClientServerTest.java
@@ -44,6 +44,7 @@ import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
import org.apache.cxf.testutil.common.TestUtil;
import org.apache.cxf.ws.addressing.EndpointReferenceType;
import org.apache.cxf.ws.addressing.EndpointReferenceUtils;
+
import org.junit.BeforeClass;
import org.junit.Test;
@@ -55,14 +56,17 @@ public class ManualHttpMulitplexClientServerTest extends AbstractBusClientServer
public static class Server extends AbstractBusTestServerBase {
Endpoint ep;
+ ManualNumberFactoryImpl implementor;
protected void run() {
setBus(BusFactory.getDefaultBus());
- Object implementor = new ManualNumberFactoryImpl(getBus(), PORT);
+ implementor = new ManualNumberFactoryImpl(getBus(), PORT);
ep = Endpoint.publish(FACTORY_ADDRESS, implementor);
}
- public void tearDown() {
+ public void tearDown() throws Exception {
ep.stop();
ep = null;
+ implementor.stop();
+ implementor = null;
}
public static void main(String[] args) {
http://git-wip-us.apache.org/repos/asf/cxf/blob/6ef5be58/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/ManualNumberFactoryImpl.java
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/ManualNumberFactoryImpl.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/ManualNumberFactoryImpl.java
index 769d9d8..9d93a2e 100644
--- a/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/ManualNumberFactoryImpl.java
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/ManualNumberFactoryImpl.java
@@ -58,6 +58,7 @@ public class ManualNumberFactoryImpl extends NumberFactoryImpl {
new EndpointImpl(bus, servant, bindingId, wsdlLocation);
ep.setEndpointName(new QName(NUMBER_SERVICE_QNAME.getNamespaceURI(), "NumberPort"));
ep.publish(getServantAddressRoot());
+ endpoints.add(ep);
templateEpr = ep.getServer().getDestination().getAddress();
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/6ef5be58/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexClientServerTest.java
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexClientServerTest.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexClientServerTest.java
index 5a50db8..b32a014 100644
--- a/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexClientServerTest.java
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexClientServerTest.java
@@ -54,13 +54,20 @@ public class MultiplexClientServerTest extends AbstractBusClientServerTestBase {
public static class Server extends AbstractBusTestServerBase {
Endpoint ep;
+ NumberFactoryImpl implementor;
protected void run() {
- Object implementor = new NumberFactoryImpl(BusFactory.getDefaultBus(), PORT);
+ implementor = new NumberFactoryImpl(BusFactory.getDefaultBus(), PORT);
ep = Endpoint.publish(FACTORY_ADDRESS, implementor);
}
public void tearDown() {
ep.stop();
ep = null;
+ try {
+ implementor.stop();
+ } catch (Exception e) {
+ //ignore
+ }
+ implementor = null;
}
public static void main(String[] args) {
http://git-wip-us.apache.org/repos/asf/cxf/blob/6ef5be58/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java
index 10994c8..d358eb0 100644
--- a/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java
@@ -59,14 +59,17 @@ public class MultiplexHttpAddressClientServerTest extends AbstractBusClientServe
public static class Server extends AbstractBusTestServerBase {
Endpoint ep;
+ HttpNumberFactoryImpl implementor;
protected void run() {
setBus(new SpringBusFactory().createBus("org/apache/cxf/systest/factory_pattern/cxf.xml"));
- Object implementor = new HttpNumberFactoryImpl(getBus(), PORT);
+ implementor = new HttpNumberFactoryImpl(getBus(), PORT);
ep = Endpoint.publish(FACTORY_ADDRESS, implementor);
}
- public void tearDown() {
+ public void tearDown() throws Exception {
ep.stop();
ep = null;
+ implementor.stop();
+ implementor = null;
}
public static void main(String[] args) {
http://git-wip-us.apache.org/repos/asf/cxf/blob/6ef5be58/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/NumberFactoryImpl.java
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/NumberFactoryImpl.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/NumberFactoryImpl.java
index d218440..876cdf1 100644
--- a/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/NumberFactoryImpl.java
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/factory_pattern/NumberFactoryImpl.java
@@ -19,6 +19,9 @@
package org.apache.cxf.systest.factory_pattern;
+import java.util.LinkedList;
+import java.util.List;
+
import javax.jws.WebService;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
@@ -49,11 +52,18 @@ public class NumberFactoryImpl implements NumberFactory {
protected NumberImpl servant;
protected Bus bus;
protected String port;
+ protected List<AutoCloseable> endpoints = new LinkedList<AutoCloseable>();
public NumberFactoryImpl(Bus b, String p) {
bus = b;
port = p;
}
+
+ public void stop() throws Exception {
+ for (AutoCloseable ep: endpoints) {
+ ep.close();
+ }
+ }
public W3CEndpointReference create(String id) {
@@ -92,6 +102,8 @@ public class NumberFactoryImpl implements NumberFactory {
servant, bindingId, wsdlLocation);
ep.setEndpointName(new QName(NUMBER_SERVICE_QNAME.getNamespaceURI(), "NumberPort"));
ep.publish(getServantAddressRoot());
+ endpoints.add(ep);
+
templateEpr = ep.getServer().getDestination().getAddress();
// jms port
@@ -102,6 +114,7 @@ public class NumberFactoryImpl implements NumberFactory {
ep.publish();
ep.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
ep.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
+ endpoints.add(ep);
}
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/6ef5be58/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_responses/Server.java
----------------------------------------------------------------------
diff --git a/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_responses/Server.java b/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_responses/Server.java
index 8eb8ad4..5665656 100644
--- a/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_responses/Server.java
+++ b/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_responses/Server.java
@@ -25,15 +25,22 @@ import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
public class Server extends AbstractBusTestServerBase {
static final String PORT = allocatePort(Server.class);
+ EndpointImpl ep;
protected void run() {
Object implementor = new HelloImpl();
String address = "http://localhost:" + PORT + "/wsa/responses";
- EndpointImpl ep = new EndpointImpl(BusFactory.getThreadDefaultBus(),
+ ep = new EndpointImpl(BusFactory.getThreadDefaultBus(),
implementor,
null,
getWsdl());
ep.publish(address);
}
+ public void tearDown() throws Exception {
+ if (ep != null) {
+ ep.close();
+ }
+ ep = null;
+ }
public static void main(String[] args) {
try {