ws-ews-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From guilla...@apache.org
Subject svn commit: r230790 [9/9] - in /webservices/ews/trunk/mapper: ./ src/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/ws/ src/java/org/apache/ws/ews/ src/java/org/apache/ws/ews/context/ src/java/org/apache/ws/ews/context/webservices/ s...
Date Mon, 08 Aug 2005 12:28:41 GMT
Added: webservices/ews/trunk/mapper/src/test-resources/heavyweight/BookQuote.xml
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/mapper/src/test-resources/heavyweight/BookQuote.xml?rev=230790&view=auto
==============================================================================
--- webservices/ews/trunk/mapper/src/test-resources/heavyweight/BookQuote.xml (added)
+++ webservices/ews/trunk/mapper/src/test-resources/heavyweight/BookQuote.xml Mon Aug  8 05:28:03
2005
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<java-wsdl-mapping
+	xmlns="http://java.sun.com/xml/ns/j2ee"
+	xmlns:mh="http://www.Monson-Haefel.com/jwsbook/BookQuote"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+	http://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd"
+	version="1.1">
+	<package-mapping>
+		<package-type>com.jwsbook.jaxrpc</package-type>
+		<namespaceURI>
+			http://www.Monson-Haefel.com/jwsbook/BookQuote
+		</namespaceURI>
+	</package-mapping>
+	<exception-mapping>
+		<exception-type>com.jwsbook.jaxrpc.InvalidIsbnException</exception-type>
+		<wsdl-message>mh:InvalidIsbnFault</wsdl-message>
+	</exception-mapping>
+	<service-interface-mapping>
+		<service-interface>com.jwsbook.jaxrpc.BookQuoteService</service-interface>
+		<wsdl-service-name>mh:BookQuoteService</wsdl-service-name>
+		<port-mapping>
+			<port-name>mh:BookQuotePort</port-name>
+			<java-port-name>BookQuotePort</java-port-name>
+		</port-mapping>
+	</service-interface-mapping>
+	<service-endpoint-interface-mapping>
+		<service-endpoint-interface>com.jwsbook.jaxrpc.BookQuote
+		</service-endpoint-interface>
+		<wsdl-port-type>mh:BookQuote</wsdl-port-type>
+		<wsdl-binding>mh:BookQuoteBinding</wsdl-binding>
+		<service-endpoint-method-mapping>
+			<java-method-name>getBookPrice</java-method-name>
+			<wsdl-operation>getBookPrice</wsdl-operation>
+			<method-param-parts-mapping>
+				<param-position>0</param-position>
+				<param-type>java.lang.String</param-type>
+				<wsdl-message-mapping>
+					<wsdl-message>mh:BookQuote_getBookPriceRequest</wsdl-message>
+					<wsdl-message-part-name>isbn</wsdl-message-part-name>
+					<parameter-mode>IN</parameter-mode>
+				</wsdl-message-mapping>
+			</method-param-parts-mapping>
+			<wsdl-return-value-mapping>
+				<method-return-value>float</method-return-value>
+				<wsdl-message>mh:BookQuote_getBookPriceResponse</wsdl-message>
+				<wsdl-message-part-name>result</wsdl-message-part-name>
+			</wsdl-return-value-mapping>
+		</service-endpoint-method-mapping>
+	</service-endpoint-interface-mapping>
+</java-wsdl-mapping>
\ No newline at end of file

Added: webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/AbstractTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/AbstractTestCase.java?rev=230790&view=auto
==============================================================================
--- webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/AbstractTestCase.java (added)
+++ webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/AbstractTestCase.java Mon
Aug  8 05:28:03 2005
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.ws.ews.mapper;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+/**
+ * Abstract base class for test cases.
+ *
+ * @author <a href="jason@zenplex.com">Jason van Zyl</a>
+ */
+public abstract class AbstractTestCase
+	extends TestCase
+{
+	protected String testDir = "src/test/";
+	protected String resDir = "src/test-resources/";
+	/**
+	 * Basedir for all file I/O. Important when running tests from
+	 * the reactor.
+	 */
+	public String basedir = System.getProperty("basedir");
+
+	/**
+	 * Constructor.
+	 */
+	public AbstractTestCase(String testName)
+	{
+		super(testName);
+	}
+
+	/**
+	 * Get test input file.
+	 *
+	 * @param path Path to test input file.
+	 */
+	public String getTestFile(String path)
+	{
+		return new File(basedir, path).getAbsolutePath();
+	}
+
+    /**
+     * Get test input file.
+     *
+     * @param path Path to test input file.
+     */
+    public String getTestResource(String path)
+    {
+        return getTestFile(resDir + path);
+    }
+}
+

