cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1335468 - in /cxf/branches/2.5.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/ tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/ tools/wadlto/jaxrs/src/test/resources/wadl/
Date Tue, 08 May 2012 12:33:18 GMT
Author: sergeyb
Date: Tue May  8 12:33:17 2012
New Revision: 1335468

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

........
  r1335462 | sergeyb | 2012-05-08 13:25:44 +0100 (Tue, 08 May 2012) | 1 line
  
  [CXF-4292] Defaulting to String when WADL Generator can not determine a class name of the
primitive type
........

Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
    cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
    cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/WADLToJavaTest.java
    cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1335462

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

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java?rev=1335468&r1=1335467&r2=1335468&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
Tue May  8 12:33:17 2012
@@ -1004,8 +1004,8 @@ public class SourceGenerator {
             return XSD_SPECIFIC_TYPE_MAP.get(value);
         } else {
             String actualValue = value.replaceAll("[\\-\\_]", "");
-            if (!actualValue.equals(value) && pair.length > 1) {
-                actualValue = convertRefToClassName(pair[0], actualValue, actualValue, info,
imports);
+            if (pair.length > 1) {
+                actualValue = convertRefToClassName(pair[0], actualValue, "String", info,
imports);
             }
             return actualValue;
         }
@@ -1027,16 +1027,13 @@ public class SourceGenerator {
                     addImport(imports, clsName);
                     int index = clsName.lastIndexOf(".");
                     if (index != -1) {
-                        actualValue = clsName.substring(index + 1);
-                    } else {
-                        actualValue = clsName;
-                    }       
+                        clsName = clsName.substring(index + 1);
+                    } 
+                    return clsName;      
                 }
-            } else {
-                actualValue = defaultValue;
             }
         }
-        return actualValue;
+        return defaultValue;
     }
     
     private String getElementRefName(Element repElement,

Modified: cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java?rev=1335468&r1=1335467&r2=1335468&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
(original)
+++ cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
Tue May  8 12:33:17 2012
@@ -47,8 +47,8 @@ public class JAXRSContainerTest extends 
 
             assertNotNull(output.list());
             
-            verifyFiles("java", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
10);
-            verifyFiles("class", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
10);
+            verifyFiles("java", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
10, true);
+            verifyFiles("class", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
10, true);
             
         } catch (Exception e) {
             e.printStackTrace();
@@ -72,8 +72,8 @@ public class JAXRSContainerTest extends 
 
             assertNotNull(output.list());
             
-            verifyFiles("java", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
10);
-            verifyFiles("class", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
10);
+            verifyFiles("java", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
10, true);
+            verifyFiles("class", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
10, true);
             
         } catch (Exception e) {
             e.printStackTrace();
@@ -97,8 +97,8 @@ public class JAXRSContainerTest extends 
 
             assertNotNull(output.list());
             
-            verifyFiles("java", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
10);
-            verifyFiles("class", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
10);
+            verifyFiles("java", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
10, true);
+            verifyFiles("class", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
10, true);
             
         } catch (Exception e) {
             e.printStackTrace();
@@ -376,8 +376,8 @@ public class JAXRSContainerTest extends 
 
             assertNotNull(output.list());
             
-            verifyFiles("java", true, false, "superbooks", "custom.books", 10);
-            verifyFiles("class", true, false, "superbooks", "custom.books", 10);
+            verifyFiles("java", true, false, "superbooks", "custom.books", 10, true);
+            verifyFiles("class", true, false, "superbooks", "custom.books", 10, true);
             
         } catch (Exception e) {
             e.printStackTrace();
@@ -402,8 +402,8 @@ public class JAXRSContainerTest extends 
 
             assertNotNull(output.list());
             
-            verifyFiles("java", true, false, "custom.books.schema", "custom.books.service",
10);
-            verifyFiles("class", true, false, "custom.books.schema", "custom.books.service",
10);
+            verifyFiles("java", true, false, "custom.books.schema", "custom.books.service",
10, true);
+            verifyFiles("class", true, false, "custom.books.schema", "custom.books.service",
10, true);
             
         } catch (Exception e) {
             e.printStackTrace();
@@ -427,8 +427,8 @@ public class JAXRSContainerTest extends 
 
             assertNotNull(output.list());
             
-            verifyFiles("java", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
10);
-            verifyFiles("class", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
10);
+            verifyFiles("java", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
10, true);
+            verifyFiles("class", true, false, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
10, true);
         } catch (Exception e) {
             fail();
             e.printStackTrace();
@@ -452,8 +452,8 @@ public class JAXRSContainerTest extends 
 
             assertNotNull(output.list());
             
-            verifyFiles("java", true, true, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
11);
-            verifyFiles("class", true, true, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
11);
+            verifyFiles("java", true, true, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
12, true);
+            verifyFiles("class", true, true, "superbooks", "org.apache.cxf.jaxrs.model.wadl",
12, true);
         } catch (Exception e) {
             fail();
             e.printStackTrace();
@@ -475,7 +475,7 @@ public class JAXRSContainerTest extends 
 
             assertNotNull(output.list());
             
-            verifyTypes("superbooks", "java");
+            verifyTypes("superbooks", "java", true);
             
         } catch (Exception e) {
             fail();
@@ -484,9 +484,17 @@ public class JAXRSContainerTest extends 
     }
     
     private void verifyFiles(String ext, boolean subresourceExpected, boolean interfacesAndImpl,

-                             String schemaPackage, String resourcePackage, int expectedCount)
{    
+                             String schemaPackage, String resourcePackage, int expectedCount)
{
+        verifyFiles(ext, subresourceExpected, interfacesAndImpl, schemaPackage, resourcePackage,
+                    expectedCount, false);
+    }
+    
+    private void verifyFiles(String ext, boolean subresourceExpected, boolean interfacesAndImpl,

+                             String schemaPackage, String resourcePackage, int expectedCount,
+                             boolean enumTypeExpected) {    
         List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + ext + "$");
