Author: dkulp
Date: Thu Apr 15 03:03:57 2010
New Revision: 934270
URL: http://svn.apache.org/viewvc?rev=934270&view=rev
Log:
[CXF-2765] Support imports in folders with spaces
Patch from William Tam applied
Added:
cxf/trunk/common/common/src/test/resources/schemas/configuration/folder
with spaces/
cxf/trunk/common/common/src/test/resources/schemas/configuration/folder
with spaces/bar.xsd
Modified:
cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
cxf/trunk/common/common/src/test/java/org/apache/cxf/resource/URIResolverTest.java
Modified:
cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java?rev=934270&r1=934269&r2=934270&view=diff
==============================================================================
---
cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
(original)
+++
cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
Thu Apr 15 03:03:57 2010
@@ -181,7 +181,8 @@ public class URIResolver {
base = base.resolve(relative);
if (base.isAbsolute() &&
"file".equalsIgnoreCase(base.getScheme())) {
try {
- baseFile = new File(base);
+ // decode space before create a file
+ baseFile = new File(base.getPath().replace("%20", "
"));
if (baseFile.exists()) {
is = base.toURL().openStream();
uri = base;
@@ -253,7 +254,8 @@ public class URIResolver {
}
}
- return path;
+ // decode spaces before returning otherwise File.exists returns false
+ return path.replace("%20", " ");
}
private void tryArchive(String baseStr, String uriStr) throws IOException {
Modified:
cxf/trunk/common/common/src/test/java/org/apache/cxf/resource/URIResolverTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/common/common/src/test/java/org/apache/cxf/resource/URIResolverTest.java?rev=934270&r1=934269&r2=934270&view=diff
==============================================================================
---
cxf/trunk/common/common/src/test/java/org/apache/cxf/resource/URIResolverTest.java
(original)
+++
cxf/trunk/common/common/src/test/java/org/apache/cxf/resource/URIResolverTest.java
Thu Apr 15 03:03:57 2010
@@ -110,5 +110,30 @@ public class URIResolverTest extends Ass
assertNotNull(xsdResolver.getInputStream());
}
+
+ @Test
+ public void testResolvePathWithSpace() throws Exception {
+ URIResolver wsdlResolver = new URIResolver();
+
+ // resolve the wsdl
+ wsdlResolver.resolve(null, "wsdl/foo.wsdl", this.getClass());
+ assertTrue(wsdlResolver.isResolved());
+
+ // get the base uri from the resolved wsdl location
+ String baseUri = wsdlResolver.getURI().toString();
+
+ // resolve the schema using relative location
+ String schemaLocation = "../schemas/configuration/folder with
spaces/bar.xsd";
+ URIResolver xsdResolver = new URIResolver();
+ xsdResolver.resolve(baseUri, schemaLocation, this.getClass());
+ assertNotNull(xsdResolver.getInputStream());
+
+ // resolve the schema using relative location with base uri fragment
+ xsdResolver = new URIResolver();
+ xsdResolver.resolve(baseUri + "#type2", schemaLocation,
this.getClass());
+ assertNotNull(xsdResolver.getInputStream());
+
+ }
+
}
Added: cxf/trunk/common/common/src/test/resources/schemas/configuration/folder
with spaces/bar.xsd
URL:
http://svn.apache.org/viewvc/cxf/trunk/common/common/src/test/resources/schemas/configuration/folder%20with%20spaces/bar.xsd?rev=934270&view=auto
==============================================================================
--- cxf/trunk/common/common/src/test/resources/schemas/configuration/folder
with spaces/bar.xsd (added)
+++ cxf/trunk/common/common/src/test/resources/schemas/configuration/folder
with spaces/bar.xsd Thu Apr 15 03:03:57 2010
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:RelPath" xmlns:RP="urn:RelPath"
+ elementFormDefault="qualified">
+ <xs:complexType name="RPTest1CT_In">
+ <xs:sequence>
+ <xs:element name="RPTest1_CT_String" type="xs:string">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="RPTest1CT_Out">
+ <xs:sequence>
+ <xs:element name="RPTest1_Ele_String" type="xs:string">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+</xs:schema>
\ No newline at end of file