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 21:19:46 UTC
[18/20] cxf git commit: [CXF-6392] Schema imports are not handled
correctly in generated WSDL and XSD files
[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/04d30cc5
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/04d30cc5
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/04d30cc5
Branch: refs/heads/3.0.x-fixes
Commit: 04d30cc5051de1846f2c226526ff1f215827df5c
Parents: d43cf7d
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:38:31 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/04d30cc5/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/04d30cc5/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/04d30cc5/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/04d30cc5/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/04d30cc5/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/04d30cc5/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/04d30cc5/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>