1 7 8 package test.wsdl.rpcParams; 9 10 import javax.xml.rpc.ServiceException ; 11 12 import junit.framework.TestCase; 13 14 public class RpcParamsServiceTestCase extends TestCase { 15 public RpcParamsServiceTestCase(String name) { 16 super(name); 17 } 18 19 public void testRpcParamsWSDL() throws Exception { 20 javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance(); 21 java.net.URL url = new java.net.URL (new test.wsdl.rpcParams.RpcParamsServiceLocator().getRpcParamsAddress() + "?WSDL"); 22 javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.rpcParams.RpcParamsServiceLocator().getServiceName()); 23 assertTrue(service != null); 24 } 25 26 30 public void testEcho() throws Exception { 31 RpcParamsBindingStub binding = getBinding(); 32 33 EchoStruct result; 34 result = binding.echo("first", "second"); 36 assertNotNull("returned struct is null", result); 37 assertEquals("first parameter marshalled wrong when both sent", "first", result.getFirst()); 38 assertEquals("second parameter marshalled wrong when both sent", "second", result.getSecond()); 39 40 result = binding.echo(null, "second"); 42 assertNotNull("returned struct is null", result); 43 assertNull("first parameter should be null", result.getFirst()); 44 assertEquals("second parameter marshalled wrong first is null", "second", result.getSecond()); 45 46 result = binding.echo("first", null); 48 assertNotNull("returned struct is null", result); 49 assertEquals("first parameter marshalled wrong when second is null", "first", result.getFirst()); 50 assertNull("second parameter should be null", result.getSecond()); 51 52 result = binding.echo(null, null); 54 assertNotNull("returned struct is null", result); 55 assertNull("first parameter should be null", result.getFirst()); 56 assertNull("second parameter should be null", result.getSecond()); 57 } 58 59 63 public void testEchoReverse() throws Exception { 64 RpcParamsBindingStub binding = getBinding(); 65 66 EchoStruct result; 67 result = binding.echoReverse("first", "second"); 69 assertNotNull("returned struct is null", result); 70 assertEquals("first parameter marshalled wrong when both sent", "first", result.getFirst()); 71 assertEquals("second parameter marshalled wrong when both sent", "second", result.getSecond()); 72 73 result = binding.echoReverse(null, "second"); 75 assertNotNull("returned struct is null", result); 76 assertNull("first parameter should be null", result.getFirst()); 77 assertEquals("second parameter marshalled wrong first is null", "second", result.getSecond()); 78 79 result = binding.echoReverse("first", null); 81 assertNotNull("returned struct is null", result); 82 assertEquals("first parameter marshalled wrong when second is null", "first", result.getFirst()); 83 assertNull("second parameter should be null", result.getSecond()); 84 85 result = binding.echoReverse(null, null); 87 assertNotNull("returned struct is null", result); 88 assertNull("first parameter should be null", result.getFirst()); 89 assertNull("second parameter should be null", result.getSecond()); 90 } 91 92 private RpcParamsBindingStub getBinding() { 93 RpcParamsBindingStub binding = null; 94 try { 95 binding = (RpcParamsBindingStub) new RpcParamsServiceLocator().getRpcParams(); 96 } 97 catch (ServiceException jre) { 98 if(jre.getLinkedCause()!=null) 99 jre.getLinkedCause().printStackTrace(); 100 fail("JAX-RPC ServiceException caught: " + jre); 101 } 102 assertNotNull("binding is null", binding); 103 104 binding.setTimeout(60000); 106 return binding; 107 } 108 } 109 | Popular Tags |