Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3447A10FB6 for ; Wed, 19 Mar 2014 03:39:13 +0000 (UTC) Received: (qmail 52812 invoked by uid 500); 19 Mar 2014 03:39:11 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 52759 invoked by uid 500); 19 Mar 2014 03:39:11 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 52752 invoked by uid 99); 19 Mar 2014 03:39:11 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Mar 2014 03:39:11 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id A5C44983A87; Wed, 19 Mar 2014 03:39:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ema@apache.org To: commits@cxf.apache.org Message-Id: <7dfb3598a8fc4993b35204e8d0731a49@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: [CXF-4910]:Refactor to better support more relative import path Date: Wed, 19 Mar 2014 03:39:10 +0000 (UTC) Repository: cxf Updated Branches: refs/heads/2.7.x-fixes 56fe9fa38 -> da898e937 [CXF-4910]:Refactor to better support more relative import path Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/da898e93 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/da898e93 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/da898e93 Branch: refs/heads/2.7.x-fixes Commit: da898e937f174b7319e8fa59de69ce69801e3d1d Parents: 56fe9fa Author: Jim Ma Authored: Wed Mar 19 11:13:32 2014 +0800 Committer: Jim Ma Committed: Wed Mar 19 11:38:36 2014 +0800 ---------------------------------------------------------------------- .../org/apache/cxf/frontend/WSDLGetUtils.java | 21 ++++-- .../systest/schemaimport/SchemaImportTest.java | 26 +++++++- .../apache/cxf/systest/schemaimport/Server.java | 3 + .../cxf/systest/schemaimport/TestEndpoint.java | 26 ++++++++ .../systest/schemaimport/TestEndpointImpl.java | 32 +++++++++ .../wsdl_systest/import/TestService.wsdl | 70 ++++++++++++++++++++ .../resources/wsdl_systest/import/schema1.xsd | 24 +++++++ .../resources/wsdl_systest/import/schema2.xsd | 23 +++++++ .../resources/wsdl_systest/import/schema3.xsd | 23 +++++++ .../resources/wsdl_systest/import/schema4.xsd | 24 +++++++ .../resources/wsdl_systest/import/schema5.xsd | 23 +++++++ .../test/resources/wsdl_systest/sayhi/a.wsdl | 2 +- 12 files changed, 288 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/da898e93/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 11fed9b..f5734a3 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 @@ -277,8 +277,11 @@ public class WSDLGetUtils { throws UnsupportedEncodingException { String key = loc; try { - if (!(new URI(loc).isAbsolute()) && xsd != null && !UrlUtils.getStem(xsd).equals(xsd)) { - key = UrlUtils.getStem(xsd) + "/" + loc; + if (!(new URI(loc).isAbsolute()) && xsd != null) { + key = new URI(xsd).resolve(loc).toString(); + } + if (!(new URI(loc).isAbsolute()) && xsd == null) { + key = new URI(".").resolve(loc).toString(); } } catch (URISyntaxException e) { //ignore @@ -335,7 +338,10 @@ public class WSDLGetUtils { String sl = el.getAttribute("location"); try { if (!StringUtils.isEmpty(wsdl) && !(new URI(sl).isAbsolute())) { - sl = UrlUtils.getStem(wsdl) + "/" + sl; + sl = new URI(wsdl).resolve(sl).toString(); + } + if (StringUtils.isEmpty(wsdl) && !(new URI(sl).isAbsolute())) { + sl = new URI(".").resolve(sl).toString(); } } catch (URISyntaxException e) { //ignore @@ -467,9 +473,12 @@ public class WSDLGetUtils { new URL(start); } catch (MalformedURLException e) { try { - if (!(new URI(docBase).isAbsolute()) && !(new URI(start).isAbsolute()) - && !StringUtils.isEmpty(docBase)) { - start = UrlUtils.getStem(docBase) + "/" + start; + if (!StringUtils.isEmpty(docBase) && !(new URI(start).isAbsolute())) { + start = new URI(docBase).resolve(start).toString(); + decodedStart = URLDecoder.decode(start, "utf-8"); + } + if (StringUtils.isEmpty(docBase) && !(new URI(start).isAbsolute())) { + start = new URI(".").resolve(start).toString(); decodedStart = URLDecoder.decode(start, "utf-8"); } } catch (Exception e1) { http://git-wip-us.apache.org/repos/asf/cxf/blob/da898e93/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/SchemaImportTest.java ---------------------------------------------------------------------- diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/SchemaImportTest.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/SchemaImportTest.java index 797da87..48c4877 100644 --- a/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/SchemaImportTest.java +++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/SchemaImportTest.java @@ -56,8 +56,8 @@ public class SchemaImportTest extends AbstractBusClientServerTestBase { @Test public void testImportWsdl() throws Exception { - String schemaURL = "http://localhost:" + PORT + "/schemaimport/sayHi" + "?wsdl=sayhi/sayhi/a.wsdl"; - URL url = new URL(schemaURL); + String wsdlURL = "http://localhost:" + PORT + "/schemaimport/sayHi" + "?wsdl=sayhi/sayhi/a.wsdl"; + URL url = new URL(wsdlURL); InputStream ins = null; try { ins = url.openStream(); @@ -73,5 +73,27 @@ public class SchemaImportTest extends AbstractBusClientServerTestBase { } } } + + + @Test + public void testAnotherSchemaImportl() throws Exception { + String schemaURL = "http://localhost:" + PORT + "/schemaimport/service" + "?xsd=schema1.xsd"; + URL url = new URL(schemaURL); + InputStream ins = null; + try { + ins = url.openStream(); + String output = IOUtils.toString(ins); + assertTrue(output.indexOf("schemaimport/service?xsd=schema2.xsd") > -1); + assertTrue(output.indexOf("schemaimport/service?xsd=schema5.xsd") > -1); + } catch (Exception e) { + e.printStackTrace(); + fail("Can not access the import wsdl"); + + } finally { + if (ins != null) { + ins.close(); + } + } + } } http://git-wip-us.apache.org/repos/asf/cxf/blob/da898e93/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/Server.java ---------------------------------------------------------------------- diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/Server.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/Server.java index 752f1b0..d240898 100644 --- a/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/Server.java +++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/Server.java @@ -32,6 +32,9 @@ public class Server extends AbstractBusTestServerBase { Object implementor = new SayHiImpl(); String address = "http://localhost:" + PORT + "/schemaimport/sayHi"; Endpoint.publish(address, implementor); + Object implementor2 = new TestEndpointImpl(); + String address2 = "http://localhost:" + PORT + "/schemaimport/service"; + Endpoint.publish(address2, implementor2); } public static void main(String[] args) { http://git-wip-us.apache.org/repos/asf/cxf/blob/da898e93/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/TestEndpoint.java ---------------------------------------------------------------------- diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/TestEndpoint.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/TestEndpoint.java new file mode 100644 index 0000000..cc45c95 --- /dev/null +++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/TestEndpoint.java @@ -0,0 +1,26 @@ +/** + * 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. + */ +package org.apache.cxf.systest.schemaimport; + +import javax.jws.WebService; + +@WebService(name = "TestEndpoint", targetNamespace = "http://cxf.apache.org/schemaimport") +public interface TestEndpoint { + String echo(final String message); +} http://git-wip-us.apache.org/repos/asf/cxf/blob/da898e93/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/TestEndpointImpl.java ---------------------------------------------------------------------- diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/TestEndpointImpl.java b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/TestEndpointImpl.java new file mode 100644 index 0000000..7009474 --- /dev/null +++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/schemaimport/TestEndpointImpl.java @@ -0,0 +1,32 @@ +/** + * 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. + */ +package org.apache.cxf.systest.schemaimport; + +import javax.jws.WebService; + +@WebService(name = "TestEndpoint", serviceName = "TestEndpointService", +targetNamespace = "http://cxf.apache.org/schemaimport", +wsdlLocation = "classpath:/wsdl_systest/import/TestService.wsdl") +public class TestEndpointImpl implements TestEndpoint { + + public String echo(String message) { + return message; + } + +} http://git-wip-us.apache.org/repos/asf/cxf/blob/da898e93/systests/uncategorized/src/test/resources/wsdl_systest/import/TestService.wsdl ---------------------------------------------------------------------- diff --git a/systests/uncategorized/src/test/resources/wsdl_systest/import/TestService.wsdl b/systests/uncategorized/src/test/resources/wsdl_systest/import/TestService.wsdl new file mode 100644 index 0000000..52b9103 --- /dev/null +++ b/systests/uncategorized/src/test/resources/wsdl_systest/import/TestService.wsdl @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/da898e93/systests/uncategorized/src/test/resources/wsdl_systest/import/schema1.xsd ---------------------------------------------------------------------- diff --git a/systests/uncategorized/src/test/resources/wsdl_systest/import/schema1.xsd b/systests/uncategorized/src/test/resources/wsdl_systest/import/schema1.xsd new file mode 100644 index 0000000..5d1a7ed --- /dev/null +++ b/systests/uncategorized/src/test/resources/wsdl_systest/import/schema1.xsd @@ -0,0 +1,24 @@ + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/da898e93/systests/uncategorized/src/test/resources/wsdl_systest/import/schema2.xsd ---------------------------------------------------------------------- diff --git a/systests/uncategorized/src/test/resources/wsdl_systest/import/schema2.xsd b/systests/uncategorized/src/test/resources/wsdl_systest/import/schema2.xsd new file mode 100644 index 0000000..ed2a010 --- /dev/null +++ b/systests/uncategorized/src/test/resources/wsdl_systest/import/schema2.xsd @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/da898e93/systests/uncategorized/src/test/resources/wsdl_systest/import/schema3.xsd ---------------------------------------------------------------------- diff --git a/systests/uncategorized/src/test/resources/wsdl_systest/import/schema3.xsd b/systests/uncategorized/src/test/resources/wsdl_systest/import/schema3.xsd new file mode 100644 index 0000000..ac098d9 --- /dev/null +++ b/systests/uncategorized/src/test/resources/wsdl_systest/import/schema3.xsd @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/da898e93/systests/uncategorized/src/test/resources/wsdl_systest/import/schema4.xsd ---------------------------------------------------------------------- diff --git a/systests/uncategorized/src/test/resources/wsdl_systest/import/schema4.xsd b/systests/uncategorized/src/test/resources/wsdl_systest/import/schema4.xsd new file mode 100644 index 0000000..24b7dba --- /dev/null +++ b/systests/uncategorized/src/test/resources/wsdl_systest/import/schema4.xsd @@ -0,0 +1,24 @@ + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/da898e93/systests/uncategorized/src/test/resources/wsdl_systest/import/schema5.xsd ---------------------------------------------------------------------- diff --git a/systests/uncategorized/src/test/resources/wsdl_systest/import/schema5.xsd b/systests/uncategorized/src/test/resources/wsdl_systest/import/schema5.xsd new file mode 100644 index 0000000..ad9e2fd --- /dev/null +++ b/systests/uncategorized/src/test/resources/wsdl_systest/import/schema5.xsd @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf/blob/da898e93/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/a.wsdl ---------------------------------------------------------------------- diff --git a/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/a.wsdl b/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/a.wsdl index 4641052..a8ea7ef 100644 --- a/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/a.wsdl +++ b/systests/uncategorized/src/test/resources/wsdl_systest/sayhi/a.wsdl @@ -18,7 +18,7 @@ under the License. --> - +