1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
/**
* RpcParamsServiceTestCase.java
*
* This file was auto-generated from WSDL
* by the Apache Axis WSDL2Java emitter.
*/
package test.wsdl.rpcParams;
import javax.xml.rpc.ServiceException;
import junit.framework.TestCase;
public class RpcParamsServiceTestCase extends TestCase {
public RpcParamsServiceTestCase(String name) {
super(name);
}
public void testRpcParamsWSDL() throws Exception {
javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
java.net.URL url = new java.net.URL(new test.wsdl.rpcParams.RpcParamsServiceLocator().getRpcParamsAddress() + "?WSDL");
javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.rpcParams.RpcParamsServiceLocator().getServiceName());
assertTrue(service != null);
}
/**
* Send parameters in the order that they are specified in
* the wsdl. Also omits null parameters.
*/
public void testEcho() throws Exception {
RpcParamsBindingStub binding = getBinding();
EchoStruct result;
// test sending both
result = binding.echo("first", "second");
assertNotNull("returned struct is null", result);
assertEquals("first parameter marshalled wrong when both sent", "first", result.getFirst());
assertEquals("second parameter marshalled wrong when both sent", "second", result.getSecond());
// test ommitting the first, since it's null
result = binding.echo(null, "second");
assertNotNull("returned struct is null", result);
assertNull("first parameter should be null", result.getFirst());
assertEquals("second parameter marshalled wrong first is null", "second", result.getSecond());
// test ommitting the second, since it's null
result = binding.echo("first", null);
assertNotNull("returned struct is null", result);
assertEquals("first parameter marshalled wrong when second is null", "first", result.getFirst());
assertNull("second parameter should be null", result.getSecond());
// test ommitting both, since they're null
result = binding.echo(null, null);
assertNotNull("returned struct is null", result);
assertNull("first parameter should be null", result.getFirst());
assertNull("second parameter should be null", result.getSecond());
}
/**
* Send parameters in the reverse order that they are specified in
* the wsdl. Also omits null parameters.
*/
public void testEchoReverse() throws Exception {
RpcParamsBindingStub binding = getBinding();
EchoStruct result;
// test sending both
result = binding.echoReverse("first", "second");
assertNotNull("returned struct is null", result);
assertEquals("first parameter marshalled wrong when both sent", "first", result.getFirst());
assertEquals("second parameter marshalled wrong when both sent", "second", result.getSecond());
// test ommitting the first, since it's null
result = binding.echoReverse(null, "second");
assertNotNull("returned struct is null", result);
assertNull("first parameter should be null", result.getFirst());
assertEquals("second parameter marshalled wrong first is null", "second", result.getSecond());
// test ommitting the second, since it's null
result = binding.echoReverse("first", null);
assertNotNull("returned struct is null", result);
assertEquals("first parameter marshalled wrong when second is null", "first", result.getFirst());
assertNull("second parameter should be null", result.getSecond());
// test ommitting both, since they're null
result = binding.echoReverse(null, null);
assertNotNull("returned struct is null", result);
assertNull("first parameter should be null", result.getFirst());
assertNull("second parameter should be null", result.getSecond());
}
private RpcParamsBindingStub getBinding() {
RpcParamsBindingStub binding = null;
try {
binding = (RpcParamsBindingStub) new RpcParamsServiceLocator().getRpcParams();
}
catch (ServiceException jre) {
if(jre.getLinkedCause()!=null)
jre.getLinkedCause().printStackTrace();
fail("JAX-RPC ServiceException caught: " + jre);
}
assertNotNull("binding is null", binding);
// Time out after a minute
binding.setTimeout(60000);
return binding;
}
}
|