cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject svn commit: r439178 - in /incubator/cxf/trunk/api: ./ src/main/java/org/apache/cxf/wsdl/ src/main/resources/schemas/wsdl/ src/test/java/org/apache/cxf/wsdl/ src/test/resources/wsdl/
Date Fri, 01 Sep 2006 04:54:02 GMT
Author: tli
Date: Thu Aug 31 21:54:02 2006
New Revision: 439178

URL: http://svn.apache.org/viewvc?rev=439178&view=rev
Log:
Add unit test for JAXBExtensionHelpter, fix a bug in JAXBExtensionHelper, Add xml binding
extension for wsdl4j

Added:
    incubator/cxf/trunk/api/src/main/resources/schemas/wsdl/wsdl4jext.xsd   (with props)
    incubator/cxf/trunk/api/src/test/java/org/apache/cxf/wsdl/
    incubator/cxf/trunk/api/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java
  (with props)
    incubator/cxf/trunk/api/src/test/resources/wsdl/
    incubator/cxf/trunk/api/src/test/resources/wsdl/hello_world_xml_bare.wsdl   (with props)
Modified:
    incubator/cxf/trunk/api/pom.xml
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java

Modified: incubator/cxf/trunk/api/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/pom.xml?rev=439178&r1=439177&r2=439178&view=diff
==============================================================================
--- incubator/cxf/trunk/api/pom.xml (original)
+++ incubator/cxf/trunk/api/pom.xml Thu Aug 31 21:54:02 2006
@@ -91,6 +91,10 @@
                                     </dependencies>
                                 </xsdOption>
                                 <xsdOption>
+                                    <xsd>${basedir}/src/main/resources/schemas/wsdl/wsdl4jext.xsd</xsd>
+                                    <packagename>org.apache.cxf.bindings.xformat</packagename>
+                                </xsdOption>
+                                <xsdOption>
                                     <xsd>${basedir}/src/main/resources/schemas/wsdl/ws-addr.xsd</xsd>
                                     <packagename>org.apache.cxf.ws.addressing</packagename>
                                 </xsdOption>

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java?rev=439178&r1=439177&r2=439178&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java Thu
Aug 31 21:54:02 2006
@@ -86,9 +86,16 @@
                         QName elementType = new QName(elementDecl.namespace(), elementDecl.name());
                         registry.registerDeserializer(parentType, elementType, helper); 
                         registry.registerSerializer(parentType, elementType, helper);   
                     
+                        registry.mapExtensionTypes(parentType, elementType, cls);       
                
+                        registry.createExtension(parentType, elementType);
                     }                    
                 }
