cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r577185 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/tools/common/ tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/ tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/ tools/javato/ws/src/main/j...
Date Wed, 19 Sep 2007 07:42:43 GMT
Author: ema
Date: Wed Sep 19 00:42:41 2007
New Revision: 577185

URL: http://svn.apache.org/viewvc?rev=577185&view=rev
Log:
* [CXF-995] Applied patch from Glen to enhance error message, thanks Glen!
* Fixed issue in Simple client and server generator 
* Enhanced check parameters  

Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleClientGenerator.java
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleServerGenerator.java
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java?rev=577185&r1=577184&r2=577185&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java Wed
Sep 19 00:42:41 2007
@@ -219,6 +219,10 @@
     //For java2ws tool
     public static final String SERVICE_LIST = "serviceList";
     public static final String GEN_FROM_SEI = "genFromSEI";
+    public static final String JAXWS_FRONTEND = "jaxws";
+    public static final String SIMPLE_FRONTEND = "simple";
+    public static final String JAXB_DATABINDING = "jaxb";
+    public static final String AEGIS_DATABINDING = "aegis";
     //For Simple FrontEnd
     public static final String SEI_CLASS = "seiClass";
     public static final String IMPL_CLASS = "implClass";

Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java?rev=577185&r1=577184&r2=577185&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
Wed Sep 19 00:42:41 2007
@@ -60,21 +60,27 @@
                 if (isVerboseOn()) {
                     env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
                 }
+                String ft = (String)env.get(ToolConstants.CFG_FRONTEND);
+                if (ft == null || ToolConstants.JAXWS_FRONTEND.equals(ft)) {
+                    ft = ToolConstants.JAXWS_FRONTEND;
+                } else {
+                    ft = ToolConstants.SIMPLE_FRONTEND;
+                    //use aegis databinding for simple front end by default
+                    env.put(ToolConstants.CFG_DATABINDING, ToolConstants.AEGIS_DATABINDING);
+                }
+                env.put(ToolConstants.CFG_FRONTEND, ft); 
                 processor = new JavaToWSDLProcessor();
                 processor.setEnvironment(env);
                 processor.process();