Added: webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/AnonymousTypesTest.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/AnonymousTypesTest.java?rev=230790&view=auto
==============================================================================
--- webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/AnonymousTypesTest.java
(added)
+++ webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/AnonymousTypesTest.java
Mon Aug  8 05:28:03 2005
@@ -0,0 +1,118 @@
+package org.apache.ws.ews.mapper;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: sauthieg
+ * Date: Aug 5, 2005
+ * Time: 10:49:48 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class AnonymousTypesTest extends JAXRPCMapperTestCase {
+
+    public AnonymousTypesTest(String name) {
+        super(name);
+    }
+
+    public void setUp() throws Exception {
+        super.setUp();
+        mapper.loadMappingFromDir(getTestResource(getJAXRPCMappingFileName()));
+    }
+
+    protected String getJAXRPCMappingFileName() {
+        return "anonymous/mapping.xml";
+    }
+
+    public void testGetPackageMappingCount() throws Exception {
+        int count = mapper.getPackageMappingCount();
+        assertEquals("Package mapping count incorrrect", 1, count);
+    }
+
+    public void testGetPackageMappingClassName() throws Exception {
+       String pkg = mapper.getPackageMappingClassName(0);
+        assertEquals("wrong package name", "org.apache.ws.ews", pkg);
+    }
+
+    public void testGetPackageMappingURI() throws Exception {
+        String uri = mapper.getPackageMappingURI(0);
+        assertEquals("wrong namespace", "X", uri);
+    }
+
+    public void testGetJavaType() throws Exception {
+        QName case1 = new QName("X", "root");
+        QName case2 = new QName("X", "root");
+        QName case3 = new QName("X", "root[0,unbounded]");
+        QName case4 = new QName("X", ">root");
+        QName case5 = new QName("X", ">root>inside");
+        QName case6 = new QName("X", ">root>inside[,10]");
+        QName case9 = new QName("X", "someOtherElement");
+        QName case8 = new QName("X", "someOtherElement[,20]");
+        QName case7 = new QName("X", ">>root>inside");
+
+        String type1 = mapper.getJavaType(case1);
+        assertEquals("org.apache.ws.ews.Root", type1);
+
+        // no support for qname-scope for now
+        /*
+        String type2 = mapper.getJavaType(case2);
+        assertEquals("org.apache.ws.ews.Root[]", type2);
+        */
+
+        String type3 = mapper.getJavaType(case3);
+        assertEquals("org.apache.ws.ews.Root[]", type3);
+
+        String type4 = mapper.getJavaType(case4);
+        assertEquals("org.apache.ws.ews.Root", type4);
+
+        String type5 = mapper.getJavaType(case5);
+        assertEquals("org.apache.ws.ews.Inside", type5);
+
+        String type6 = mapper.getJavaType(case6);
+        assertEquals("org.apache.ws.ews.Inside[]", type6);
+
+        String type7 = mapper.getJavaType(case7);
+        assertEquals("org.apache.ws.ews.Inside", type7);
+
+        String type8 = mapper.getJavaType(case8);
+        assertEquals("int[]", type8);
+
+        String type9 = mapper.getJavaType(case9);
+        assertEquals("int", type9);
+
+
+
+    }
+
+    public void testGetExceptionType() {
+        // no applicable for this mapping
+    }
+
+    public void testGetPortName() {
+        // no applicable for this mapping
+    }
+
+    public void testGetServiceInterfaceName() {
+        // no applicable for this mapping
+    }
+
+    public void testGetServiceEndpointInterfaceName() {
+        // no applicable for this mapping
+    }
+
+    public void testGetJavaMethodParamType() {
+        // no applicable for this mapping
+    }
+
+    public void testGetJavaMethodReturnType() {
+        // no applicable for this mapping
+    }
+
+    public void testGetJavaMethodName() {
+        // no applicable for this mapping
+    }
+
+    public void testHasWrappedElement() {
+        // no applicable for this mapping
+    }
+}

