tomj 2002/09/25 14:00:38
Added: java/test/wsdl/esr build.xml esr.wsdl
EsrTestBindingImpl.java EsrTestServiceTestCase.java
Log:
New test for bug 12636 - DII call with multiple parameters.
Revision Changes Path
1.1 xml-axis/java/test/wsdl/esr/build.xml
Index: build.xml
===================================================================
<?xml version="1.0" ?>
<!DOCTYPE project [
<!ENTITY properties SYSTEM "file:../../../xmls/properties.xml">
<!ENTITY paths SYSTEM "file:../../../xmls/path_refs.xml">
<!ENTITY taskdefs SYSTEM "file:../../../xmls/taskdefs.xml">
<!ENTITY taskdefs_post_compile SYSTEM
"file:../../../xmls/taskdefs_post_compile.xml">
<!ENTITY targets SYSTEM "file:../../../xmls/targets.xml">
]>
<!-- ===================================================================
<description>
Test/Sample Component file for Axis
Notes:
This is a build file for use with the Jakarta Ant build tool.
Prerequisites:
jakarta-ant from http://jakarta.apache.org
Build Instructions:
To compile
ant compile
To execute
ant run
Author:
Matt Seibert [EMAIL PROTECTED]
Copyright:
Copyright (c) 2002-2003 Apache Software Foundation.
</description>
==================================================================== -->
<project default="compile">
<property name="axis.home" location="../../.." />
<property name="componentName" value="test/wsdl/esr" />
&properties;
&paths;
&taskdefs;
&taskdefs_post_compile;
&targets;
<target name="clean">
<echo message="Removing ${build.dir}/classes/${componentName} and
${build.dir}/work/${componentName}" />
<delete dir="${build.dir}/classes/${componentName}"/>
<delete dir="${build.dir}/work/${componentName}"/>
</target>
<target name="copy" depends="setenv"/>
<target name="compile" depends="copy">
<echo message="Compiling test.wsdl.esr"/>
<!-- This is a DII test with multiple output params -->
<wsdl2java url="${axis.home}/test/wsdl/esr/esr.wsdl"
output="${axis.home}/build/work"
serverSide="yes"
skeletonDeploy="yes"
helperGen="yes"
testcase="yes">
</wsdl2java>
<copy todir="${build.dir}/work/test/wsdl/esr" overwrite="yes">
<fileset dir="${axis.home}/test/wsdl/esr">
<include name="*TestCase.java"/>
<include name="*Impl.java"/>
</fileset>
</copy>
<javac srcdir="${build.dir}/work" destdir="${build.dest}" fork="${javac.fork}"
debug="${debug}">
<classpath refid="classpath" />
<include name="test/wsdl/esr/*.java" />
<include name="test/wsdl/esr/**/*.java" />
</javac>
</target>
<target name="run" >
<antcall target="execute-Component" />
</target>
</project>
1.1 xml-axis/java/test/wsdl/esr/esr.wsdl
Index: esr.wsdl
===================================================================
<?xml version="1.0" ?>
<definitions
name="esr types test"
targetNamespace="urn:esr.wsdl.test"
xmlns:tns="urn:esr.wsdl.test"
xmlns:typens="urn:comprehensive-types.types.wsdl.test"
xmlns:typens2="urn:comprehensive-types2.types.wsdl.test"
xmlns:xsd="http://www.w3.org/2001/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='EsrTest.esrRequest'>
<part name='value' type='xsd:short'/>
</message>
<message name='EsrTest.esrResponse'>
<part name='echoVal' type='xsd:short'/>
<part name='sqrtVal' type='xsd:double'/>
</message>
<!-- port type declns -->
<portType name='EsrTest'>
<operation name='esrInOut' parameterOrder='value echoVal sqrtVal'>
<input message='tns:EsrTest.esrRequest' />
<output message='tns:EsrTest.esrResponse' />
</operation>
</portType>
<!-- binding declns -->
<binding name="EsrTestBinding" type="tns:EsrTest">
<soap:binding
style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="esrInOut">
<soap:operation soapAction=""/>
<input>
<soap:body
use="encoded"
namespace=""
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body
use="encoded"
namespace=""
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<!-- service decln -->
<service name="EsrTestService">
<port name="EsrTest" binding="tns:EsrTestBinding">
<soap:address location="http://localhost:8080/axis/services/EsrTest"/>
</port>
</service>
</definitions>
1.1 xml-axis/java/test/wsdl/esr/EsrTestBindingImpl.java
Index: EsrTestBindingImpl.java
===================================================================
/**
* EsrTestBindingImpl.java
*
* Test for bug 12636
*/
package test.wsdl.esr;
public class EsrTestBindingImpl implements test.wsdl.esr.EsrTest{
public void esrInOut(short value, javax.xml.rpc.holders.ShortHolder echoVal,
javax.xml.rpc.holders.DoubleHolder sqrtVal) throws java.rmi.RemoteException {
echoVal.value = (short)value;
sqrtVal.value = Math.sqrt(value);
}
}
1.1 xml-axis/java/test/wsdl/esr/EsrTestServiceTestCase.java
Index: EsrTestServiceTestCase.java
===================================================================
/**
* EsrTestServiceTestCase.java
*
* Test for bug 12636
* Uses the Service interface to deal with WSDL instead of stubs.
*/
package test.wsdl.esr;
import org.apache.axis.transport.http.SimpleAxisWorker;
import javax.xml.namespace.QName;
public class EsrTestServiceTestCase extends junit.framework.TestCase {
public EsrTestServiceTestCase(java.lang.String name) {
super(name);
}
public void test1EsrTestEsrInOut() {
// Using WSDL file to make a SOAP call
try {
String thisHost = SimpleAxisWorker.getLocalHost();
String thisPort = System.getProperty("test.functional.ServicePort",
"8080");
//load wsdl file
String wsdlLocation = "http://" + thisHost + ":" + thisPort +
"/axis/services/EsrTest?WSDL";
javax.xml.rpc.Service svc =
new org.apache.axis.client.Service(
wsdlLocation,
new javax.xml.namespace.QName("urn:esr.wsdl.test",
"EsrTestService")
);
//setting up the call
javax.xml.rpc.Call call = svc.createCall(
new javax.xml.namespace.QName("urn:esr.wsdl.test",
"EsrTest"),
new javax.xml.namespace.QName("urn:esr.wsdl.test",
"esrInOut")
);
//init in params
Object[] soapInParams = new Object[]{new Short((short) 5)};
//calling soap service
Object ret = call.invoke(soapInParams);
//printing output params
java.util.Map outParams = call.getOutputParams();
// Debug code if you need it
/*
java.util.Collection outs = outParams.values();
java.util.Iterator it = outs.iterator();
int i = 1;
while (it.hasNext()) {
System.out.println(i++ + ". " + it.next().toString());
}
*/
// Expecting a short and a double back
assertEquals("Number of output parameters is wrong", outParams.size(),
2);
Object s = outParams.get(new QName("echoVal"));
assertNotNull("echoVal paramter is null", s);
assertEquals("echoVal parameter is incorrect", (Short)s, new
Short((short) 5) );
Object sq = outParams.get(new QName("sqrtVal"));
assertNotNull("sqrtVal paramter is null", sq);
assertEquals("sqrtVal parameter is incorrect",
((Double)sq).doubleValue(), Math.sqrt(5), 0.001D );
} catch (Exception e) {
e.printStackTrace(System.out);
throw new junit.framework.AssertionFailedError("Exception caught: " + e);
}
}
}