cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r553456 - in /incubator/cxf/trunk/tools/wsdlto: frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/ frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/ frontend/jaxws/src/t...
Date Thu, 05 Jul 2007 11:16:55 GMT
Author: mmao
Date: Thu Jul  5 04:16:53 2007
New Revision: 553456

URL: http://svn.apache.org/viewvc?view=rev&rev=553456
Log:
* jaxb:bindings MAY appear inside external binding file 
    as a child of a jaxws:bindings element


Added:
    incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/resources/binding2.xml
      - copied unchanged from r553385, incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/bug305924/binding2.xml
    incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/resources/hello_world.wsdl
      - copied unchanged from r553385, incubator/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/bug305924/hello_world.wsdl
Modified:
    incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParser.java
    incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParserTest.java
    incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java

Modified: incubator/cxf/trunk/tools/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/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParser.java?view=diff&rev=553456&r1=553455&r2=553456
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParser.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParser.java
Thu Jul  5 04:16:53 2007
@@ -165,7 +165,24 @@
         return nodes;
     }
 
-    protected void copyAllJaxbDeclarations(final Node schemaNode, final Node jaxwsBindingNode)
{
+    private void appendJaxbVersion(final Element schemaElement) {
+        String jaxbPrefix = schemaElement.lookupPrefix(ToolConstants.NS_JAXB_BINDINGS);
+        if (jaxbPrefix == null) {
+            schemaElement.setAttribute("xmlns:jaxb", ToolConstants.NS_JAXB_BINDINGS);
+            schemaElement.setAttribute("jaxb:version", "2.0");
+        }
+    }
+
+    protected void copyAllJaxbDeclarations(final Node schemaNode, final Element jaxwsBindingNode)
{
+        Element jaxbBindingElement = getJaxbBindingElement(jaxwsBindingNode);
+        appendJaxbVersion((Element)schemaNode);
+        if (jaxbBindingElement != null) {
+            copyAllJaxbDeclarations(nodeSelector.queryNode(schemaNode,
+                                                           jaxbBindingElement.getAttribute("node")),
+                                    jaxbBindingElement);
+            return;
+        }
+
         Node[] embededNodes  = getAnnotationNodes(schemaNode);
         Node annotationNode = embededNodes[0];
         Node appinfoNode = embededNodes[1];
@@ -173,17 +190,12 @@
         NodeList childNodes = jaxwsBindingNode.getChildNodes();
         for (int i = 0; i < childNodes.getLength(); i++) {
             Node childNode = childNodes.item(i);
-            if (!isJaxbBindings(childNode)) {
+            if (!isJaxbBindings(childNode) || isJaxbBindingsElement(childNode)) {
                 continue;
             }
 
             final Element schemaElement = (Element) schemaNode;
             final Node jaxbNode = childNode;
-            String jaxbPrefix = schemaElement.lookupPrefix(ToolConstants.NS_JAXB_BINDINGS);
-            if (jaxbPrefix == null) {
-                schemaElement.setAttribute("xmlns:jaxb", ToolConstants.NS_JAXB_BINDINGS);
-                schemaElement.setAttribute("jaxb:version", "2.0");
-            }
 
             Node cloneNode = ProcessorUtil.cloneNode(schemaNode.getOwnerDocument(), jaxbNode,
true);
             appinfoNode.appendChild(cloneNode);
@@ -415,6 +427,18 @@
 
     private boolean isJaxbBindings(Node bindings) {
         return ToolConstants.NS_JAXB_BINDINGS.equals(bindings.getNamespaceURI());
+    }
+
+    private boolean isJaxbBindingsElement(Node bindings) {
+        return "bindings".equals(bindings.getLocalName());
+    }
+
+    protected Element getJaxbBindingElement(final Element bindings) {
+        NodeList list = bindings.getElementsByTagNameNS(ToolConstants.NS_JAXB_BINDINGS, "bindings");
+        if (list.getLength() > 0) {
+            return (Element) list.item(0);
+        }
+        return null;
     }
 
     protected boolean hasJaxbBindingDeclaration(Node bindings) {

Modified: incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParserTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParserTest.java?view=diff&rev=553456&r1=553455&r2=553456
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParserTest.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customiztion/CustomizationParserTest.java
Thu Jul  5 04:16:53 2007
@@ -60,7 +60,7 @@
         Node jaxwsBindingNode = selector.queryNode(binding, "//jaxws:bindings[@node]");
         Node schemaNode = selector.queryNode(schema, "//xsd:schema");
 
-        parser.copyAllJaxbDeclarations(schemaNode, jaxwsBindingNode);
+        parser.copyAllJaxbDeclarations(schemaNode, (Element)jaxwsBindingNode);
 
         File file = new File(output, "custom_test.xsd");
         XMLUtils.writeTo(schemaNode, new FileOutputStream(file));
@@ -119,6 +119,28 @@
             new String[]{base + "jaxb:globalBindings/jaxb:javaType"};
 
         File file = new File(output, "custom_test.wsdl");
+        XMLUtils.writeTo(wsdlDoc, new FileOutputStream(file));
+        Document testNode = XMLUtils.parse(file);
+
+        checking(testNode, checkingPoints);
+    }
+
+    @Test
+    public void testInternalizeBinding4() throws Exception {
+        Element wsdlDoc = getDocumentElement("resources/hello_world.wsdl");
+        Element jaxwsBinding = getDocumentElement("resources/binding2.xml");
+        parser.setWSDLNode(wsdlDoc);
+        parser.internalizeBinding(jaxwsBinding, "");
+
+        String checkingPoint = "wsdl:definitions/wsdl:types/xsd:schema";
+        checkingPoint += "/xsd:element[@name='CreateProcess']/xsd:complexType/xsd:sequence";
+        checkingPoint += "/xsd:element[@name='MyProcess']/xsd:simpleType/xsd:annotation/xsd:appinfo";
+        checkingPoint += "/jaxb:typesafeEnumClass/jaxb:typesafeEnumMember[@name='BLUE']";
+
+        String[] checkingPoints =
+            new String[]{checkingPoint};
+
+        File file = new File(output, "custom_test4.wsdl");
         XMLUtils.writeTo(wsdlDoc, new FileOutputStream(file));
         Document testNode = XMLUtils.parse(file);
 

Modified: incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?view=diff&rev=553456&r1=553455&r2=553456
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
Thu Jul  5 04:16:53 2007
@@ -46,7 +46,7 @@
     private JAXWSContainer processor;
     private ClassLoader classLoader;
 
-    
+
     @Before
     public void setUp() throws Exception {
         super.setUp();
@@ -66,7 +66,7 @@
 
     }
 
-    
+
     @After
     public void tearDown() {
         super.tearDown();
@@ -175,9 +175,9 @@
         Class clz = classLoader.loadClass("org.cxf.Greeter");
         assertTrue("Generate " + clz.getName() + "error", clz.isInterface());
     }
-    
-    
-    
+
+
+
 
     @Test
     public void testBug305772() throws Exception {
@@ -214,11 +214,11 @@
         assertFalse("Generated file has been excluded", com.exists());
         File iona = new File(com, "iona");
         assertFalse("Generated file has been excluded", iona.exists());
-        
+
         File implFile = new File(output, "org/apache/hello_world_soap_http/Greeter.java");
         String str = getStringFromFile(implFile);
         assertTrue(str.indexOf("com.iona.BareDocumentResponse") > 0);
-        
+
         File org = new File(output, "org");
         File apache = new File(org, "apache");
         File invoice = new File(apache, "Invoice");
@@ -240,7 +240,7 @@
         assertFalse("Generated file has been excluded", com.exists());
 
     }
-     
+
     @Test
     public void testCommandLine() throws Exception {
         String[] args = new String[] {"-compile", "-d", output.getCanonicalPath(), "-classdir",
@@ -309,14 +309,14 @@
                                           getLocation("/wsdl2java_wsdl/bug305924/hello_world.wsdl")};
             WSDLToJava.main(args);
         } catch (Exception e) {
-            e.printStackTrace(System.err);
+            fail("Error during wsdl2java: \n" + e.getMessage());
         }
         try {
             Class clz = classLoader
                 .loadClass("org.apache.hello_world_soap_http.types.CreateProcess$MyProcess");
             assertNotNull("Customization binding code should be generated", clz);
         } catch (ClassNotFoundException e) {
-            e.printStackTrace();
+            fail("Can not load the inner class MyProcess, the customization failed: \n" +
e.getMessage());
         }
     }
 
@@ -386,7 +386,7 @@
         while (size != -1) {
             bout.write(buffer, 0, size);
             index = bout.toString()
-                .indexOf("new QName(\"http://apache.org/hello_world_soap_http/service\","

+                .indexOf("new QName(\"http://apache.org/hello_world_soap_http/service\","
                         + " \"SOAPService_Test1\")");
             if (index > 0) {
                 break;
@@ -424,28 +424,28 @@
         File address = new File(ws, "addressing");
         assertTrue(address.exists());
     }
-    
-    
+
+
     @Test
     public void testDefatultNsMapExclude() throws Exception {
         env.put(ToolConstants.CFG_ALL, ToolConstants.CFG_ALL);
-        env.put(ToolConstants.CFG_NEXCLUDE, 
+        env.put(ToolConstants.CFG_NEXCLUDE,
                 "http://www.w3.org/2005/08/addressing=org.apache.cxf.ws.addressing");
         env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/cxf492/locator.wsdl"));
         processor.setContext(env);
         processor.execute();
-        
+
         File org = new File(output, "org");
         assertTrue("org directory is not exist", org.exists());
         File apache = new File(org, "apache");
         assertTrue(apache.exists());
         File ws = new File(output, "org/apache/cxf/ws/addressing");
         assertFalse(ws.exists());
-        
+
         File orginal = new File(output, "org.w3._2005._08.addressing");
         assertFalse(orginal.exists());
     }
-    
+
     @Test
     public void testHelloWorldExternalBindingFile() throws Exception {
         Server server = new Server(8585);
@@ -457,18 +457,18 @@
         env.put(ToolConstants.CFG_BINDING, "http://localhost:8585/remote-hello_world_binding.xsd");
         processor.setContext(env);
         processor.execute();
-        server.stop();      
-        
+        server.stop();
+
     }
-    
-    
+
+
     @Test
     public void testDefaultNSWithPkg() throws Exception {
         String[] args = new String[] {"-d", output.getCanonicalPath(), "-p", "org.cxf",
                                       getLocation("/wsdl2java_wsdl/basic_callback.wsdl")};
 
         WSDLToJava.main(args);
-        
+
         assertNotNull(output);
         File org = new File(output, "org");
         assertTrue(org.exists());
@@ -483,43 +483,43 @@
 
         File[] files = address.listFiles();
         assertEquals(11, files.length);
-        
+
         cxf = new File(output, "org/cxf");
         assertTrue(cxf.exists());
         files = cxf.listFiles();
         assertEquals(5, files.length);
 
     }
-    
+
     @Test
     public void testCXF677() throws Exception {
         String[] args = new String[] {"-d", output.getCanonicalPath(),
-                                      "-b", 
+                                      "-b",
                                       getLocation("/wsdl2java_wsdl/hello-mime-binding.xml"),
                                       getLocation("/wsdl2java_wsdl/hello-mime.wsdl")};
 
-        WSDLToJava.main(args); 
-        assertFileEquals(getClass().getResource("expected/expected_hello_mime").getFile(),

+        WSDLToJava.main(args);
+        assertFileEquals(getClass().getResource("expected/expected_hello_mime").getFile(),
                          output.getCanonicalPath() + "/org/apache/hello_world_mime/Hello.java");
 
 
 
     }
-    
-    
+
+
     @Test
     public void testWebResult() throws Exception {
 
         env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/sayHi.wsdl"));
         processor.setContext(env);
         processor.execute();
-        
-        assertFileEquals(getClass().getResource("expected/expected_sayHi").getFile(), 
+
+        assertFileEquals(getClass().getResource("expected/expected_sayHi").getFile(),
                          output.getCanonicalPath() + "/org/apache/sayhi/SayHi.java");
-        
+
     }
-    
-    
+
+
     @Test
     public void testCXF627() throws Exception {
 
@@ -527,13 +527,13 @@
         env.put(ToolConstants.CFG_BINDING, getLocation("/wsdl2java_wsdl/bug627/async_binding.xml"));
         processor.setContext(env);
         processor.execute();
-        
-        
+
+
         Class clz = classLoader.loadClass("org.apache.hello_world_soap_http.Greeter");
-        assertEquals(3, clz.getDeclaredMethods().length); 
+        assertEquals(3, clz.getDeclaredMethods().length);
 
     }
-    
+
     @Test
     //Test for CXF-765
     public void testClientServer() throws Exception {
@@ -544,7 +544,7 @@
         env.put(ToolConstants.CFG_GEN_CLIENT, ToolConstants.CFG_GEN_CLIENT);
         processor.setContext(env);
         processor.execute();
-        
+
         File file = new File(output, "org/apache/hello_world_soap_http");
         assertEquals(4, file.list().length);
         file = new File(output, "org/apache/hello_world_soap_http/DocLitBare_DocLitBarePort_Client.java");



Mime
View raw message