-                String ft = (String)env.get(ToolConstants.CFG_FRONTEND);
-                if (ft == null || "jaxws".equals(ft.toLowerCase())) {
-                    ft = "jaxws";
-                    env.put(ToolConstants.CFG_FRONTEND, "jaxws");
+                
+                
+                if (ft.equals(ToolConstants.JAXWS_FRONTEND)) {
                     if (env.optionSet(ToolConstants.CFG_SERVER) || env.optionSet(ToolConstants.CFG_CLIENT))
{
                         processor = new JAXWSFrontEndProcessor();
                         processor.setEnvironment(env);
                         processor.process();
                     }
-                } else {
-                    ft = "simple";
-                    env.put(ToolConstants.CFG_FRONTEND, "simple");
+                } else {               
                     processor = new SimpleFrontEndProcessor();
                     processor.setEnvironment(env);
                     processor.process();
@@ -112,20 +118,31 @@
 
         if (doc.hasParameter(ToolConstants.CFG_FRONTEND)) {
             String ft = doc.getParameter(ToolConstants.CFG_FRONTEND);
-            if (!"simple".equalsIgnoreCase(ft) && !"jaxws".equalsIgnoreCase(ft))
{
+            if (!ToolConstants.JAXWS_FRONTEND.equals(ft) 
+                && !ToolConstants.SIMPLE_FRONTEND.equals(ft)) {
                 Message msg = new Message("INVALID_FRONTEND", LOG, new Object[] {ft});
                 errs.add(new ErrorVisitor.UserError(msg.toString()));
             }
+            
+            if (ToolConstants.SIMPLE_FRONTEND.equals(ft) 
+                && doc.getParameter(ToolConstants.CFG_DATABINDING) != null 
+                && !ToolConstants.
+                AEGIS_DATABINDING.equals(doc.getParameter(ToolConstants.CFG_DATABINDING)))
{
+                Message msg = new Message("INVALID_DATABINDING_FOR_SIMPLE", LOG);
+                errs.add(new ErrorVisitor.UserError(msg.toString()));
+            }
+            
         }
 
         if (doc.hasParameter(ToolConstants.CFG_WRAPPERBEAN)) {
             String ft = doc.getParameter(ToolConstants.CFG_FRONTEND);
-            if (ft != null && !"jaxws".equalsIgnoreCase(ft)) {
+            if (ft != null && !ToolConstants.JAXWS_FRONTEND.equals(ft)) {
                 Message msg = new Message("WRAPPERBEAN_WITHOUT_JAXWS", LOG);
                 errs.add(new ErrorVisitor.UserError(msg.toString()));
             }
         }
-
+        
+        
         if (errs.getErrors().size() > 0) {
             Message msg = new Message("PARAMETER_MISSING", LOG);
             throw new ToolException(msg, new BadUsageException(getUsage(), errs));

Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties?rev=577185&r1=577184&r2=577185&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties
Wed Sep 19 00:42:41 2007
@@ -22,8 +22,9 @@
 NOT_A_DIRECTORY = {0} is not a directory
 FILE_NOT_EXIST = File does not exist
 NOT_A_FILE = {0} is not a file
-PARAMETER_MISSING = Required parameter is missing or not valid
+PARAMETER_MISSING = Parameter is not valid or required parameter is missing
 INVALID_FRONTEND = "{0}" is not a valid frontend, java2ws only supports jaxws and the simple
frontend.
 WRAPPERBEAN_WITHOUT_JAXWS = -wrapperbean is only valid for the jaxws front end.
-INVALID_DATABINDING = Invalid value {0} for data binding type. 
+INVALID_DATABINDING = Invalid value {0} for data binding type.
+INVALID_DATABINDING_FOR_SIMPLE = Simple front end only supports aegis databinding.
 

Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml?rev=577185&r1=577184&r2=577185&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml
Wed Sep 19 00:42:41 2007
@@ -38,7 +38,8 @@
 		
 			<option id="databinding" maxOccurs="1">
 				<annotation>
-				    Specify the data binding (aegis or jaxb). Default jaxb.
+				    Specify the data binding (aegis or jaxb). Default is jaxb for jaxws 
+				    frontend, and aegis for simple frontend.
 				</annotation>
 				<switch>databinding</switch>
 				<associatedArgument placement="afterSpace">
@@ -47,24 +48,24 @@
 			</option>
 			<option id="frontend" maxOccurs="1">
 				<annotation>
-					Specify which frontend should be use, support jaxws and simple frontend.
+					Specify the frontend to use.  jaxws and the simple frontend are supported.
 				</annotation>
 				<switch>frontend</switch>
 				<associatedArgument placement="afterSpace">
-					<annotation>jaxws-or-simple</annotation>
+					<annotation>jaxws or simple</annotation>
 				</associatedArgument>
 			</option>
 
 			<option id="wsdl" maxOccurs="1">
 				<annotation>
-					Specify generating wsdl
+					Specify to generate the WSDL file
 				</annotation>
 				<switch>wsdl</switch>
 			</option>
 			
 			<option id="wrapperbean" maxOccurs="1">
 				<annotation>
-					Specify to genearte wrapper and fault bean
+					Specify to generate the wrapper and fault bean
 				</annotation>
 				<switch>wrapperbean</switch>
 			</option>

Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java?rev=577185&r1=577184&r2=577185&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessor.java
Wed Sep 19 00:42:41 2007
@@ -131,6 +131,7 @@
         if (context.containsKey(ToolConstants.CFG_WRAPPERBEAN)) {
             generators.add(getWrapperBeanGenerator());
             generators.add(getFaultBeanGenerator());
+            
         }
         generate(service, outputDir);
         List<ServiceInfo> serviceList = new ArrayList<ServiceInfo>();

Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleClientGenerator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleClientGenerator.java?rev=577185&r1=577184&r2=577185&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleClientGenerator.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleClientGenerator.java
Wed Sep 19 00:42:41 2007
@@ -55,7 +55,7 @@
         for (JavaInterface intf : interfaces.values()) {
             clearAttributes();
             setAttributes("intf", intf);
-            setAttributes("seiClass", ((Class)env.get(ToolConstants.SEI_CLASS)).getName());
+            setAttributes("seiClass", env.get(ToolConstants.SEI_CLASS));
             setCommonAttributes();
             doWrite(CLIENT_TEMPLATE, parseOutputName(intf.getPackageName(), intf.getName()
+ "Client"));
 

Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleServerGenerator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleServerGenerator.java?rev=577185&r1=577184&r2=577185&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleServerGenerator.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/simple/generator/SimpleServerGenerator.java
Wed Sep 19 00:42:41 2007
@@ -59,7 +59,7 @@
         for (JavaInterface intf : interfaces.values()) {
             clearAttributes();
             setAttributes("intf", intf);
-            setAttributes("implClass", ((Class)env.get(ToolConstants.IMPL_CLASS)).getName());
+            setAttributes("implClass", env.get(ToolConstants.IMPL_CLASS));
             setCommonAttributes();
             doWrite(SERVER_TEMPLATE, parseOutputName(intf.getPackageName(), intf.getName()
+ "Server"));
         }

Modified: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java?rev=577185&r1=577184&r2=577185&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
Wed Sep 19 00:42:41 2007
@@ -23,11 +23,10 @@
 import java.net.URL;
 import java.net.URLClassLoader;
 
-
-
 import org.apache.cxf.helpers.FileUtils;
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolTestBase;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -55,9 +54,7 @@
     }
     
     private File outputFile(String name) {
-        File f = new File(output.getPath() + File.separator + name);
-        f.delete();
-        return f;
+        return new File(output.getPath() + File.separator + name);
     }
 
     @Test
@@ -74,7 +71,7 @@
                                       "-client", "-server", "org.apache.hello_world_soap12_http.Greeter"};
         JavaToWS.main(args);
         checkStdErr();
-        assertTrue("wsdl is not generated", wsdlFile.exists());
+        assertTrue("Failed to generate WSDL file", wsdlFile.exists());
     }
 
     private void checkStdErr() {
@@ -92,10 +89,24 @@
                                       "org.apache.hello_world_doc_lit.Greeter"};
         JavaToWS.main(args);
         checkStdErr();
-        assertTrue("wsdl is not generated", wsdlFile.exists());
+        assertTrue("Failed to generate WSDL file", wsdlFile.exists());
     }
     
     @Test
+    public void testSimpleFrontend() throws Exception {
+        String[] args = new String[] {"-wsdl", "-o", output.getPath() + "/tmp.wsdl", "-verbose",
"-d",
+                                      output.getPath(), "-frontend", "simple", "-client",
"-server",
+                                      "org.apache.cxf.tools.fortest.simple.Hello"};
+        JavaToWS.main(args);
+        File client = outputFile("org/apache/cxf/tools/fortest/simple/HelloPortTypeClient.java");
+        File server = outputFile("org/apache/cxf/tools/fortest/simple/HelloPortTypeServer.java");
+        File impl = outputFile("org/apache/cxf/tools/fortest/simple/HelloPortTypeImpl.java");
+        assertTrue("Failed to generate client file for simple front end ", client.exists());
+        assertTrue("Failed to generate server file for simple front end ", server.exists());
+        assertTrue("Failed to generate impl file for simple front end ", impl.exists());
+    }
+        
+    @Test
     public void testMissingBeans() {
         String[] args = new String[] {"-wsdl", "-o", output.getPath() + "/tmp.wsdl", "-verbose",
"-d",
                                       output.getPath(), "-frontend", "jaxws", "-client",
"-server",
@@ -115,7 +126,7 @@
                                       output.getPath(), "-frontend", "jaxws", "-client",
"-server",
                                       "org.apache.cxf.tools.fortest.HelloWithNoAnno"};
         JavaToWS.main(args);
-        assertTrue("wsdl is not generated", wsdlFile.exists());
+        assertTrue("Failed to generate WSDL file", wsdlFile.exists());
         assertTrue("Class does not carry WebService error should be detected", getStdErr()
             .indexOf("does not carry a WebService annotation") > -1);
     }
@@ -127,7 +138,7 @@
                                       output.getPath(), "-frontend", "jaxws", "-client",
"-server",
                                       "org.apache.cxf.tools.fortest.HelloRMI"};
         JavaToWS.main(args);
-        assertTrue("wsdl is not generated", wsdlFile.exists());
+        assertTrue("Failed to generate WSDL file", wsdlFile.exists());
         assertTrue("Parameter or return type implemented java.rmi.Remote interface error
should be detected",
                    getStdErr().indexOf("implemented the java.rmi.Remote interface") >
-1);
     }
