You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by de...@apache.org on 2009/07/18 21:11:45 UTC

svn commit: r795420 - in /webservices/axis2/trunk/java/modules/integration: test-resources/generics/ test/org/apache/axis2/generics/

Author: deepal
Date: Sat Jul 18 19:11:45 2009
New Revision: 795420

URL: http://svn.apache.org/viewvc?rev=795420&view=rev
Log:
Applying the generic patch 

Added:
    webservices/axis2/trunk/java/modules/integration/test-resources/generics/
    webservices/axis2/trunk/java/modules/integration/test-resources/generics/generics.wsdl
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/GenericService.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/GenericServiceTest.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/GenericWSDLGenerationTest.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/Person.java

Added: webservices/axis2/trunk/java/modules/integration/test-resources/generics/generics.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test-resources/generics/generics.wsdl?rev=795420&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test-resources/generics/generics.wsdl (added)
+++ webservices/axis2/trunk/java/modules/integration/test-resources/generics/generics.wsdl Sat Jul 18 19:11:45 2009
@@ -0,0 +1,227 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+                  xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+                  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:ns1="http://org.apache.axis2/xsd"
+                  xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+                  xmlns:ax21="http://generics.axis2.apache.org/xsd" xmlns:ns="http://generics.axis2.apache.org"
+                  xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+                  targetNamespace="http://generics.axis2.apache.org">
+    <wsdl:types>
+        <xs:schema xmlns:ax22="http://generics.axis2.apache.org/xsd" attributeFormDefault="qualified"
+                   elementFormDefault="qualified" targetNamespace="http://generics.axis2.apache.org">
+            <xs:import namespace="http://generics.axis2.apache.org/xsd"/>
+            <xs:element name="processStringList">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="values" nillable="true" type="xs:string"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="processStringListResponse">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="processStringArray">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="values" nillable="true" type="ns:String"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:complexType name="String">
+                <xs:sequence>
+                    <xs:element maxOccurs="unbounded" minOccurs="0" name="array" nillable="true" type="xs:string"/>
+                </xs:sequence>
+            </xs:complexType>
+            <xs:element name="processPersonList">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="persons" nillable="true"
+                                    type="ax22:Person"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="processPersonListResponse">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element minOccurs="0" name="return" nillable="true" type="ax22:Person"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+            <xs:element name="getStringListResponse">
+                <xs:complexType>
+                    <xs:sequence>
+                        <xs:element maxOccurs="unbounded" minOccurs="0" name="return" nillable="true" type="xs:string"/>
+                    </xs:sequence>
+                </xs:complexType>
+            </xs:element>
+        </xs:schema>
+        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified"
+                   targetNamespace="http://generics.axis2.apache.org/xsd">
+            <xs:complexType name="Person">
+                <xs:sequence>
+                    <xs:element minOccurs="0" name="age" type="xs:int"/>
+                    <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
+                </xs:sequence>
+            </xs:complexType>
+        </xs:schema>
+    </wsdl:types>
+    <wsdl:message name="processStringArrayRequest">
+        <wsdl:part name="parameters" element="ns:processStringArray"/>
+    </wsdl:message>
+    <wsdl:message name="processStringListRequest">
+        <wsdl:part name="parameters" element="ns:processStringList"/>
+    </wsdl:message>
+    <wsdl:message name="processStringListResponse">
+        <wsdl:part name="parameters" element="ns:processStringListResponse"/>
+    </wsdl:message>
+    <wsdl:message name="getStringListRequest"/>
+    <wsdl:message name="getStringListResponse">
+        <wsdl:part name="parameters" element="ns:getStringListResponse"/>
+    </wsdl:message>
+    <wsdl:message name="processPersonListRequest">
+        <wsdl:part name="parameters" element="ns:processPersonList"/>
+    </wsdl:message>
+    <wsdl:message name="processPersonListResponse">
+        <wsdl:part name="parameters" element="ns:processPersonListResponse"/>
+    </wsdl:message>
+    <wsdl:portType name="GenericServicePortType">
+        <wsdl:operation name="processStringArray">
+            <wsdl:input message="ns:processStringArrayRequest" wsaw:Action="urn:processStringArray"/>
+        </wsdl:operation>
+        <wsdl:operation name="processStringList">
+            <wsdl:input message="ns:processStringListRequest" wsaw:Action="urn:processStringList"/>
+            <wsdl:output message="ns:processStringListResponse" wsaw:Action="urn:processStringListResponse"/>
+        </wsdl:operation>
+        <wsdl:operation name="getStringList">
+            <wsdl:input message="ns:getStringListRequest" wsaw:Action="urn:getStringList"/>
+            <wsdl:output message="ns:getStringListResponse" wsaw:Action="urn:getStringListResponse"/>
+        </wsdl:operation>
+        <wsdl:operation name="processPersonList">
+            <wsdl:input message="ns:processPersonListRequest" wsaw:Action="urn:processPersonList"/>
+            <wsdl:output message="ns:processPersonListResponse" wsaw:Action="urn:processPersonListResponse"/>
+        </wsdl:operation>
+    </wsdl:portType>
+    <wsdl:binding name="GenericServiceSoap11Binding" type="ns:GenericServicePortType">
+        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+        <wsdl:operation name="processStringArray">
+            <soap:operation soapAction="urn:processStringArray" style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+        </wsdl:operation>
+        <wsdl:operation name="processStringList">
+            <soap:operation soapAction="urn:processStringList" style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+        <wsdl:operation name="getStringList">
+            <soap:operation soapAction="urn:getStringList" style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+        <wsdl:operation name="processPersonList">
+            <soap:operation soapAction="urn:processPersonList" style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:binding name="GenericServiceSoap12Binding" type="ns:GenericServicePortType">
+        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+        <wsdl:operation name="processStringArray">
+            <soap12:operation soapAction="urn:processStringArray" style="document"/>
+            <wsdl:input>
+                <soap12:body use="literal"/>
+            </wsdl:input>
+        </wsdl:operation>
+        <wsdl:operation name="processStringList">
+            <soap12:operation soapAction="urn:processStringList" style="document"/>
+            <wsdl:input>
+                <soap12:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap12:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+        <wsdl:operation name="getStringList">
+            <soap12:operation soapAction="urn:getStringList" style="document"/>
+            <wsdl:input>
+                <soap12:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap12:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+        <wsdl:operation name="processPersonList">
+            <soap12:operation soapAction="urn:processPersonList" style="document"/>
+            <wsdl:input>
+                <soap12:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap12:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:binding name="GenericServiceHttpBinding" type="ns:GenericServicePortType">
+        <http:binding verb="POST"/>
+        <wsdl:operation name="processStringArray">
+            <http:operation location="processStringArray"/>
+            <wsdl:input>
+                <mime:content type="text/xml" part="processStringArray"/>
+            </wsdl:input>
+        </wsdl:operation>
+        <wsdl:operation name="processStringList">
+            <http:operation location="processStringList"/>
+            <wsdl:input>
+                <mime:content type="text/xml" part="processStringList"/>
+            </wsdl:input>
+            <wsdl:output>
+                <mime:content type="text/xml" part="processStringList"/>
+            </wsdl:output>
+        </wsdl:operation>
+        <wsdl:operation name="getStringList">
+            <http:operation location="getStringList"/>
+            <wsdl:input>
+                <mime:content type="text/xml" part="getStringList"/>
+            </wsdl:input>
+            <wsdl:output>
+                <mime:content type="text/xml" part="getStringList"/>
+            </wsdl:output>
+        </wsdl:operation>
+        <wsdl:operation name="processPersonList">
+            <http:operation location="processPersonList"/>
+            <wsdl:input>
+                <mime:content type="text/xml" part="processPersonList"/>
+            </wsdl:input>
+            <wsdl:output>
+                <mime:content type="text/xml" part="processPersonList"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:service name="GenericService">
+        <wsdl:port name="GenericServiceHttpSoap11Endpoint" binding="ns:GenericServiceSoap11Binding">
+            <soap:address location="http://localhost:8080/axis2/services/GenericService"/>
+        </wsdl:port>
+        <wsdl:port name="GenericServiceHttpSoap12Endpoint" binding="ns:GenericServiceSoap12Binding">
+            <soap12:address location="http://localhost:8080/axis2/services/GenericService"/>
+        </wsdl:port>
+        <wsdl:port name="GenericServiceHttpEndpoint" binding="ns:GenericServiceHttpBinding">
+            <http:address location="http://localhost:8080/axis2/services/GenericService"/>
+        </wsdl:port>
+    </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/GenericService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/GenericService.java?rev=795420&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/GenericService.java (added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/GenericService.java Sat Jul 18 19:11:45 2009
@@ -0,0 +1,46 @@
+/*
+ * 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.axis2.generics;
+
+import java.util.List;
+import java.util.ArrayList;
+
+public class GenericService {
+
+    public String processStringList(List<String> values) {
+        return values.get(0);
+    }
+
+    public List<String> getStringList() {
+        List<String> values = new ArrayList<String>();
+        values.add("test1");
+        values.add("test2");
+        values.add("test3");
+        return values;
+    }
+
+    public Person processPersonList(List<Person> persons) {
+        return persons.get(0);
+    }
+
+    public void processStringArray(List<String[]> values) {
+
+    }
+}

Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/GenericServiceTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/GenericServiceTest.java?rev=795420&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/GenericServiceTest.java (added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/GenericServiceTest.java Sat Jul 18 19:11:45 2009
@@ -0,0 +1,122 @@
+/*
+ * 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.axis2.generics;
+
+import org.apache.axis2.integration.RPCLocalTestCase;
+import org.apache.axis2.rpc.client.RPCServiceClient;
+import org.apache.axis2.AxisFault;
+
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+
+public class GenericServiceTest extends RPCLocalTestCase {
+
+//    private SimpleDateFormat zulu = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+    //  0123456789 0 123456789
+
+    protected boolean finish = false;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        deployClassAsService("GenericService", GenericService.class);
+    }
+
+    public void testProcessStringList() throws AxisFault {
+        RPCServiceClient sender = getRPCClient("GenericService", "processStringList");
+        ArrayList<StringArray> args = new ArrayList<StringArray>();
+        args.add(new StringArray());
+
+        Object[] value = sender.invokeBlocking(new QName("http://generics.axis2.apache.org", "processStringList", "req"), args.toArray(),
+                new Class[]{String.class});
+        assertEquals(value[0], "Test1");
+    }
+
+    public void testGetStringList() throws AxisFault {
+        RPCServiceClient sender = getRPCClient("GenericService", "getStringList");
+        ArrayList<StringArray> args = new ArrayList<StringArray>();
+        args.add(new StringArray());
+
+        ArrayList<Class<String>> resobj = new ArrayList<Class<String>>();
+        resobj.add(String.class);
+        resobj.add(String.class);
+        resobj.add(String.class);
+
+
+        Object[] value = sender.invokeBlocking(new QName("http://generics.axis2.apache.org", "getStringList", "req"), args.toArray(),
+                (Class[]) resobj.toArray(new Class[resobj.size()]));
+        assertEquals(value[0], "test1");
+        assertEquals(value[1], "test2");
+        assertEquals(value[2], "test3");
+    }
+
+
+    public void testProcessPersonList() throws AxisFault {
+        RPCServiceClient sender = getRPCClient("GenericService", "processPersonList");
+        ArrayList<PersonArray> args = new ArrayList<PersonArray>();
+        args.add(new PersonArray());
+
+        Object[] value = sender.invokeBlocking(new QName("http://generics.axis2.apache.org", "processPersonList", "req"), args.toArray(),
+                new Class[]{Person.class});
+        Person person = (Person) value[0];
+        assertNotNull(person);
+        assertEquals(person.getAge(), 10);
+    }
+
+    class StringArray {
+        private ArrayList<String> values;
+
+        StringArray() {
+            values = new ArrayList<String>();
+            values.add("Test1");
+            values.add("Test2");
+            values.add("Test3");
+            values.add("Test4");
+
+        }
+
+        public ArrayList<String> getValues() {
+            return values;
+        }
+
+        public void setValues(ArrayList<String> values) {
+            this.values = values;
+        }
+    }
+
+    class PersonArray {
+        private ArrayList<Person> values;
+
+        PersonArray() {
+            values = new ArrayList<Person>();
+            values.add(new Person("P1", 10));
+            values.add(new Person("P2", 20));
+            values.add(new Person("P3", 30));
+
+        }
+
+        public ArrayList<Person> getValues() {
+            return values;
+        }
+
+        public void setValues(ArrayList<Person> values) {
+            this.values = values;
+        }
+    }
+}

Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/GenericWSDLGenerationTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/GenericWSDLGenerationTest.java?rev=795420&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/GenericWSDLGenerationTest.java (added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/GenericWSDLGenerationTest.java Sat Jul 18 19:11:45 2009
@@ -0,0 +1,57 @@
+/*
+ * 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.axis2.generics;
+
+import junit.framework.TestCase;
+import org.custommonkey.xmlunit.XMLTestCase;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.custommonkey.xmlunit.Diff;
+import org.apache.ws.java2wsdl.Java2WSDLBuilder;
+import org.tempuri.complex.ComplexDataTypes;
+import org.tempuri.differenceEngine.WSDLDifferenceEngine;
+import org.tempuri.differenceEngine.WSDLController;
+import org.tempuri.elementQualifier.WSDLElementQualifier;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FileReader;
+import java.io.StringReader;
+
+public class GenericWSDLGenerationTest   extends XMLTestCase {
+
+    private String wsdlLocation = System.getProperty("basedir", ".") + "/" + "test-resources/generics/generics.wsdl";
+
+    public void test1() throws Exception {
+        XMLUnit.setIgnoreWhitespace(true);
+        try {
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            Java2WSDLBuilder builder = new Java2WSDLBuilder(out, GenericService.class.getName(), GenericService.class.getClassLoader());
+            builder.generateWSDL();
+            FileReader control = new FileReader(wsdlLocation);
+            StringReader test = new StringReader(new String(out.toByteArray()));
+            Diff myDiff = new Diff(XMLUnit.buildDocument(XMLUnit.getControlParser(), control),
+		               XMLUnit.buildDocument(XMLUnit.getControlParser(), test),
+		               new WSDLDifferenceEngine(new WSDLController()), new WSDLElementQualifier());
+            if (!myDiff.similar())
+	            fail(myDiff.toString());
+        } finally {
+            XMLUnit.setIgnoreWhitespace(false);
+        }
+    }
+}
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/Person.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/Person.java?rev=795420&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/Person.java (added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/generics/Person.java Sat Jul 18 19:11:45 2009
@@ -0,0 +1,48 @@
+/*
+ * 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.axis2.generics;
+
+public class Person {
+    private String name;
+    private int age;
+
+    public Person() {
+    }
+
+    public Person(String name, int age) {
+        this.name = name;
+        this.age = age;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+}