cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r564127 - in /incubator/cxf/trunk/tools/javato/ws: ./ src/main/java/org/apache/cxf/tools/java2ws/ src/main/java/org/apache/cxf/tools/java2wsdl/ src/main/java/org/apache/cxf/tools/java2wsdl/processor/ src/test/java/ src/test/java/org/ src/te...
Date Thu, 09 Aug 2007 07:55:33 GMT
Author: ema
Date: Thu Aug  9 00:55:31 2007
New Revision: 564127

URL: http://svn.apache.org/viewvc?view=rev&rev=564127
Log:
[CXF-891] Create tool specification and java2ws container to check the input parameters
Corrected typo errors

Added:
    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/
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
    incubator/cxf/trunk/tools/javato/ws/src/test/resources/
      - copied from r563798, incubator/cxf/trunk/tools/javato/test/src/test/resources/
Removed:
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/JavaToWSDL.java
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/JavaToWSDLContainer.java
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/Messages.properties
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/java2wsdl.xml
Modified:
    incubator/cxf/trunk/tools/javato/ws/pom.xml
    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/java2wsdl/processor/JavaToProcessor.java

Modified: incubator/cxf/trunk/tools/javato/ws/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/pom.xml?view=diff&rev=564127&r1=564126&r2=564127
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/pom.xml (original)
+++ incubator/cxf/trunk/tools/javato/ws/pom.xml Thu Aug  9 00:55:31 2007
@@ -85,6 +85,13 @@
         </dependency>
 
         <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxws</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>      
+        
+        <dependency>
             <groupId>com.sun.xml.bind</groupId>
             <artifactId>jaxb-xjc</artifactId>
         </dependency>
@@ -99,7 +106,73 @@
         </dependency>
 
     </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.cxf</groupId>
+                <artifactId>cxf-codegen-plugin</artifactId>
+                <version>${project.version}</version>
+                <executions>
+                    <execution>
+                        <id>generate-test-sources</id>
+                        <phase>generate-test-sources</phase>
+                        <configuration>
+                            <testSourceRoot>${basedir}/target/generated/src/test/java</testSourceRoot>
+                            <wsdlOptions>
+                                <wsdlOption>
+                                    <wsdl>${basedir}/src/test/resources/java2wsdl_wsdl/hello_world_async.wsdl</wsdl>
+                                </wsdlOption>
+                                <wsdlOption>
+                                    <wsdl>${basedir}/src/test/resources/java2wsdl_wsdl/doc_wrapped_simple.wsdl</wsdl>
+                                </wsdlOption>
+                                <wsdlOption>
+                                    <wsdl>${basedir}/src/test/resources/java2wsdl_wsdl/hello_world_doc_lit.wsdl</wsdl>
+                                </wsdlOption>
+                                <wsdlOption>
+                                    <wsdl>${basedir}/src/test/resources/java2wsdl_wsdl/hello_world_doc_wrapped_bare.wsdl</wsdl>
+                                </wsdlOption>
+                                <wsdlOption>
+                                    <wsdl>${basedir}/src/test/resources/java2wsdl_wsdl/hello_world_rpc_lit.wsdl</wsdl>
+                                </wsdlOption>
+                                <wsdlOption>
+                                    <wsdl>${basedir}/src/test/resources/java2wsdl_wsdl/hello_world_soap12.wsdl</wsdl>
+                                </wsdlOption>
+                                <wsdlOption>
+                                    <wsdl>${basedir}/src/test/resources/java2wsdl_wsdl/hello_world_bare.wsdl</wsdl>
+                                </wsdlOption>
+                                <wsdlOption>
+                                    <wsdl>${basedir}/src/test/resources/java2wsdl_wsdl/hello_world_fault.wsdl</wsdl>
+                                </wsdlOption>
+                            </wsdlOptions>
+                        </configuration>
+                        <goals>
+                            <goal>wsdl2java</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <version>1.0</version>
+                <executions>
+                    <execution>
+                        <id>add-source</id>
+                        <phase>generate-test-sources</phase>
+                        <goals>
+                            <goal>add-test-source</goal>
+                        </goals>
+                        <configuration>
+                            <sources>
+                                <source>${basedir}/src/test/generated</source>
+                            </sources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
 