-        int size = interfacesAndImpl ? expectedCount : expectedCount - 2;
+        int offset = enumTypeExpected ? 1 : 2;
+        int size = interfacesAndImpl ? expectedCount : expectedCount - offset;
         if (!subresourceExpected) {
             size--;
         }
@@ -506,9 +514,9 @@ public class JAXRSContainerTest extends 
         }
     }
     
-    private void verifyTypes(String schemaPackage, String ext) {
+    private void verifyTypes(String schemaPackage, String ext, boolean enumTypeExpected)
{
         List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + ext + "$");
-        assertEquals(5, files.size());
+        assertEquals(enumTypeExpected ? 6 : 5, files.size());
         doVerifyTypes(files, schemaPackage, ext);
     }
     

Modified: cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/WADLToJavaTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/WADLToJavaTest.java?rev=1335468&r1=1335467&r2=1335468&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/WADLToJavaTest.java
(original)
+++ cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/WADLToJavaTest.java
Tue May  8 12:33:17 2012
@@ -59,7 +59,7 @@ public class WADLToJavaTest extends Proc
     private void verifyFiles(String ext, boolean subresourceExpected, boolean interfacesAndImpl,

                              String schemaPackage, String resourcePackage) {    
         List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + ext + "$");
-        int size = interfacesAndImpl ? 10 : 8;
+        int size = interfacesAndImpl ? 11 : 9;
         if (!subresourceExpected) {
             size--;
         }
@@ -78,6 +78,7 @@ public class WADLToJavaTest extends Proc
     }
     
     private void doVerifyTypes(List<File> files, String schemaPackage, String ext)
{
+        assertTrue(checkContains(files, schemaPackage + ".EnumType." + ext));
         assertTrue(checkContains(files, schemaPackage + ".Book." + ext));
         assertTrue(checkContains(files, schemaPackage + ".TheBook2." + ext));
         assertTrue(checkContains(files, schemaPackage + ".Chapter." + ext));

Modified: cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml?rev=1335468&r1=1335467&r2=1335468&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml (original)
+++ cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml Tue
May  8 12:33:17 2012
@@ -43,15 +43,32 @@
             <xs:element minOccurs="0" name="name" type="xs:string"/>
         </xs:sequence>
     </xs:complexType>
+    
+    <xs:simpleType name="patternType">
+        <xs:restriction base="xs:string">
+            <xs:pattern value="([A-z0-9_@$\-]+)|(([A-z][A-z0-9_\-]*(\.[A-z][A-z0-9_\-]*)*)(\,[A-z0-9_@$\-]+)(\,(latest|([0-9]+(\.[0-9]+)*)))?)"/>
+        </xs:restriction>
+    </xs:simpleType>
+    
+    <xs:simpleType name="enumType">
+		<xs:restriction base="xs:string">
+			<xs:enumeration value="text-only"/>
+			<xs:enumeration value="rich-xml"/>
+			<xs:enumeration value="original"/>
+		</xs:restriction>
+	</xs:simpleType>
+    
   </xs:schema>
  </grammars>
  <resources base="http://localhost:8080/baz">
    <resource path="/bookstore/{id}" id="org.apache.cxf.jaxrs.model.wadl.BookStore">
      <doc xml:lang="en-us" title="book store resource">super resource</doc>
      <param name="id" style="template" type="xs:long"/>
+     <param name="patternId" style="template" type="prefix1:patternType"/>
 
      <method name="GET" id="getName">
       <request>
+        <param name="enumType" style="query" type="prefix1:enumType"/>
         <param name="a" style="query" type="xs:int"/>
         <param name="c.a" style="query" type="xs:int"/>
         <param name="c.b" style="query" type="xs:int"/>



Mime
View raw message