cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r925999 - in /cxf/branches/2.2.x-fixes: ./ common/common/src/main/java/org/apache/cxf/resource/ common/common/src/test/java/org/apache/cxf/resource/ common/common/src/test/resources/schemas/configuration/ common/common/src/test/resources/wsdl/
Date Mon, 22 Mar 2010 08:40:19 GMT
Author: ningjiang
Date: Mon Mar 22 08:40:18 2010
New Revision: 925999

URL: http://svn.apache.org/viewvc?rev=925999&view=rev
Log:
Merged revisions 925995 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r925995 | ningjiang | 2010-03-22 16:28:44 +0800 (Mon, 22 Mar 2010) | 1 line
  
  CXF-2724 applied patch with thanks to William
........

Added:
    cxf/branches/2.2.x-fixes/common/common/src/test/resources/schemas/configuration/bar.xsd
      - copied unchanged from r925995, cxf/trunk/common/common/src/test/resources/schemas/configuration/bar.xsd
    cxf/branches/2.2.x-fixes/common/common/src/test/resources/wsdl/
      - copied from r925995, cxf/trunk/common/common/src/test/resources/wsdl/
    cxf/branches/2.2.x-fixes/common/common/src/test/resources/wsdl/foo.wsdl
      - copied unchanged from r925995, cxf/trunk/common/common/src/test/resources/wsdl/foo.wsdl
Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
    cxf/branches/2.2.x-fixes/common/common/src/test/java/org/apache/cxf/resource/URIResolverTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar 22 08:40:18 2010
@@ -1 +1 @@
-/cxf/trunk:925337,925378
+/cxf/trunk:925337,925378,925995

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java?rev=925999&r1=925998&r2=925999&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
(original)
+++ cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
Mon Mar 22 08:40:18 2010
@@ -167,9 +167,9 @@ public class URIResolver {
             } else if (!StringUtils.isEmpty(baseUriStr)) {
                 URI base;
                 File baseFile = new File(baseUriStr);
-
-                if (!baseFile.exists() && baseUriStr.startsWith("file:/")) {
-                    baseFile = new File(baseUriStr.substring(6));
+          
+                if (!baseFile.exists() && baseUriStr.startsWith("file:")) {
+                    baseFile = new File(getFilePathFromUri(baseUriStr));
                 }
 
                 if (baseFile.exists()) {
@@ -232,6 +232,30 @@ public class URIResolver {
         }
     }
     
+    /**
+     * Assumption: URI scheme is "file"
+     */
+    private String getFilePathFromUri(String uriString) {     
+        String path = null;
+        
+        try {
+            path = new URL(uriString).getPath();
+        } catch (MalformedURLException e) {
+            // ignore
+        }
+        
+        if (path == null) {
+            if (uriString.startsWith("file:/")) {
+                path = uriString.substring(6);
+            } else if (uriString.startsWith("file:")) {
+                // handle Windows file URI such as "file:C:/foo/bar"
+                path = uriString.substring(5);
+            } 
+        }
+        
+        return path;
+    }
+
     private void tryArchive(String baseStr, String uriStr) throws IOException {
         int i = baseStr.indexOf('!');
         if (i == -1) {

Modified: cxf/branches/2.2.x-fixes/common/common/src/test/java/org/apache/cxf/resource/URIResolverTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/common/common/src/test/java/org/apache/cxf/resource/URIResolverTest.java?rev=925999&r1=925998&r2=925999&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/common/common/src/test/java/org/apache/cxf/resource/URIResolverTest.java
(original)
+++ cxf/branches/2.2.x-fixes/common/common/src/test/java/org/apache/cxf/resource/URIResolverTest.java
Mon Mar 22 08:40:18 2010
@@ -85,5 +85,30 @@ public class URIResolverTest extends Ass
         InputStream is3 = uriResolver.getInputStream();
         assertNotNull(is3); 
     }
+    
+    
+    @Test
+    public void testResolveRelativeFile() 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/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());
+        
+    }
 
 }



Mime
View raw message