-            }
+            }        
+            
+        } catch (WSDLException we) {
+            // TODO
+            we.printStackTrace();            
+
         } catch (ClassNotFoundException ex) {
             // TODO
             ex.printStackTrace();            

Added: incubator/cxf/trunk/api/src/main/resources/schemas/wsdl/wsdl4jext.xsd
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/resources/schemas/wsdl/wsdl4jext.xsd?rev=439178&view=auto
==============================================================================
--- incubator/cxf/trunk/api/src/main/resources/schemas/wsdl/wsdl4jext.xsd (added)
+++ incubator/cxf/trunk/api/src/main/resources/schemas/wsdl/wsdl4jext.xsd Thu Aug 31 21:54:02
2006
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+	xmlns:tns="http://cxf.apache.org/bindings/xformat"
+	targetNamespace="http://cxf.apache.org/bindings/xformat"
+	elementFormDefault="qualified"
+	xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0">
+
+	<xs:attribute name="required" type="xs:boolean" />
+
+	<xs:complexType name="tExtensibilityElement" abstract="true">
+		<xs:annotation>
+			<xs:appinfo>
+				<jaxb:class
+					implClass="org.apache.cxf.wsdl.TExtensibilityElementImpl" />
+			</xs:appinfo>
+		</xs:annotation>
+		<xs:attribute ref="tns:required" use="optional" />
+	</xs:complexType>
+
+
+	<xs:complexType name="XMLBindingMessageFormat">
+		<xs:complexContent>
+			<xs:extension base="tns:tExtensibilityElement">
+				<xs:sequence />
+				<xs:attribute name="rootNode" type="xs:string"
+					use="required" />
+			</xs:extension>
+		</xs:complexContent>
+	</xs:complexType>
+
+	<xs:element name="body" type="tns:XMLBindingMessageFormat" />
+
+</xs:schema>

Propchange: incubator/cxf/trunk/api/src/main/resources/schemas/wsdl/wsdl4jext.xsd
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/trunk/api/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java?rev=439178&view=auto
==============================================================================
--- incubator/cxf/trunk/api/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java
(added)
+++ incubator/cxf/trunk/api/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java
Thu Aug 31 21:54:02 2006
@@ -0,0 +1,97 @@
+/**
+ * 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.wsdl;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import javax.wsdl.Binding;
+import javax.wsdl.BindingInput;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Definition;
+import javax.wsdl.extensions.ExtensionRegistry;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+public class JAXBExtensionHelperTest extends TestCase {
+
+    private WSDLFactory wsdlFactory;
+
+    private WSDLReader wsdlReader;
+
+    private Definition wsdlDefinition;
+
+    private ExtensionRegistry registry;
+
+    public void setUp() throws Exception {
+
+        wsdlFactory = WSDLFactory.newInstance();
+        wsdlReader = wsdlFactory.newWSDLReader();
+        wsdlReader.setFeature("javax.wsdl.verbose", false);
+        registry = wsdlReader.getExtensionRegistry();
+        if (registry == null) {
+            registry = wsdlFactory.newPopulatedExtensionRegistry();
+        }
+        JAXBExtensionHelper.addExtensions(registry, "javax.wsdl.BindingInput",
+                        "org.apache.cxf.bindings.xformat.XMLBindingMessageFormat", Thread.currentThread()
+                                        .getContextClassLoader());
+    }
+
+    public void tearDown() {
+
+    }
+
+    public void testAddExtension() throws Exception {
+
+        Class extClass = Class.forName("org.apache.cxf.bindings.xformat.XMLBindingMessageFormat");
+        
+        String file = this.getClass().getResource("/wsdl/hello_world_xml_bare.wsdl").getFile();
+        
+        wsdlReader.setExtensionRegistry(registry);
+                
+        wsdlDefinition = wsdlReader.readWSDL(file);
+
+        Binding b = wsdlDefinition.getBinding(new QName("http://objectweb.org/hello_world_xml_http/bare",
+                        "Greeter_XMLBinding"));
+        BindingOperation bo = b.getBindingOperation("sayHi", null, null);
+        BindingInput bi = bo.getBindingInput(); 
+        List extList = bi.getExtensibilityElements();
+        Object extIns = null;
+        for (Object ext : extList) {
+            extIns = extClass.cast(ext);
+        }
+        assertEquals("can't found ext element XMLBindingMessageFormat", true, extIns != null);
+        String rootNode = getRootNode(extIns);
+        assertEquals("get rootNode value back from extension element", "sayHi", rootNode);
+    }
+
+    private String getRootNode(Object ext) throws Exception {
+        for (int i = 0; i < ext.getClass().getMethods().length; i++) {
+            Method method = ext.getClass().getMethods()[i];
+            if (method.getName().equals("getRootNode")) {
+                return (String) method.invoke(ext, new Object[] {});
+            }
+        }
+        return null;
+    }
+}

Propchange: incubator/cxf/trunk/api/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/cxf/trunk/api/src/test/resources/wsdl/hello_world_xml_bare.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/resources/wsdl/hello_world_xml_bare.wsdl?rev=439178&view=auto
==============================================================================
--- incubator/cxf/trunk/api/src/test/resources/wsdl/hello_world_xml_bare.wsdl (added)
+++ incubator/cxf/trunk/api/src/test/resources/wsdl/hello_world_xml_bare.wsdl Thu Aug 31 21:54:02
2006
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions name="HelloWorld" targetNamespace="http://objectweb.org/hello_world_xml_http/bare"

+		  xmlns="http://schemas.xmlsoap.org/wsdl/"
+		  xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+		  xmlns:xformat="http://cxf.apache.org/bindings/xformat" 
+		  xmlns:tns="http://objectweb.org/hello_world_xml_http/bare"
+		  xmlns:x1="http://objectweb.org/hello_world_xml_http/bare/types"
+		  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
+		  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+  
+  <wsdl:types>
+    <schema targetNamespace="http://objectweb.org/hello_world_xml_http/bare/types" 
+	    xmlns="http://www.w3.org/2001/XMLSchema" 
+	    elementFormDefault="qualified">
+
+      <element name="responseType" type="xsd:string"/>
+      <element name="requestType" type="xsd:string"/>
+
+      <complexType name="myComplexStruct">
+	<sequence>
+	  <element name="elem1" type="xsd:string"/>
+	  <element name="elem2" type="xsd:string"/>
+	  <element name="elem3" type="xsd:int"/>
+	</sequence>
+      </complexType>
+    </schema>
+  </wsdl:types>
+  
+  <wsdl:message name="sayHiRequest"/>
+  
+  <wsdl:message name="sayHiResponse">
+    <wsdl:part type="xsd:string" name="out"/>
+  </wsdl:message>
+  
+  <wsdl:message name="greetMeRequest">
+    <wsdl:part element="x1:requestType" name="me"/>
+  </wsdl:message>
+  
+  <wsdl:message name="greetMeResponse">
+    <wsdl:part element="x1:responseType" name="theResponse"/>
+  </wsdl:message>
+  
+  <wsdl:message name="sendReceiveDataRequest">
+    <wsdl:part type="x1:myComplexStruct" name="in"/>
+  </wsdl:message>
+  
+  <wsdl:message name="sendReceiveDataResponse">
+    <wsdl:part type="x1:myComplexStruct" name="out"/>
+  </wsdl:message>
+  
+  <wsdl:portType name="Greeter">
+    <wsdl:operation name="sayHi">
+      <wsdl:input message="tns:sayHiRequest" name="sayHiRequest"/>
+      <wsdl:output message="tns:sayHiResponse" name="sayHiResponse"/>
+    </wsdl:operation>
+    <wsdl:operation name="greetMe">
+      <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
+      <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
+    </wsdl:operation>
+    <wsdl:operation name="sendReceiveData">
+      <wsdl:input message="tns:sendReceiveDataRequest" name="SendReceiveDataRequest"/>
+      <wsdl:output message="tns:sendReceiveDataResponse" name="SendReceiveDataResponse"/>
+    </wsdl:operation>
+  </wsdl:portType>
+  
+  <wsdl:binding name="Greeter_XMLBinding" type="tns:Greeter">
+    <xformat:binding/>
+    <wsdl:operation name="sayHi">
+      <wsdl:input>
+	<xformat:body rootNode="sayHi"/>
+      </wsdl:input>
+      <wsdl:output/>
+    </wsdl:operation>
+    
+    <wsdl:operation name="greetMe">
+      <wsdl:input/>
+      <wsdl:output/>
+    </wsdl:operation>
+    
+    <wsdl:operation name="sendReceiveData">
+      <wsdl:input/>
+      <wsdl:output/>
+    </wsdl:operation>
+  </wsdl:binding>
+  
+  <wsdl:service name="XMLService">
+    <wsdl:port binding="tns:Greeter_XMLBinding" name="XMLPort">
+      <http:address location="http://localhost:9000/XMLService/XMLPort"/>
+    </wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>

Propchange: incubator/cxf/trunk/api/src/test/resources/wsdl/hello_world_xml_bare.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/api/src/test/resources/wsdl/hello_world_xml_bare.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message