cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1337359 - 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 Fri, 11 May 2012 20:17:41 GMT
Author: sergeyb
Date: Fri May 11 20:17:41 2012
New Revision: 1337359

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

........
  r1337204 | sergeyb | 2012-05-11 16:18:52 +0100 (Fri, 11 May 2012) | 1 line
  
  [CXF-4311] Attempting to generate the unique method names when no method ids are available
........

Added:
    cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/resourceSameTargetNsSchemas.xml
      - copied unchanged from r1337204, cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/resourceSameTargetNsSchemas.xml
    cxf/branches/2.5.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/resourcesNoId.xml
      - copied unchanged from r1337204, cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/resourcesNoId.xml
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

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

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=1337359&r1=1337358&r2=1337359&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
Fri May 11 20:17:41 2012
@@ -488,8 +488,12 @@ public class SourceGenerator {
     
     private String firstCharToUpperCase(String name) {
         StringBuilder sb = new StringBuilder();
-        sb.append(Character.toUpperCase(name.charAt(0)));
-        return name.length() > 1 ? sb.append(name.substring(1)).toString() : sb.toString();
+        if (name.length() > 0) {
+            sb.append(Character.toUpperCase(name.charAt(0)));
+            return name.length() > 1 ? sb.append(name.substring(1)).toString() : sb.toString();
+        } else {
+            return sb.toString();
+        }
     }
     
     private boolean writeAnnotations(boolean interfaceIsGenerated) {
@@ -638,7 +642,11 @@ public class SourceGenerator {
             boolean responseTypeAvailable = true;
             if (methodNameLowerCase.length() > 0) {
                 responseTypeAvailable = writeResponseType(responseEls, sbCode, imports, info);
-                sbCode.append(id + suffixName);
+                String genMethodName = id + suffixName;
+                if (methodNameLowerCase.equals(genMethodName)) {
+                    genMethodName += firstCharToUpperCase(currentPath.replaceAll("/", ""));
+                }
+                sbCode.append(genMethodName); 
             } else {
                 boolean expandedQName = id.startsWith("{");
                 QName qname = convertToQName(id, expandedQName);

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=1337359&r1=1337358&r2=1337359&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
Fri May 11 20:17:41 2012
@@ -332,6 +332,66 @@ public class JAXRSContainerTest extends 
     }
     
     @Test    
+    public void testCodeGenNoIds3() {
+        try {
+            JAXRSContainer container = new JAXRSContainer(null);
+
+            ToolContext context = new ToolContext();
+            context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
+            context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/resourcesNoId.xml"));
+            context.put(WadlToolConstants.CFG_COMPILE, "true");
+            
+            container.setContext(context);
+            container.execute();
+
+            assertNotNull(output.list());
+            
+            List<File> javaFiles = FileUtils.getFilesRecurse(output, ".+\\." + "java"
+ "$");
+            assertEquals(1, javaFiles.size());
+            assertTrue(checkContains(javaFiles, "application.TestRsResource.java"));
+            List<File> classFiles = FileUtils.getFilesRecurse(output, ".+\\." + "class"
+ "$");
+            assertEquals(1, classFiles.size());
+            assertTrue(checkContains(classFiles, "application.TestRsResource.class"));
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail();
+        }
+    }
+    
+    @Test    
+    public void testCodeTwoSchemasSameTargetNs() {
+        try {
+            JAXRSContainer container = new JAXRSContainer(null);
+
+            ToolContext context = new ToolContext();
+            context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
+            context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/resourceSameTargetNsSchemas.xml"));
+            context.put(WadlToolConstants.CFG_COMPILE, "true");
+            
+            container.setContext(context);
+            container.execute();
+
+            List<File> javaFiles = FileUtils.getFilesRecurse(output, ".+\\." + "java"
+ "$");
+            assertEquals(4, javaFiles.size());
+            assertTrue(checkContains(javaFiles, "application.Resource.java"));
+            assertTrue(checkContains(javaFiles, "com.example.test.ObjectFactory.java"));
+            assertTrue(checkContains(javaFiles, "com.example.test.package-info.java"));
+            assertTrue(checkContains(javaFiles, "com.example.test.TestCompositeObject.java"));
+            List<File> classFiles = FileUtils.getFilesRecurse(output, ".+\\." + "class"
+ "$");
+            assertEquals(4, classFiles.size());
+            assertTrue(checkContains(classFiles, "application.Resource.class"));
+            assertTrue(checkContains(classFiles, "com.example.test.ObjectFactory.class"));
+            assertTrue(checkContains(classFiles, "com.example.test.package-info.class"));
+            assertTrue(checkContains(classFiles, "com.example.test.TestCompositeObject.class"));
+
+            
+            assertNotNull(output.list());
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail();
+        }
+    }
+    @Test    
     public void testCodeGenWithResourceSet() {
         try {
             JAXRSContainer container = new JAXRSContainer(null);



Mime
View raw message