+        </plugins>
+    </build>
     <scm>
 	<connection>scm:svn:http://svn.apache.org/repos/asf/incubator/cxf/trunk/tools/javato/core</connection>
 	<developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/cxf/trunk/tools/javato/ws</developerConnection>

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=564127&r1=564126&r2=564127
==============================================================================
--- 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
Thu Aug  9 00:55:31 2007
@@ -41,7 +41,7 @@
         try {
             j2w.run();
         } catch (Exception ex) {
-            System.err.println("JavaToWSDL Error : " + ex.getMessage());
+            System.err.println("JavaToWS Error : " + ex.getMessage());
             System.err.println();
             if (j2w.isVerbose()) {
                 ex.printStackTrace();
@@ -72,8 +72,7 @@
 
     private void run() throws Exception {
         ToolRunner.runTool(JavaToWSContainer.class, JavaToWSContainer.class
-                           .getResourceAsStream("java2ws.xml"), false, args);
-       
+                           .getResourceAsStream("java2ws.xml"), false, args);      
     }
 
     private boolean isExitOnFinish() {
@@ -83,5 +82,7 @@
         }
         return "YES".equalsIgnoreCase(exit) || "TRUE".equalsIgnoreCase(exit);
     }
+    
+    
 
 }

Added: 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=auto&rev=564127
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
(added)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
Thu Aug  9 00:55:31 2007
@@ -0,0 +1,92 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.tools.java2ws;
+
+import java.util.HashSet;
+
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.tools.common.AbstractCXFToolContainer;
+import org.apache.cxf.tools.common.Processor;
+import org.apache.cxf.tools.common.ToolConstants;
+import org.apache.cxf.tools.common.ToolContext;
+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.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";
+
+    public JavaToWSContainer(ToolSpec toolspec) throws Exception {
+        super(TOOL_NAME, toolspec);
+    }
+
+    public void execute(boolean exitOnFinish) throws ToolException {
+        Processor processor = null;
+        try {
+            super.execute(exitOnFinish);
+            if (!hasInfoOption()) {
+                ToolContext env = new ToolContext();
+                env.setParameters(getParametersMap(new HashSet()));
+                if (isVerboseOn()) {
+                    env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
+                }
+
+                processor = new JavaToProcessor();
+
+                processor.setEnvironment(env);
+                processor.process();
+            }
+        } catch (ToolException ex) {
+            if (ex.getCause() instanceof BadUsageException) {
+                printUsageException(TOOL_NAME, (BadUsageException)ex.getCause());
+                if (isVerboseOn()) {
+                    ex.printStackTrace();
+                }
+            }
+            throw ex;
+        } catch (Exception ex) {
+            System.err.println("Error : " + ex.getMessage());
+            System.err.println();
+            if (isVerboseOn()) {
+                ex.printStackTrace();
+            }
+
+            throw new ToolException(ex.getMessage(), ex.getCause());
+        }
+    }
+
+    public Class getServiceClass(ToolContext context) {
+        return AnnotationUtil.loadClass((String)context.get(ToolConstants.CFG_CLASSNAME),
+                                        getClass().getClassLoader());
+    }
+
+
+
+    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));
+        }
+    }
+}
+

Added: 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=auto&rev=564127
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties
(added)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties
Thu Aug  9 00:55:31 2007
@@ -0,0 +1,27 @@
+#
+#
+#    Licensed to the Apache Software Foundation (ASF) under one
+#    or more contributor license agreements. See the NOTICE file
+#    distributed with this work for additional information
+#    regarding copyright ownership. The ASF licenses this file
+#    to you under the Apache License, Version 2.0 (the
+#    "License"); you may not use this file except in compliance
+#    with the License. You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing,
+#    software distributed under the License is distributed on an
+#    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#    KIND, either express or implied. See the License for the
+#    specific language governing permissions and limitations
+#    under the License.
+#
+#
+DIRECTORY_NOT_EXIST = Directory : {0} does not exist
+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
+
+

