You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2002/01/30 04:59:29 UTC
cvs commit: xml-axis/java/test/wsdl/inheritance InheritancePortType.java InheritanceTest.wsdl InheritanceTestCase.java InheritanceTestSoapBindingImpl.java StockQuoteProvider.java
scheu 02/01/29 19:59:29
Modified: java/test/wsdl Java2WsdlAntTask.java Wsdl2javaTestSuite.xml
Added: java/test/wsdl/inheritance InheritancePortType.java
InheritanceTest.wsdl InheritanceTestCase.java
InheritanceTestSoapBindingImpl.java
StockQuoteProvider.java
Log:
The following test was submitted by Brent Ulbricht of IBM.
This tests the Java2WSDL useInheritedMethods feature, which
examines inherited methods when building a portType.
Revision Changes Path
1.5 +8 -0 xml-axis/java/test/wsdl/Java2WsdlAntTask.java
Index: Java2WsdlAntTask.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/wsdl/Java2WsdlAntTask.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Java2WsdlAntTask.java 26 Jan 2002 14:40:51 -0000 1.4
+++ Java2WsdlAntTask.java 30 Jan 2002 03:59:29 -0000 1.5
@@ -76,6 +76,7 @@
private String service = null ;
private String implClass = null;
private String factory = null;
+ private boolean useInheritedMethods = false;
// The method executing the task
public void execute() throws BuildException {
@@ -88,6 +89,7 @@
log("\tclassName:" + className, Project.MSG_VERBOSE);
log("\timplClass:" + implClass, Project.MSG_VERBOSE);
log("\tfactory:" + factory, Project.MSG_VERBOSE);
+ log("\tinheritance:" + useInheritedMethods, Project.MSG_VERBOSE);
// Instantiate the emitter
Emitter emitter = new Emitter();
@@ -105,6 +107,7 @@
emitter.setFactory(factory);
emitter.setIntfNamespace(namespace);
emitter.setLocationUrl(location);
+ emitter.setUseInheritedMethods(useInheritedMethods);
emitter.emit(output, Emitter.MODE_ALL);
} catch (Throwable t) {
throw new BuildException("Error while running " + getClass().getName(), t);
@@ -144,6 +147,11 @@
// The setter for the "namespace" attribute
public void setNamespace(String parameter) {
this.namespace = parameter;
+ }
+
+ // The setter for the "useInheritedMethods" attribute
+ public void setUseInheritedMethods(boolean parameter) {
+ this.useInheritedMethods = parameter;
}
/** the command arguments */
1.63 +55 -0 xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml
Index: Wsdl2javaTestSuite.xml
===================================================================
RCS file: /home/cvs/xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- Wsdl2javaTestSuite.xml 30 Jan 2002 03:34:10 -0000 1.62
+++ Wsdl2javaTestSuite.xml 30 Jan 2002 03:59:29 -0000 1.63
@@ -150,6 +150,61 @@
<mapping namespace="urn:ArrayTest2" package="test.wsdl.arrays"/>
</wsdl2java>
+ <!-- Inheritance Test -->
+ <!-- Bootstrap to generate Java From WSDL to get stubs/skeletons -->
+ <wsdl2java url="test/wsdl/inheritance/InheritanceTest.wsdl"
+ output="build/work"
+ deployscope="session"
+ skeleton="yes"
+ noimports="no"
+ verbose="no"
+ testcase="no">
+ <mapping namespace="urn:InheritanceTest2" package="test.wsdl.inheritance"/>
+ </wsdl2java>
+ <!-- To test inheritance, the InheritancePortType is changed to use inheritance -->
+ <copy todir="${build.dir}/work/test/wsdl/inheritance" overwrite="yes">
+ <fileset dir="${test.dir}/wsdl/inheritance">
+ <include name="InheritancePortType.java"/>
+ <include name="StockQuoteProvider.java"/>
+ </fileset>
+ </copy>
+ <!-- Compile the Web Service -->
+ <javac srcdir="${build.dir}/work" destdir="${build.dest}" debug="${debug}">
+ <classpath refid="test-classpath" />
+ <include name="test/wsdl/inheritance/**.java" />
+ <exclude name="test/wsdl/inheritance/*TestCase.java" />
+ <exclude name="test/wsdl/inheritance/*Impl.java" />
+ </javac>
+ <!-- Now create the WSDL file specifying useInheritedMethods -->
+ <java2wsdl output="build/work/test/wsdl/inheritance/InheritanceTest.wsdl"
+ className= "test.wsdl.inheritance.InheritancePortType"
+ namespace="urn:InheritanceTest2"
+ useInheritedMethods="true"
+ location="http://localhost:8080/axis/services/InheritanceTest">
+ <mapping namespace="urn:InheritanceTest2" package="test.wsdl.inheritance"/>
+ </java2wsdl>
+ <!-- Delete the intermediate files so we recreate over a clean slate -->
+ <delete dir="${build.dir}/classes/test/wsdl/inheritance"/>
+ <!-- Recreate Java files from the new WSDL -->
+ <wsdl2java url="build/work/test/wsdl/inheritance/InheritanceTest.wsdl"
+ output="build/work"
+ deployscope="session"
+ skeleton="yes"
+ noimports="no"
+ verbose="no"
+ testcase="no">
+ <mapping namespace="urn:InheritanceTest2" package="test.wsdl.inheritance"/>
+ </wsdl2java>
+
+ <!-- MArrayTests Test -->
+ <wsdl2java url="test/wsdl/marrays/MArrayTest.wsdl"
+ output="build/work"
+ deployscope="session"
+ skeleton="yes"
+ testcase="yes">
+ <mapping namespace="urn:MArrayTests" package="test.wsdl.marrays"/>
+ </wsdl2java>
+
<!-- MArrayTests Test -->
<wsdl2java url="test/wsdl/marrays/MArrayTest.wsdl"
output="build/work"
1.1 xml-axis/java/test/wsdl/inheritance/InheritancePortType.java
Index: InheritancePortType.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package test.wsdl.inheritance;
/**
* The InheritancePortType interface defines the methods necessary when
* when implementing this interface. Note that this interface extends
* the StockQuoteProvider interface.
*
* @version 1.00 21 Jan 2002
* @author Brent Ulbricht
*/
public interface InheritancePortType extends test.wsdl.inheritance.StockQuoteProvider {
public float getRealtimeLastTradePrice(String tickerSymbol)
throws java.rmi.RemoteException;
}
1.1 xml-axis/java/test/wsdl/inheritance/InheritanceTest.wsdl
Index: InheritanceTest.wsdl
===================================================================
<?xml version="1.0" ?>
<!-- This WSDL contains the WSDL for testing inherited service definition interfaces -->
<definitions name="urn:InheritanceTest"
targetNamespace="urn:InheritanceTest2"
xmlns:tns="urn:InheritanceTest2"
xmlns:typens="urn:InheritanceTest2"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<!-- message declns -->
<message name="getRealtimeLastTradePriceResponse">
<part name="price" type="xsd:float"/>
</message>
<message name="getRealtimeLastTradePriceRequest">
<part name="tickerSymbol" type="xsd:string"/>
</message>
<message name="getLastTradePriceRequest">
<part name="tickerSymbol" type="xsd:string"/>
</message>
<message name="getLastTradePriceResponse">
<part name="price" type="xsd:float"/>
</message>
<!-- port type declns -->
<portType name="InheritancePortType">
<operation name="getLastTradePrice">
parameterOrder="tickerSymbol">
<input message="tns:getLastTradePriceRequest"/>
<output message="tns:getLastTradePriceResponse"/>
</operation>
<operation name="getRealtimeLastTradePrice">
<input message="tns:getRealtimeLastTradePriceRequest"/>
<output message="tns:getRealtimeLastTradePriceResponse"/>
</operation>
</portType>
<!-- binding declns -->
<binding name="InheritanceSoapBinding" type="tns:InheritancePortType">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getLastTradePrice">
<soap:operation soapAction=""/>
<input>
<soap:body use="encoded"
namespace="urn:InheritanceTest"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
namespace="urn:InheritanceTest"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="getRealtimeLastTradePrice">
<soap:operation soapAction=""/>
<input>
<soap:body use="encoded"
namespace="urn:InheritanceTest"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
namespace="urn:InheritanceTest"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<!-- service decln -->
<service name="InheritanceTest">
<port name="InheritanceTest" binding="tns:InheritanceSoapBinding">
<soap:address location="http://localhost:8080/axis/services/InheritanceTest"/>
</port>
</service>
</definitions>
1.1 xml-axis/java/test/wsdl/inheritance/InheritanceTestCase.java
Index: InheritanceTestCase.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package test.wsdl.inheritance;
import javax.xml.rpc.JAXRPCException;
/**
* This class contains the methods necessary for testing that the use inherited methods
* function in the Java2WSDL tool works as specified.
*
* When using the Java2WSDL tool with the use inherited methods switch on, the tool
* should generate the appropriate classes to include all of the inherited methods
* of the specified interface (in addition to the actual methods in the interface).
*
* @version 1.00 21 Jan 2002
* @author Brent Ulbricht
*/
public class InheritanceTestCase extends junit.framework.TestCase {
/**
* Constructor used in all tests utilizing the Junit Framework.
*/
public InheritanceTestCase(String name) {
super(name);
} // Constructor
/**
* This method insures that two methods (getLastTradePrice and getRealtimeLastTradePrice)
* can be called, and they return the expected stock values. The main goal is to verify
* that the getLastTradePrice method does not cause any compile errors and returns the
* expected stock value.
*
* The getLastTradePrice method originates from the test/wsdl/inheritance/StockQuoteProvider
* interface. The InheritancePortType interface extends the StockQuoteProvider interface.
*
* When the WSDL is generated for the InheritancePortType interface and the use inherited
* methods switch is used, all methods from the StockQuoteProvider and InheritancePortType
* interfaces should be available for service.
*/
public void testInheritanceTest() {
test.wsdl.inheritance.InheritancePortType binding;
try {
binding = new InheritanceTest().getInheritanceTest();
}
catch (JAXRPCException jre) {
throw new junit.framework.AssertionFailedError("JAX-RPC Exception caught: " + jre);
}
assertTrue("binding is null", binding != null);
// The getLastTradePrice method should return a value of 20.25 when sent the tickerSymbol
// "SOAP".
try {
float expected = 20.25F;
float actual = binding.getLastTradePrice(new java.lang.String("SOAP"));
float delta = 0.0F;
assertEquals("The actual and expected values did not match.", expected, actual, delta);
} catch (java.rmi.RemoteException re) {
throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re );
}
// The getRealtimeLastTradePrice method should return a value of 21.75 when sent the
// tickerSymbol "AXIS".
try {
float expected = 21.75F;
float actual = binding.getRealtimeLastTradePrice(new java.lang.String("AXIS"));
float delta = 0.0F;
assertEquals("The actual and expected values did not match.", expected, actual, delta);
} catch (java.rmi.RemoteException re) {
throw new junit.framework.AssertionFailedError("Remote Exception caught: " + re );
}
} // testInheritanceTest
} // InheritanceTestCase
1.1 xml-axis/java/test/wsdl/inheritance/InheritanceTestSoapBindingImpl.java
Index: InheritanceTestSoapBindingImpl.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package test.wsdl.inheritance;
/**
* This class contains the remote method implementations for the
* inheritance test.
*
* @version 1.00 21 Jan 2002
* @author Brent Ulbricht
*/
public class InheritanceTestSoapBindingImpl implements test.wsdl.inheritance.InheritancePortType {
/**
* This method will return a hard coded value to the client depending on the value of the
* tickerSymbol received.
*
* The getLastTradePrice originates from the InheritancePortType interface.
*/
public float getLastTradePrice(java.lang.String tickerSymbol) throws java.rmi.RemoteException {
if (tickerSymbol.equals("SOAP")) {
return 20.25F;
} else {
return 0.00F;
}
} // getLastTradePrice
/**
* This method will return a hard coded value to the client depending on the value of the
* tickerSymbol received.
*
* The getRealtimeLastTradePrice originates from the StockQuoteProvider interface.
*/
public float getRealtimeLastTradePrice(java.lang.String tickerSymbol) throws java.rmi.RemoteException {
if (tickerSymbol.equals("AXIS")) {
return 21.75F;
} else {
return 0.00F;
}
} // getRealtimeLastTradePrice
} // End class InheritanceTestSoapBindingImpl
1.1 xml-axis/java/test/wsdl/inheritance/StockQuoteProvider.java
Index: StockQuoteProvider.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package test.wsdl.inheritance;
/**
* The StockQuoteProvider interface defines the methods necessary when
* when implementing this interface.
*
* @version 1.00 21 Jan 2002
* @author Brent Ulbricht
*/
public interface StockQuoteProvider extends java.rmi.Remote {
public float getLastTradePrice(String tickerSymbol)
throws java.rmi.RemoteException;
}