Added: webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/FrenchZipTest.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/FrenchZipTest.java?rev=230790&view=auto
==============================================================================
--- webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/FrenchZipTest.java (added)
+++ webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/FrenchZipTest.java Mon
Aug  8 05:28:03 2005
@@ -0,0 +1,94 @@
+package org.apache.ws.ews.mapper;
+
+import javax.xml.namespace.QName;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.factory.WSDLFactory;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: sauthieg
+ * Date: Aug 5, 2005
+ * Time: 1:14:34 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class FrenchZipTest extends JAXRPCMapperTestCase {
+
+    private QName pt = null;
+    private QName b = null;
+    private QName s = null;
+
+    public FrenchZipTest(String name) {
+        super(name);
+    }
+
+    public void setUp() throws Exception {
+        super.setUp();
+        mapper.loadMappingFromDir(getTestResource(getJAXRPCMappingFileName()));
+        pt = new QName("http://tempuri.org/", "IODCODESPOSTAUX");
+        b = new QName("http://tempuri.org/", "IODCODESPOSTAUXbinding");
+        s = new QName("http://tempuri.org/", "IODCODESPOSTAUXservice");
+    }
+
+    protected String getJAXRPCMappingFileName() {
+        return "frenchzip/FrenchZipMapping.xml";
+    }
+
+    public void testGetPackageMappingCount() throws Exception {
+        int count = mapper.getPackageMappingCount();
+        assertEquals("Package mapping count incorrrect", 1, count);
+    }
+
+    public void testGetPackageMappingClassName() throws Exception {
+        String pkg = mapper.getPackageMappingClassName(0);
+        assertEquals("wrong package name", "org.objectweb.jonas.zip", pkg);
+    }
+
+    public void testGetPackageMappingURI() throws Exception {
+        String uri = mapper.getPackageMappingURI(0);
+        assertEquals("wrong namespace", "http://tempuri.org/", uri);
+    }
+
+    public void testGetJavaType() throws Exception {
+        // no type mapping here, the service use only string, int, ...
+    }
+
+    public void testGetExceptionType() throws Exception {
+        // not applicable
+    }
+
+    public void testGetPortName() throws Exception {
+        String port = mapper.getPortName("IODCODESPOSTAUXPort");
+        assertEquals("Java port name incorrect", "ZipPort", port);
+    }
+
+    public void testGetServiceInterfaceName() throws Exception {
+        String si = mapper.getServiceInterfaceName(s);
+        assertEquals("Wrong Java service interface name", "org.objectweb.jonas.zip.ZipService",
si);
+    }
+
+    public void testGetServiceEndpointInterfaceName() throws Exception {
+        String sei = mapper.getServiceEndpointInterfaceName(pt, b);
+        assertEquals("Wrong Java service endpoint interface name", "org.objectweb.jonas.zip.Zip",
sei);
+    }
+
+    public void testGetJavaMethodParamType() throws Exception {
+        String type = mapper.getJavaMethodParamType(b, pt, "GetDepartmentForCode", 0);
+        assertEquals("Wrong Method param type", "java.lang.String", type);
+    }
+
+    public void testGetJavaMethodReturnType() throws Exception {
+        String type = mapper.getJavaMethodReturnType(b, pt, "GetDepartmentForCode");
+        assertEquals("Wrong Method Return type", "java.lang.String", type);
+    }
+
+    public void testGetJavaMethodName() throws Exception {
+        String jmn = mapper.getJavaMethodName(b, pt, "GetDepartmentForCode");
+        assertEquals("Wrong Java Method name", "getMyDepartmentFromGivenPostalCode", jmn);
+    }
+
+    public void testHasWrappedElement() throws Exception {
+        boolean w = mapper.hasWrappedElement();
+        assertFalse("WSDL not wrapped", w);
+    }
+}

Added: webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/JAXRPCMapperTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/JAXRPCMapperTestCase.java?rev=230790&view=auto
==============================================================================
--- webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/JAXRPCMapperTestCase.java
(added)
+++ webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/JAXRPCMapperTestCase.java
Mon Aug  8 05:28:03 2005
@@ -0,0 +1,86 @@
+package org.apache.ws.ews.mapper;
+
+import org.apache.ws.ews.mapper.jaxrpc.JaxRpcMapper;
+import org.apache.ws.ews.mapper.jaxrpc.XMLBeansJaxRpcMapper;
+import org.apache.axis.wsdl.symbolTable.ServiceEntry;
+import org.apache.axis.wsdl.symbolTable.PortTypeEntry;
+import org.apache.axis.wsdl.symbolTable.BindingEntry;
+
+import javax.xml.namespace.QName;
+import javax.wsdl.Port;
+import javax.wsdl.Operation;
+import java.io.InputStream;
+import java.io.FileInputStream;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: sauthieg
+ * Date: Aug 5, 2005
+ * Time: 10:35:32 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public abstract class JAXRPCMapperTestCase extends AbstractTestCase {
+
+    protected JaxRpcMapper mapper = null;
+
+    public JAXRPCMapperTestCase(String name) {
+        super(name);
+    }
+
+    public void setUp() throws Exception {
+        super.setUp();
+        mapper = new XMLBeansJaxRpcMapper();
+    }
+
+    public void tearDown() throws Exception {
+        mapper = null;
+        super.tearDown();
+    }
+
+    public void testLoadMappingFromInputStream() throws Exception {
+        String mapping = getTestResource(getJAXRPCMappingFileName());
+        try {
+            mapper.loadMappingFromInputStream(new FileInputStream(mapping));
+        } catch (MapperFault f) {
+            fail("Cannot load Mapping file '" + mapping + "' from an InputStream");
+        }
+    }
+
+    protected abstract String getJAXRPCMappingFileName();
+
+    public void testLoadMappingFromDir() throws Exception {
+        String mapping = getTestResource(getJAXRPCMappingFileName());
+        try {
+            mapper.loadMappingFromDir(mapping);
+        } catch (MapperFault f) {
+            fail("Cannot load Mapping file '" + mapping + "' from a File");
+        }
+    }
+
+    public abstract void testGetPackageMappingCount() throws Exception;
+
+    public abstract void testGetPackageMappingClassName() throws Exception;
+
+    public abstract void testGetPackageMappingURI() throws Exception;
+
+    public abstract void testGetJavaType() throws Exception;
+
+    public abstract void testGetExceptionType() throws Exception;
+
+    public abstract void testGetPortName() throws Exception;
+
+    public abstract void testGetServiceInterfaceName() throws Exception;
+
+    public abstract void testGetServiceEndpointInterfaceName() throws Exception;
+
+    public abstract void testGetJavaMethodParamType() throws Exception;
+
+    public abstract void testGetJavaMethodReturnType() throws Exception;
+
+    public abstract void testGetJavaMethodName() throws Exception;
+
+    public abstract void testHasWrappedElement() throws Exception;
+
+
+}
+