Added: 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=auto&rev=564127
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml
(added)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml
Thu Aug  9 00:55:31 2007
@@ -0,0 +1,215 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	Licensed to the Apache Software Foundation (ASF) under one
+	or more contributor license agreements. See the NOTICE file
+	distributed with this work for additional information
+	regarding copyright ownership. The ASF licenses this file
+	to you under the Apache License, Version 2.0 (the
+	"License"); you may not use this file except in compliance
+	with the License. You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing,
+	software distributed under the License is distributed on an
+	"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+	KIND, either express or implied. See the License for the
+	specific language governing permissions and limitations
+	under the License.
+-->
+
+<!-- The xhtml namespace is for usage documentation -->
+<toolspec xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:xhtml="http://www.w3.org/TR/xhtml1/strict"
+	xsi:schemaLocation="http://cxf.apache.org/Xutil/ToolSpecification http://cxf.apache.org/schema/xutil/tool-specification.xsd"
+	xmlns="http://cxf.apache.org/Xutil/ToolSpecification"
+	xmlns:ts="http://cxf.apache.org/Xutil/ToolSpecification">
+
+	<annotation>
+		Examples :
+
+		java2wsdl 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
+		org.apache.hello_world_soap_http.Greeter
+	</annotation>
+	<usage>
+
+		<optionGroup id="options">
+			<option id="frontend" maxOccurs="1">
+				<annotation>Specify to use which frontend</annotation>
+				<switch>frontend</switch>
+				<associatedArgument placement="afterSpace">
+					<annotation>Use to use which frontend, simple or jaxws</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">
+				<annotation>Specify generating wsdl</annotation>
+				<switch>wsdl</switch>W
+			</option>
+
+
+			<option id="outputfile" maxOccurs="1">
+				<annotation>
+					Specify the output wsdl file name
+				</annotation>
+				<switch>o</switch>
+				<associatedArgument placement="afterSpace">
+					<annotation>output-file</annotation>
+				</associatedArgument>
+			</option>
+
+			<option id="outputdir" maxOccurs="1">
+				<annotation>
+					The directory in which the output files are placed
+				</annotation>
+				<switch>d</switch>
+				<associatedArgument placement="afterSpace">
+					<annotation>output-directory</annotation>
+				</associatedArgument>
+			</option>
+
+			<option id="sourcedir" maxOccurs="1">
+				<annotation>
+					The directory in which the generated source files
+					are placed
+				</annotation>
+				<switch>s</switch>
+				<associatedArgument placement="afterSpace">
+					<annotation>source-directory</annotation>
+				</associatedArgument>
+			</option>
+			<option id="classdir" maxOccurs="1">
+				<annotation>
+					The directory in which the generated sources are
+					compiled into. If not specified, the files are not
+					compiled.
+				</annotation>
+				<switch>classdir</switch>
+				<associatedArgument placement="afterSpace">
+					<annotation>compile-classes-directory</annotation>
+				</associatedArgument>
+			</option>
+
+			<option id="classpath" maxOccurs="1">
+				<annotation>
+					Specify the SEI and types class search path of
+					directories and zip/jar files
+				</annotation>
+				<switch>cp</switch>
+				<associatedArgument placement="afterSpace">
+					<annotation>class-path</annotation>
+				</associatedArgument>
+			</option>
+
+			<option id="soap12" maxOccurs="1">
+				<annotation>
+					Specify to generate SOAP 1.2 binding
+				</annotation>
+				<switch>soap12</switch>
+			</option>
+
+			<option id="tns" maxOccurs="1">
+				<annotation>
+					Specify the target namespace to use in the wsdl
+				</annotation>
+				<switch>t</switch>
+				<associatedArgument placement="afterSpace">
+					<annotation>target-namespace</annotation>
+				</associatedArgument>
+			</option>
+
+			<option id="servicename" maxOccurs="1">
+				<annotation>
+					Specify the service name to use in the generated
+					wsdl
+				</annotation>
+				<switch>servicename</switch>
+				<associatedArgument placement="afterSpace">
+					<annotation>service-name</annotation>
+				</associatedArgument>
+			</option>
+
+			<option id="port" maxOccurs="1">
+				<annotation>
+					Specify the port name to use in the generated wsdl
+				</annotation>
+				<switch>portname</switch>
+				<associatedArgument placement="afterSpace">
+					<annotation>port-name</annotation>
+				</associatedArgument>
+			</option>
+
+			<option id="createxsdimports" maxOccurs="1">
+				<annotation>
+					Output schemas to separate files and use imports to
+					load them instead of inlining them into the wsdl.
+				</annotation>
+				<switch>createxsdimports</switch>
+			</option>
+
+		</optionGroup>
+
+		<optionGroup id="common_options">
+			<option id="help" maxOccurs="1">
+				<annotation>
+					Display detailed information for options.
+				</annotation>
+				<switch>h</switch>
+				<switch>?</switch>
+				<switch>help</switch>
+			</option>
+
+			<option id="version">
+				<annotation>
+					Display the version of the tool.
+				</annotation>
+				<switch>v</switch>
+			</option>
+
+			<option id="verbose">
+				<annotation>Verbose mode</annotation>
+				<switch>verbose</switch>
+				<switch>V</switch>
+			</option>
+
+			<option id="quiet">
+				<annotation>Quiet mode</annotation>
+				<switch>quiet</switch>
+				<switch>q</switch>
+			</option>
+
+
+		</optionGroup>
+
+		<argument id="classname" minOccurs="1" maxOccurs="1">
+			<annotation>SEI class name</annotation>
+		</argument>
+	</usage>
+</toolspec>

Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java?view=diff&rev=564127&r1=564126&r2=564127
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java
Thu Aug  9 00:55:31 2007
@@ -92,11 +92,13 @@
                                       service.getName().getLocalPart() + ".wsdl");
 
         File outputDir = getOutputDir(wsdlFile);
