cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r564510 - in /incubator/cxf/trunk/tools/javato: core/src/main/java/org/apache/cxf/tools/java2wsdl/ ws/src/main/java/org/apache/cxf/tools/java2ws/ ws/src/test/java/org/apache/cxf/tools/java2ws/
Date Fri, 10 Aug 2007 08:39:35 GMT
Author: ema
Date: Fri Aug 10 01:39:34 2007
New Revision: 564510

URL: http://svn.apache.org/viewvc?view=rev&rev=564510
Log:
Added check parameters and test for java2ws tool 
Corrected error message in JavaToWSDLContainer

Modified:
    incubator/cxf/trunk/tools/javato/core/src/main/java/org/apache/cxf/tools/java2wsdl/JavaToWSDLContainer.java
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.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/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java

Modified: incubator/cxf/trunk/tools/javato/core/src/main/java/org/apache/cxf/tools/java2wsdl/JavaToWSDLContainer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/core/src/main/java/org/apache/cxf/tools/java2wsdl/JavaToWSDLContainer.java?view=diff&rev=564510&r1=564509&r2=564510
==============================================================================
--- incubator/cxf/trunk/tools/javato/core/src/main/java/org/apache/cxf/tools/java2wsdl/JavaToWSDLContainer.java
(original)
+++ incubator/cxf/trunk/tools/javato/core/src/main/java/org/apache/cxf/tools/java2wsdl/JavaToWSDLContainer.java
Fri Aug 10 01:39:34 2007
@@ -66,7 +66,7 @@
             }
             throw ex;
         } catch (Exception ex) {
-            System.err.println("Error : " + ex.getMessage());
+            System.err.println("Error: " + ex.getMessage());
             System.err.println();
             if (isVerboseOn()) {
                 ex.printStackTrace();
@@ -85,7 +85,7 @@
 
     public void checkParams(ErrorVisitor errors) throws ToolException {
         if (errors.getErrors().size() > 0) {
-            Message msg = new Message("PARAMETER_MISSSING", LOG);
+            Message msg = new Message("PARAMETER_MISSING", LOG);
             throw new ToolException(msg, new BadUsageException(getUsage(), errors));
         }
     }

Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.java?view=diff&rev=564510&r1=564509&r2=564510
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.java
Fri Aug 10 01:39:34 2007
@@ -41,7 +41,7 @@
         try {
             j2w.run();
         } catch (Exception ex) {
-            System.err.println("JavaToWS Error : " + ex.getMessage());
+            System.err.println("JavaToWS Error: " + ex.getMessage());
             System.err.println();
             if (j2w.isVerbose()) {
                 ex.printStackTrace();

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?view=diff&rev=564510&r1=564509&r2=564510
==============================================================================
--- 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
Fri Aug 10 01:39:34 2007
@@ -19,8 +19,10 @@
 package org.apache.cxf.tools.java2ws;
 
 import java.util.HashSet;
+import java.util.logging.Logger;
 
 import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.tools.common.AbstractCXFToolContainer;
 import org.apache.cxf.tools.common.Processor;
 import org.apache.cxf.tools.common.ToolConstants;
@@ -28,13 +30,14 @@
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.common.toolspec.ToolSpec;
 import org.apache.cxf.tools.common.toolspec.parser.BadUsageException;
+import org.apache.cxf.tools.common.toolspec.parser.CommandDocument;
 import org.apache.cxf.tools.common.toolspec.parser.ErrorVisitor;
 import org.apache.cxf.tools.java2wsdl.processor.JavaToProcessor;
 import org.apache.cxf.tools.util.AnnotationUtil;
 
 public class JavaToWSContainer extends AbstractCXFToolContainer {
-
-    private static final String TOOL_NAME = "java2wsdl";
+    private static final Logger LOG = LogUtils.getL7dLogger(JavaToWSContainer.class);
+    private static final String TOOL_NAME = "java2ws";
 
     public JavaToWSContainer(ToolSpec toolspec) throws Exception {
         super(TOOL_NAME, toolspec);
@@ -42,8 +45,10 @@
 
     public void execute(boolean exitOnFinish) throws ToolException {
         Processor processor = null;
+        ErrorVisitor errors = new ErrorVisitor();
         try {
             super.execute(exitOnFinish);
+            checkParams(errors);
             if (!hasInfoOption()) {
                 ToolContext env = new ToolContext();
                 env.setParameters(getParametersMap(new HashSet()));
@@ -65,7 +70,7 @@
             }
             throw ex;
         } catch (Exception ex) {
-            System.err.println("Error : " + ex.getMessage());
+            System.err.println("Error: " + ex.getMessage());
             System.err.println();
             if (isVerboseOn()) {
                 ex.printStackTrace();
@@ -76,17 +81,41 @@
     }
 
     public Class getServiceClass(ToolContext context) {
-        return AnnotationUtil.loadClass((String)context.get(ToolConstants.CFG_CLASSNAME),
-                                        getClass().getClassLoader());
+        return AnnotationUtil.loadClass((String)context.get(ToolConstants.CFG_CLASSNAME),
getClass()
+            .getClassLoader());
     }
 
+    public void checkParams(ErrorVisitor errs) throws ToolException {
+
+        CommandDocument doc = super.getCommandDocument();
 
+        if (doc.hasParameter("frontend")) {
+            String ft = doc.getParameter("frontend");
+            
+            if (!"simple".equalsIgnoreCase(ft) && !"jaxws".equalsIgnoreCase(ft))
{
+                Message msg = new Message("INVALID_FORNTEND", LOG, new Object[]{ft});   
           
+                errs.add(new ErrorVisitor.UserError(msg.toString()));
+            }
+        }
+        
+        
+        if (doc.hasParameter("wrapperbean")) {
+            String ft = doc.getParameter("frontend");
+            if (ft != null &&  !"jaxws".equalsIgnoreCase(ft)) {
+                Message msg = new Message("CANT_GEN_WRAPPERBEAN", LOG);               
+                errs.add(new ErrorVisitor.UserError(msg.toString()));
+            }
+        }
 
-    public void checkParams(ErrorVisitor errors) throws ToolException {
-        if (errors.getErrors().size() > 0) {
-            Message msg = new Message("PARAMETER_MISSSING", LOG);
-            throw new ToolException(msg, new BadUsageException(getUsage(), errors));
+        
+        
+        
+        
+        
+        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?view=diff&rev=564510&r1=564509&r2=564510
==============================================================================
--- 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
Fri Aug 10 01:39:34 2007
@@ -22,6 +22,7 @@
 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
-
+PARAMETER_MISSING = Required parameter is missing or not valid
+INVALID_FORNTEND = \ "{0}" is not a valid frontend, java2ws only supports jaxws and simple
frontend.
+CANT_GEN_WRAPPERBEAN = Wrapperbean only needs to be generated for jaxws front end.
 

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?view=diff&rev=564510&r1=564509&r2=564510
==============================================================================
--- 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
Fri Aug 10 01:39:34 2007
@@ -28,7 +28,7 @@
 	<annotation>
 		Examples :
 
-		java2wsdl org.apache.hello_world_soap_http.Greeter java2ws -cp
+		java2ws org.apache.hello_world_soap_http.Greeter java2ws -cp
 		./tmp org.apache.hello_world_soap_http.Greeter java2ws -o
 		hello.wsdl org.apache.hello_world_soap_http.Greeter java2ws -o
 		hello.wsdl -t http://cxf.apache.org
@@ -38,35 +38,26 @@
 
 		<optionGroup id="options">
 			<option id="frontend" maxOccurs="1">
-				<annotation>Specify to use which frontend</annotation>
+				<annotation>specify which frontend should be use, support jaxws and simple frontend.</annotation>
 				<switch>frontend</switch>
 				<associatedArgument placement="afterSpace">
-					<annotation>Use to use which frontend, simple or jaxws</annotation>
+					<annotation>jaxws-or-simple</annotation>
 				</associatedArgument>
 			</option>
 			
 			<option id="wrapperbean" maxOccurs="1">
 				<annotation>Specify to genearte wrapper and fault bean</annotation>
 				<switch>wrapperbean</switch>
-				<associatedArgument placement="afterSpace">
-					<annotation>Use jaxws frontend, default is jaxws frontend</annotation>
-				</associatedArgument>
 			</option>
 			
 			<option id="client" maxOccurs="1">
 				<annotation>Specify to genearte client side code</annotation>
 				<switch>client</switch>
-				<associatedArgument placement="afterSpace">
-					<annotation>Generate client side code for this class</annotation>
-				</associatedArgument>
 			</option>
 				
 			<option id="server" maxOccurs="1">
 				<annotation>Specify to genearte server side code</annotation>
 				<switch>server</switch>
-				<associatedArgument placement="afterSpace">
-					<annotation>Generate server side code for this class</annotation>
-				</associatedArgument>
 			</option>
 			
 			<option id="wsdl" maxOccurs="1">

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?view=diff&rev=564510&r1=564509&r2=564510
==============================================================================
--- 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
Fri Aug 10 01:39:34 2007
@@ -34,7 +34,7 @@
     protected String cp;
     protected ToolContext env;
     protected File output;
-    
+
     @Before
     public void startUp() throws Exception {
         env = new ToolContext();
@@ -44,7 +44,7 @@
         output = new File(output, "/generated/");
         FileUtils.mkDir(output);
     }
-    
+
     @After
     public void tearDown() {
         super.tearDown();
@@ -57,18 +57,44 @@
         JavaToWS.main(args);
         assertNotNull(getStdOut());
     }
-    
+
     @Test
     public void testFlagWSDL() throws Exception {
-        String[] args = new String[] {"-wsdl", "-o", output.getPath() + "/tmp.wsdl", 
+        String[] args = new String[] {"-wsdl", "-o", output.getPath() + "/tmp.wsdl",
                                       "org.apache.hello_world_soap12_http.Greeter"};
         JavaToWS.main(args);
         File wsdlFile = new File(output.getPath() + "/tmp.wsdl");
         assertTrue("wsdl is not generated", wsdlFile.exists());
-        
-        
+
+
     }
-    
+
+    @Test
+    public void testInvalidFlag() throws Exception {
+        String[] args = new String[] {"-frontend", "tmp", "-wsdl", "-o", output.getPath()
+ "/tmp.wsdl",
+                                      "org.apache.hello_world_soap12_http.Greeter"};
+        JavaToWS.main(args);
+        assertTrue("invalid frontend flag should be detected",
+                   getStdErr().indexOf("is not a valid frontend,") > -1);
+
+        File wsdlFile = new File(output.getPath() + "/tmp.wsdl");
+        assertTrue("wsdl is not generated", wsdlFile.exists());
+    }
+
+    @Test
+    public void testInvalidFlag2() throws Exception {
+        String[] args = new String[] {"-frontend", "simple", "-wrapperbean", "-wsdl",
+                                      "-o", output.getPath() + "/tmp.wsdl",
+                                      "org.apache.hello_world_soap12_http.Greeter"};
+        JavaToWS.main(args);
+        assertTrue("wrapperbean flag error should be detected",
+                   getStdErr().indexOf("Wrapperbean only needs to be generated for jaxws
front end") > -1);
+        File wsdlFile = new File(output.getPath() + "/tmp.wsdl");
+        assertTrue("wsdl is not generated", wsdlFile.exists());
+    }
+
+
+
     protected String getClassPath() throws URISyntaxException {
         ClassLoader loader = getClass().getClassLoader();
         StringBuffer classPath = new StringBuffer();



Mime
View raw message