You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2013/04/04 15:38:52 UTC

svn commit: r1464532 - in /cxf/trunk/tools/wadlto/jaxrs/src: main/java/org/apache/cxf/tools/wadlto/jaxrs/ test/java/org/apache/cxf/tools/wadlto/jaxrs/ test/resources/wadl/sub/

Author: sergeyb
Date: Thu Apr  4 13:38:52 2013
New Revision: 1464532

URL: http://svn.apache.org/r1464532
Log:
[CXF-4946] Better resolving of relative references with parent folders

Added:
    cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/sub/
    cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/sub/bookstoreImport.xml   (with props)
Modified:
    cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
    cxf/trunk/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java

Modified: cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java?rev=1464532&r1=1464531&r2=1464532&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java (original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java Thu Apr  4 13:38:52 2013
@@ -1364,7 +1364,7 @@ public class SourceGenerator {
             if (schemaURI == null) {
                 if (!URI.create(href).isAbsolute() && app.getWadlPath() != null) {
                     String baseWadlPath = getBaseWadlPath(app.getWadlPath());
-                    if  (!href.startsWith("/")) {
+                    if  (!href.startsWith("/") && !href.contains("..")) {
                         schemaURI = baseWadlPath + href;
                     } else {
                         schemaURI = URI.create(baseWadlPath).resolve(href).toString();

Modified: cxf/trunk/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java?rev=1464532&r1=1464531&r2=1464532&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java (original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java Thu Apr  4 13:38:52 2013
@@ -135,6 +135,30 @@ public class JAXRSContainerTest extends 
         }
     }
     
+    @Test
+    public void testCodeGenWithImportedSchemaWithParentRefs() {
+        try {
+            JAXRSContainer container = new JAXRSContainer(null);
+
+            ToolContext context = new ToolContext();
+            context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
+            context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/sub/bookstoreImport.xml"));
+            context.put(WadlToolConstants.CFG_COMPILE, "true");
+
+            container.setContext(context);
+            container.execute();
+
+            assertNotNull(output.list());
+            
+            verifyFiles("java", false, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl", 9);
+            verifyFiles("class", false, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl", 9);
+            
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail();
+        }
+    }
+    
     @Test    
     public void testCodeGenWithMultipleInlinedSchemas() {
         doTestInlinedSchemasWithImport("/wadl/bookstoreMultipleSchemas.xml");

Added: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/sub/bookstoreImport.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/sub/bookstoreImport.xml?rev=1464532&view=auto
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/sub/bookstoreImport.xml (added)
+++ cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/sub/bookstoreImport.xml Thu Apr  4 13:38:52 2013
@@ -0,0 +1,47 @@
+<?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.
+-->
+<application xmlns="http://wadl.dev.java.net/2009/02" xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+   xmlns:ns1="http://superbooks">
+
+ <grammars>
+    <include href="../schemas/book.xsd"/>
+ </grammars>
+ <resources base="http://localhost:8080/baz">
+   <resource path="/bookstore" id="{wadl.model.jaxrs.cxf.apache.org}BookStore">
+    
+    <resource path="/books/{bookid}">
+     <param name="bookid" style="template" type="xs:int"/>
+     
+     <method name="POST" id="addBook">
+      <request>
+       <representation mediaType="application/xml" element="ns1:thebook"/>
+      </request>
+     </method>
+     
+     <method name="POST" id="addChapter">
+      <request>
+       <representation mediaType="application/xml" element="ns1:thechapter"/>
+      </request>
+     </method>
+    </resource>
+   </resource>
+</resources>
+
+</application>

Propchange: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/sub/bookstoreImport.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/sub/bookstoreImport.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/sub/bookstoreImport.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml