cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1133424 - in /cxf/trunk: maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/ tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/ja...
Date Wed, 08 Jun 2011 15:24:16 GMT
Author: dkulp
Date: Wed Jun  8 15:24:16 2011
New Revision: 1133424

URL: http://svn.apache.org/viewvc?rev=1133424&view=rev
Log:
[CXF-3566] Allow specifying the SUID for faults

Modified:
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
    cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/wsdlto.xml
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm
    cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java?rev=1133424&r1=1133423&r2=1133424&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
(original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
Wed Jun  8 15:24:16 2011
@@ -23,8 +23,6 @@ import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.cxf.tools.wsdlto.frontend.jaxws.generators.FaultSerialVersionUID;
-
 
 public class Option {
     static final String DEFAULT_BINDING_FILE_PATH = "src" + File.separator + "main"
@@ -146,7 +144,7 @@ public class Option {
     /**
      * specify how to generate fault Exception's SUID, default is NONE
      */
-    FaultSerialVersionUID faultSerialVersionUID;
+    String faultSerialVersionUID;
 
     /**
      * Uses @Generated annotation in all generated java classes if the flag is set to true.
@@ -331,11 +329,11 @@ public class Option {
         this.noTypes = noTypes;
     }
 
-    public FaultSerialVersionUID getFaultSerialVersionUID() {
-        return faultSerialVersionUID == null ? FaultSerialVersionUID.NONE : faultSerialVersionUID;
+    public String getFaultSerialVersionUID() {
+        return faultSerialVersionUID == null ? "none" : faultSerialVersionUID;
     }
 
-    public void setFaultSerialVersionUID(FaultSerialVersionUID faultSerialVersionUID) {
+    public void setFaultSerialVersionUID(String faultSerialVersionUID) {
         this.faultSerialVersionUID = faultSerialVersionUID;
     }
 

Modified: cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/wsdlto.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/wsdlto.xml?rev=1133424&r1=1133423&r2=1133424&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/wsdlto.xml (original)
+++ cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/wsdlto.xml Wed Jun
 8 15:24:16 2011
@@ -198,7 +198,9 @@ under the License.
 
             <option id="faultSerialVersionUID" maxOccurs="1">
                 <annotation>
-                    specify how to generate fault Exception's SUID, can use NONE|TIMESTAMP|FQCN,
the default is NONE
+                    Specifies how to generate fault Exception's SUID, can use NONE|TIMESTAMP|FQCN|####",
the default is NONE.
+                    FQCN uses a hash of the fully qualified class name.   #### would be any
valid Long to
+                    use as the SUID. 
                 </annotation>
                 <switch>faultSerialVersionUID</switch>
                 <associatedArgument placement="afterSpace">

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java?rev=1133424&r1=1133423&r2=1133424&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java
Wed Jun  8 15:24:16 2011
@@ -82,16 +82,27 @@ public class FaultGenerator extends Abst
                 clearAttributes();
                 
                 if (penv.containsKey(ToolConstants.CFG_FAULT_SERIAL_VERSION_UID)) {
-                    Object faultSerialVersionUID 
-                        = penv.get(ToolConstants.CFG_FAULT_SERIAL_VERSION_UID);
+                    String faultSerialVersionUID 
+                        = penv.get(ToolConstants.CFG_FAULT_SERIAL_VERSION_UID).toString();
                     setAttributes("faultSerialVersionUID", faultSerialVersionUID);
-                    if (faultSerialVersionUID.equals(FaultSerialVersionUID.FQCN) 
-                        || "FQCN".equals(faultSerialVersionUID)) {
+                    if ("FQCN".equalsIgnoreCase(faultSerialVersionUID)) {
                         setAttributes("suid", generateHashSUID(expClz.getFullClassName()));
-                    } else if (faultSerialVersionUID.equals(FaultSerialVersionUID.TIMESTAMP)
-                        || "TIMESTAMP".equals(faultSerialVersionUID)) {
+                    } else if ("TIMESTAMP".equalsIgnoreCase(faultSerialVersionUID)) {
                         setAttributes("suid", generateTimestampSUID());
+                    } else if ("NONE".equalsIgnoreCase(faultSerialVersionUID)) {
+                        //nothing
+                        setAttributes("suid", "");
+                    } else {
+                        //do a quick Parse to make sure it looks like a Long
+                        try {
+                            Long.parseLong(faultSerialVersionUID);
+                        } catch (NumberFormatException nfe) {
+                            throw new ToolException(nfe);
+                        }
+                        setAttributes("suid", faultSerialVersionUID);
                     }
+                } else {
+                    setAttributes("suid", "");
                 }
                 setAttributes("expClass", expClz);
                 String exceptionSuperclass = "Exception";

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml?rev=1133424&r1=1133423&r2=1133424&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
Wed Jun  8 15:24:16 2011
@@ -313,7 +313,9 @@ Examples:
 
             <option id="faultSerialVersionUID" maxOccurs="1">
                 <annotation>
-                    specify how to generate fault Exception's SUID, can use NONE|TIMESTAMP|FQCN,
the default is NONE
+                    Specifies how to generate fault Exception's SUID, can use NONE|TIMESTAMP|FQCN|####",
the default is NONE.
+                    FQCN uses a hash of the fully qualified class name.   #### would be any
valid Long to
+                    use as the SUID. 
                 </annotation>
                 <switch>faultSerialVersionUID</switch>
                 <associatedArgument placement="afterSpace">

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm?rev=1133424&r1=1133423&r2=1133424&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/fault.vm
Wed Jun  8 15:24:16 2011
@@ -43,7 +43,7 @@ public class $expClass.Name extends $exc
 #if ($mark-generated == "true")
     @Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "$currentdate")
 #end
-#if ($faultSerialVersionUID == "TIMESTAMP" || $faultSerialVersionUID == "FQCN")
+#if (${suid} != "")
     public static final long serialVersionUID = ${suid}L;
 #end
 #foreach ($field in $expClass.Fields)

Modified: cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java?rev=1133424&r1=1133423&r2=1133424&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
(original)
+++ cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
Wed Jun  8 15:24:16 2011
@@ -47,7 +47,6 @@ import org.apache.cxf.tools.common.ToolC
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.util.AnnotationUtil;
 import org.apache.cxf.tools.wsdlto.AbstractCodeGenTest;
-import org.apache.cxf.tools.wsdlto.frontend.jaxws.generators.FaultSerialVersionUID;
 
 import org.junit.Test;
 
@@ -1340,7 +1339,7 @@ public class CodeGenTest extends Abstrac
     @Test
     public void testCXFNotType() throws Exception {
         env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
-        env.put(ToolConstants.CFG_FAULT_SERIAL_VERSION_UID, FaultSerialVersionUID.FQCN);
+        env.put(ToolConstants.CFG_FAULT_SERIAL_VERSION_UID, "FQCN");
         processor.setContext(env);
         processor.execute();
         
@@ -1355,7 +1354,7 @@ public class CodeGenTest extends Abstrac
     @Test
     public void testFaultSerialVersionUIDNONEFQCN() throws Exception {
         env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
-        env.put(ToolConstants.CFG_FAULT_SERIAL_VERSION_UID, FaultSerialVersionUID.FQCN);
+        env.put(ToolConstants.CFG_FAULT_SERIAL_VERSION_UID, "FQCN");
         processor.setContext(env);
         processor.execute();
 
@@ -1404,7 +1403,7 @@ public class CodeGenTest extends Abstrac
     @Test
     public void testFaultSerialVersionUIDNONE() throws Exception {
         env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
-        env.put(ToolConstants.CFG_FAULT_SERIAL_VERSION_UID, FaultSerialVersionUID.NONE);
+        env.put(ToolConstants.CFG_FAULT_SERIAL_VERSION_UID, "NONE");
         processor.setContext(env);
         processor.execute();
 
@@ -1433,7 +1432,7 @@ public class CodeGenTest extends Abstrac
     @Test
     public void testFaultSerialVersionUIDNONETIMESTAMP() throws Exception {
         env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
-        env.put(ToolConstants.CFG_FAULT_SERIAL_VERSION_UID, FaultSerialVersionUID.TIMESTAMP);
+        env.put(ToolConstants.CFG_FAULT_SERIAL_VERSION_UID, "TIMESTAMP");
         processor.setContext(env);
         processor.execute();
 
@@ -1450,7 +1449,29 @@ public class CodeGenTest extends Abstrac
         serialVersionUID = fault.getDeclaredField("serialVersionUID");
         assertNotNull(serialVersionUID);
     }
-    
+    @Test
+    public void testFaultSerialVersionUIDNumber() throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
+        env.put(ToolConstants.CFG_FAULT_SERIAL_VERSION_UID, "123456789");
+        processor.setContext(env);
+        processor.execute();
+
+        File faultFile = new File(output, "org/apache/cxf/w2j/hello_world_soap_http/NoSuchCodeLitFault.java");
+        assertTrue(faultFile.exists());
+        faultFile = new File(output, "org/apache/cxf/w2j/hello_world_soap_http/BadRecordLitFault.java");
+        assertTrue(faultFile.exists());
+
+        Class<?> fault = classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.NoSuchCodeLitFault");
+        Field serialVersionUID = fault.getDeclaredField("serialVersionUID");
+        assertNotNull(serialVersionUID);
+        Long l = (Long)serialVersionUID.get(null);
+        assertEquals(123456789L, l.longValue());
+        
+        fault = classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.BadRecordLitFault");
+        serialVersionUID = fault.getDeclaredField("serialVersionUID");
+        assertNotNull(serialVersionUID);
+        assertEquals(123456789L, l.longValue());
+    }
     @Test
     public void testExtensionWrapper() throws Exception {
         env.put(ToolConstants.CFG_WSDLURL,
@@ -1479,7 +1500,6 @@ public class CodeGenTest extends Abstrac
         List<String> results1 = FileUtils.readLines(new File(output.getCanonicalPath(),
             "org/apache/cxf/w2j/hello_world_soap_http/Greeter.java"));
 
-        System.out.println(results1);
         assertTrue(results1.contains(" * porttype documentation"));
         assertTrue(results1.contains("     * porttype op documentation"));
 



Mime
View raw message