@@ -142,8 +153,8 @@
                                       "org.apache.hello_world_soap12_http.Greeter"};
         JavaToWS.main(args);
         checkStdErr();
-        assertTrue("Client is not generated", client.exists());
-        assertTrue("Greeter_GreeterPort_Server.java is not generated", server.exists());
+        assertTrue("Client was not generated", client.exists());
+        assertTrue("Greeter_GreeterPort_Server.java was not generated", server.exists());
     }
 
     @Test
@@ -155,8 +166,8 @@
                                       "org.apache.hello_world_soap12_http.Greeter"};
         JavaToWS.main(args);
         checkStdErr();
-        assertTrue("GreeterServer.java is not generated", server.exists());
-        assertTrue("GreeterImpl.java is not generated", impl.exists());
+        assertTrue("GreeterServer.java was not generated", server.exists());
+        assertTrue("GreeterImpl.java was not generated", impl.exists());
     }
 
     @Test
@@ -185,6 +196,18 @@
         assertTrue("wrapperbean flag error should be detected", getStdErr()
             .indexOf("-wrapperbean is only valid for the jaxws front end.") > -1);
     }
+    
+    @Test
+    public void testInvalidFlag3() throws Exception {
+        String[] args = new String[] {"-databinding", "jaxb", "-frontend", "simple",
+                                      "-wsdl", "-o",
+                                      output.getPath() + "/tmp.wsdl",
+                                      "org.apache.hello_world_soap12_http.Greeter"};
+        JavaToWS.main(args);
+        assertTrue("jaxb databinding warning should be detected", getStdErr()
+                   .indexOf("simple front end only supports aegis databinding") > -1);
+    }
+    
 
     protected String getClassPath() throws URISyntaxException {
         ClassLoader loader = getClass().getClassLoader();



Mime
View raw message