-
-        generators.add(getWSDLGenerator(wsdlFile));
-        generators.add(getWrapperBeanGenerator());
-        generators.add(getFaultBeanGenerator());
-
+        if (context.containsKey(ToolConstants.CFG_WSDL)) {
+            generators.add(getWSDLGenerator(wsdlFile));
+        }
+        if (context.containsKey(ToolConstants.CFG_WRAPPERBEAN)) {
+            generators.add(getWrapperBeanGenerator());
+            generators.add(getFaultBeanGenerator());
+        }
         generate(service, outputDir);
         System.setProperty(JAVA_CLASS_PATH, oldClassPath);
         LOG.log(Level.INFO, "RESUME_CP", oldClassPath);

Added: 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=auto&rev=564127
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
(added)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
Thu Aug  9 00:55:31 2007
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.tools.java2ws;
+
+import java.io.File;
+import java.net.URISyntaxException;
+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.Test;
+
+public class JavaToWSTest extends ToolTestBase {
+    protected String cp;
+    protected ToolContext env;
+    protected File output;
+    
+    @Before
+    public void startUp() throws Exception {
+        env = new ToolContext();
+        cp = System.getProperty("java.class.path");
+        URL url = getClass().getResource(".");
+        output = new File(url.toURI());
+        output = new File(output, "/generated/");
+        FileUtils.mkDir(output);
+    }
+    
+    @After
+    public void tearDown() {
+        super.tearDown();
+        System.setProperty("java.class.path", cp);
+    }
+
+    @Test
+    public void testVersionOutput() throws Exception {
+        String[] args = new String[] {"-v"};
+        JavaToWS.main(args);
+        assertNotNull(getStdOut());
+    }
+    
+    @Test
+    public void testFlagWSDL() throws Exception {
+        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());
+        
+        
+    }
+    
+    protected String getClassPath() throws URISyntaxException {
+        ClassLoader loader = getClass().getClassLoader();
+        StringBuffer classPath = new StringBuffer();
+        if (loader instanceof URLClassLoader) {
+            URLClassLoader urlLoader = (URLClassLoader)loader;
+            for (URL url : urlLoader.getURLs()) {
+                File file;
+                file = new File(url.toURI());
+                String filename = file.getAbsolutePath();
+                if (filename.indexOf("junit") == -1) {
+                    classPath.append(filename);
+                    classPath.append(System.getProperty("path.separator"));
+                }
+            }
+        }
+        return classPath.toString();
+    }
+
+}



Mime
View raw message