Added: webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/MapperTest.java
URL: http://svn.apache.org/viewcvs/webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/MapperTest.java?rev=230790&view=auto
==============================================================================
--- webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/MapperTest.java (added)
+++ webservices/ews/trunk/mapper/src/test/org/apache/ws/ews/mapper/MapperTest.java Mon Aug
 8 05:28:03 2005
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.ws.ews.mapper;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.ws.ews.mapper.WsdlToJ2ee;
+
+/**
+ * Unit test for simple App.
+ *
+ * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
+ */
+public class MapperTest 
+	extends AbstractTestCase
+{
+	/**
+	 * Create the test case
+	 *
+	 * @param testName name of the test case
+	 */
+	public MapperTest( String testName )
+	{
+		super( testName );
+	}
+
+	/**
+	 * @return the suite of tests being tested
+	 */
+	public static Test suite()
+	{
+		TestSuite suite = new TestSuite();
+		suite.addTest(TestSuite.createTest(MapperTest.class,"testHeavyWeight"));
+		//suite.addTest(TestSuite.createTest(MapperTest.class,"testLightWeight"));
+		suite.addTest(TestSuite.createTest(MapperTest.class,"testGoogle"));
+		suite.addTest(TestSuite.createTest(MapperTest.class,"testFrenchZip"));
+		//suite.addTest(TestSuite.createTest(MapperTest.class,"testAnonymousTypes"));
+		return suite;
+	}
+
+
+	/**
+	 * Rigourous Test :-)
+	 */
+	public void testHeavyWeight() throws Exception {
+		String[] args = new String[]{"-m", getTestFile(resDir +"heavyweight/BookQuote.xml"),
+									 "-o", getTestFile("target/generated/samples/mapper/heavyweight"),
+									 getTestFile(resDir +"heavyweight/BookQuote.wsdl")};
+		WsdlToJ2ee.main(args);
+	}
+
+	public void testLightWeight() throws Exception {
+		String[] args = new String[]{"-m", getTestFile(resDir +"lightweight/BookQuote.xml"),
+									 "-o", getTestFile("target/generated/samples/mapper/lightweight"),
+									 getTestFile(resDir +"lightweight/BookQuote.wsdl")};
+		WsdlToJ2ee.main(args);
+	}
+
+	public void testGoogle() throws Exception {
+		String[] args = new String[]{"-m",getTestFile(resDir +"google/GoogleSearch.xml"),
+									 "-o", getTestFile("target/generated/samples/mapper/google"),
+									 getTestFile(resDir +"google/GoogleSearch.wsdl")};
+		WsdlToJ2ee.main(args);
+	}
+
+	public void testFrenchZip() throws Exception {
+		String[] args = new String[]{"-m",getTestFile(resDir +"frenchzip/FrenchZipMapping.xml"),
+									 "-o", getTestFile("target/generated/samples/mapper/frenchzip"),
+									 getTestFile(resDir +"frenchzip/FrenchZip.wsdl")};
+		WsdlToJ2ee.main(args);
+	}
+
+	  public void testAnonymousTypes() throws Exception {
+		  String[] args = new String[]{"-m",getTestFile(resDir +"anonymous/mapping.xml"),
+									   "-o", getTestFile("target/generated/samples/mapper/anonymous"),
+									   getTestFile(resDir +"anonymous/anonymous.wsdl")};
+		  WsdlToJ2ee.main(args);
+	  }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: ews-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: ews-dev-help@ws.apache.org


Mime
View raw message