cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r496651 - in /incubator/cxf/trunk/tools2: common/src/main/java/org/apache/cxf/tools/common/ validator/ wsdlto/core/ wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/ wsdlto/frontend/jaxws/src/main/java/org/...
Date Tue, 16 Jan 2007 10:08:54 GMT
Author: ema
Date: Tue Jan 16 02:08:53 2007
New Revision: 496651

URL: http://svn.apache.org/viewvc?view=rev&rev=496651
Log:
Updated woodstox dependency 
Ported some wsdl2java test cases from old tools
 
 

Modified:
    incubator/cxf/trunk/tools2/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
    incubator/cxf/trunk/tools2/validator/pom.xml
    incubator/cxf/trunk/tools2/wsdlto/core/pom.xml
    incubator/cxf/trunk/tools2/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/ClassNameAllocatorImpl.java
    incubator/cxf/trunk/tools2/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
    incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParser.java
    incubator/cxf/trunk/tools2/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java

Modified: incubator/cxf/trunk/tools2/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java?view=diff&rev=496651&r1=496650&r2=496651
==============================================================================
--- incubator/cxf/trunk/tools2/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
(original)
+++ incubator/cxf/trunk/tools2/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
Tue Jan 16 02:08:53 2007
@@ -181,6 +181,9 @@
         if (hasNamespace(ns)) {
             return mapNamespaceToPackageName(ns);
         } else {
+            if (getPackageName() != null) {
+                return getPackageName();
+            }
             String pkg = URIParserUtil.parsePackageName(ns, null);
             setPackageName(pkg);
             return pkg;

Modified: incubator/cxf/trunk/tools2/validator/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/validator/pom.xml?view=diff&rev=496651&r1=496650&r2=496651
==============================================================================
--- incubator/cxf/trunk/tools2/validator/pom.xml (original)
+++ incubator/cxf/trunk/tools2/validator/pom.xml Tue Jan 16 02:08:53 2007
@@ -83,7 +83,7 @@
         </dependency>
 
         <dependency>
-            <groupId>woodstox</groupId>
+            <groupId>org.codehaus.woodstox</groupId>
             <artifactId>wstx-asl</artifactId>
             <scope>runtime</scope>
         </dependency>

Modified: incubator/cxf/trunk/tools2/wsdlto/core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/wsdlto/core/pom.xml?view=diff&rev=496651&r1=496650&r2=496651
==============================================================================
--- incubator/cxf/trunk/tools2/wsdlto/core/pom.xml (original)
+++ incubator/cxf/trunk/tools2/wsdlto/core/pom.xml Tue Jan 16 02:08:53 2007
@@ -106,10 +106,10 @@
 	    <artifactId>saaj-api</artifactId>
 	</dependency>
 	<dependency>
-	    <groupId>woodstox</groupId>
-	    <artifactId>wstx-asl</artifactId>
-	    <scope>runtime</scope>
-	</dependency>
+	            <groupId>org.codehaus.woodstox</groupId>
+	            <artifactId>wstx-asl</artifactId>
+	            <scope>runtime</scope>
+        </dependency>
 	<dependency>
 	    <groupId>org.apache.cxf</groupId>
 	    <artifactId>cxf-common-utilities</artifactId>

Modified: incubator/cxf/trunk/tools2/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/ClassNameAllocatorImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/ClassNameAllocatorImpl.java?view=diff&rev=496651&r1=496650&r2=496651
==============================================================================
--- incubator/cxf/trunk/tools2/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/ClassNameAllocatorImpl.java
(original)
+++ incubator/cxf/trunk/tools2/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/ClassNameAllocatorImpl.java
Tue Jan 16 02:08:53 2007
@@ -31,8 +31,10 @@
 public class ClassNameAllocatorImpl implements ClassNameAllocator {
     private static final String TYPE_SUFFIX = "_Type";
     private ClassCollector collector;
+
     public ClassNameAllocatorImpl(ClassCollector classCollector) {
         collector = classCollector;
+
     }
 
     private boolean isNameCollision(String packageName, String className) {

Modified: incubator/cxf/trunk/tools2/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?view=diff&rev=496651&r1=496650&r2=496651
==============================================================================
--- incubator/cxf/trunk/tools2/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
(original)
+++ incubator/cxf/trunk/tools2/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
Tue Jan 16 02:08:53 2007
@@ -20,6 +20,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.logging.Logger;
@@ -27,6 +28,7 @@
 import javax.wsdl.Definition;
 import javax.xml.namespace.QName;
 
+import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 import org.xml.sax.InputSource;
@@ -42,6 +44,7 @@
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
+
 import org.apache.cxf.service.model.SchemaInfo;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.tools.common.ToolConstants;
@@ -57,6 +60,7 @@
     private ToolContext env;
     private ServiceInfo serviceInfo;
     private Definition def;
+    private List<String> schemaSystemIds = new ArrayList<String>();
 
     @SuppressWarnings("unchecked")
     private void initialize(ToolContext penv) throws ToolException {
@@ -65,7 +69,9 @@
         def = (Definition)env.get(Definition.class);
 
         SchemaCompilerImpl schemaCompiler = (SchemaCompilerImpl)XJC.createSchemaCompiler();
-
+        if (env.getPackageName() != null) {
+            schemaCompiler.setDefaultPackageName(env.getPackageName());
+        }
         ClassCollector classCollector = env.get(ClassCollector.class);
         ClassNameAllocatorImpl allocator = new ClassNameAllocatorImpl(classCollector);
         allocator.setInterface(serviceInfo.getInterface(), env.mapPackageName(def.getTargetNamespace()));
@@ -74,14 +80,25 @@
         JAXBBindErrorListener listener = new JAXBBindErrorListener(env);
         schemaCompiler.setErrorListener(listener);
 
-        Collection<SchemaInfo> schemas = serviceInfo.getTypeInfo().getSchemas();
+        Collection<SchemaInfo> schemas = serviceInfo.getSchemas();
 
         Collection<InputSource> jaxbBindings = env.getJaxbBindingFile().values();
 
         for (SchemaInfo schema : schemas) {
-            Element element = schema.getElement();
-            String tns = element.getAttribute("targetNamespace");
-            schemaCompiler.parseSchema(tns, element);
+            Document[] docs = schema.getSchema().getAllSchemas();
+            for (int i = 0; i < docs.length; i++) {
+                Element ele = docs[i].getDocumentElement();
+                String systemId = schema.getElement().getBaseURI();
+                String tns = ele.getAttribute("targetNamespace");              
+                if (StringUtils.isEmpty(tns)) {
+                    continue;
+                }
+                if (schemaSystemIds.contains(schema.getElement().getBaseURI())) {
+                    systemId = schema.getElement().getBaseURI() + "#" + tns;
+                } 
+                schemaCompiler.parseSchema(systemId, ele);
+            }
+            
         }
 
         for (InputSource binding : jaxbBindings) {

Modified: incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParser.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParser.java?view=diff&rev=496651&r1=496650&r2=496651
==============================================================================
--- incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParser.java
(original)
+++ incubator/cxf/trunk/tools2/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParser.java
Tue Jan 16 02:08:53 2007
@@ -332,7 +332,7 @@
         } catch (URISyntaxException e2) {
             //ignore
         }
-        InputSource is = new InputSource(bindingFile);
+        InputSource is = new InputSource(bindingURI.toString());
         XMLStreamReader reader = StAXUtil.createFreshXMLStreamReader(is);
 
         StAXUtil.toStartTag(reader);

Modified: incubator/cxf/trunk/tools2/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools2/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java?view=diff&rev=496651&r1=496650&r2=496651
==============================================================================
--- incubator/cxf/trunk/tools2/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
(original)
+++ incubator/cxf/trunk/tools2/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
Tue Jan 16 02:08:53 2007
@@ -62,7 +62,7 @@
     }
 
     public void testRPCLit() throws Exception {
-       
+
         env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world_rpc_lit.wsdl"));
         processor.setContext(env);
         processor.execute(false);
@@ -274,7 +274,6 @@
 
     }
 
-    
     public void testDocLitHolder() throws Exception {
         env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/mapping-doc-literal.wsdl"));
         processor.setContext(env);
@@ -297,7 +296,131 @@
         webParamAnno = AnnotationUtil.getWebParam(method, "z");
         assertEquals("OUT", webParamAnno.mode().name());
     }
-     
+
+    public void testSchemaImport() throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world_schema_import.wsdl"));
+        
+        processor.setContext(env);
+        processor.execute(true);
+
+        assertNotNull(output);
+
+        File org = new File(output, "org");
+        assertTrue(org.exists());
+        File apache = new File(org, "apache");
+        assertTrue(apache.exists());
+        File[] files = apache.listFiles();
+        assertEquals(2, files.length);
+        File helloworldsoaphttp = new File(apache, "hello_world_soap_http");
+        assertTrue(helloworldsoaphttp.exists());
+        File types = new File(helloworldsoaphttp, "types");
+        assertTrue(types.exists());
+        files = helloworldsoaphttp.listFiles();
+        assertEquals(1, files.length);
+        files = types.listFiles();
+        assertEquals(files.length, 10);
+        File schemaImport = new File(apache, "schema_import");
+        assertTrue(schemaImport.exists());
+        files = schemaImport.listFiles();
+        assertEquals(4, files.length);
+
+        Class clz = classLoader.loadClass("org.apache.schema_import.Greeter");
+        assertEquals(4, clz.getMethods().length);
+
+        Method method = clz.getMethod("pingMe", new Class[] {});
+        assertEquals("void", method.getReturnType().getSimpleName());
+        assertEquals("Exception class is not generated ", 1, method.getExceptionTypes().length);
+
+    }
+
+    public void testExceptionNameCollision() throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/InvoiceServer.wsdl"));
+
+        processor.setContext(env);
+        processor.execute(true);
+
+        assertNotNull(output);
+
+        File org = new File(output, "org");
+        assertTrue(org.exists());
+        File apache = new File(org, "apache");
+        assertTrue(apache.exists());
+        File invoiceserver = new File(apache, "invoiceserver");
+        assertTrue(invoiceserver.exists());
+        File invoice = new File(apache, "invoice");
+        assertTrue(invoice.exists());
+
+        File exceptionCollision = new File(invoiceserver, "NoSuchCustomerFault_Exception.java");
+        assertTrue(exceptionCollision.exists());
+
+        File[] files = invoiceserver.listFiles();
+        assertEquals(13, files.length);
+        files = invoice.listFiles();
+        assertEquals(files.length, 9);
+
+        Class clz = classLoader.loadClass("org.apache.invoiceserver.InvoiceServer");
+        assertEquals(3, clz.getMethods().length);
+
+        Method method = clz.getMethod("getInvoicesForCustomer", new Class[] {String.class,
String.class});
+        assertEquals("NoSuchCustomerFault_Exception", method.getExceptionTypes()[0].getSimpleName());
+
+    }
+
+    public void testAllNameCollision() throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world_collision.wsdl"));
+        env.setPackageName("org.apache");
+        processor.setContext(env);
+        processor.execute(true);
+
+        assertNotNull(output);
+
+        File org = new File(output, "org");
+        assertTrue(org.exists());
+        File apache = new File(org, "apache");
+        assertTrue(apache.exists());
+
+        File[] files = apache.listFiles();
+        assertEquals(14, files.length);
+
+        File typeCollision = new File(apache, "Greeter_Type.java");
+        assertTrue(typeCollision.exists());
+        File exceptionCollision = new File(apache, "Greeter_Exception.java");
+        assertTrue(exceptionCollision.exists());
+        File serviceCollision = new File(apache, "Greeter_Service.java");
+        assertTrue(serviceCollision.exists());
+
+        Class clz = classLoader.loadClass("org.apache.Greeter");
+        assertTrue("SEI class Greeter modifier should be interface", clz.isInterface());
+
+        clz = classLoader.loadClass("org.apache.Greeter_Exception");
+        clz = classLoader.loadClass("org.apache.Greeter_Service");
+    }
+
+    public void testImportNameCollision() throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL,
+                getLocation("/wsdl2java_wsdl/helloworld-portname_servicename.wsdl"));
+        env.setPackageName("org.apache");
+        processor.setContext(env);
+        processor.execute(true);
+
+        assertNotNull(output);
+
+        File org = new File(output, "org");
+        assertTrue(org.exists());
+        File apache = new File(org, "apache");
+        assertTrue(apache.exists());
+
+        File[] files = apache.listFiles();
+        assertEquals(4, files.length);
+
+        File serviceCollision = new File(apache, "HelloWorldServiceImpl_Service.java");
+        assertTrue(serviceCollision.exists());
+
+        Class clz = classLoader.loadClass("org.apache.HelloWorldServiceImpl");
+        assertTrue("SEI class HelloWorldServiceImpl modifier should be interface", clz.isInterface());
+
+        clz = classLoader.loadClass("org.apache.HelloWorldServiceImpl_Service");
+    }
 
     private String getLocation(String wsdlFile) {
         return this.getClass().getResource(wsdlFile).getFile();



Mime
View raw message