1 package org.objectweb.celtix.systest.basicRPCLit; 2 3 import java.lang.reflect.UndeclaredThrowableException ; 4 import java.net.URL ; 5 6 import javax.xml.namespace.QName ; 7 8 import junit.framework.Test; 9 import junit.framework.TestSuite; 10 11 import org.objectweb.celtix.systest.common.ClientServerSetupBase; 12 import org.objectweb.celtix.systest.common.ClientServerTestBase; 13 14 import org.objectweb.hello_world_rpclit.GreeterRPCLit; 15 import org.objectweb.hello_world_rpclit.SOAPServiceRPCLit; 16 import org.objectweb.hello_world_rpclit.types.MyComplexStruct; 17 18 public class RPCLitClientServerTest extends ClientServerTestBase { 19 20 private final QName serviceName = new QName ("http://objectweb.org/hello_world_rpclit", 21 "SOAPServiceRPCLit"); 22 private final QName portName = new QName ("http://objectweb.org/hello_world_rpclit", 23 "SoapPortRPCLit"); 24 25 26 public static Test suite() throws Exception { 27 TestSuite suite = new TestSuite(RPCLitClientServerTest.class); 28 return new ClientServerSetupBase(suite) { 29 public void startServers() throws Exception { 30 assertTrue("server did not launch correctly", launchServer(Server.class)); 31 } 32 }; 33 } 34 35 public void testBasicConnection() throws Exception { 36 37 URL wsdl = getClass().getResource("/wsdl/hello_world_rpc_lit.wsdl"); 38 assertNotNull(wsdl); 39 40 SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName); 41 assertNotNull(service); 42 43 String response1 = new String ("Hello Milestone-"); 44 String response2 = new String ("Bonjour"); 45 try { 46 GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class); 47 for (int idx = 0; idx < 5; idx++) { 48 String greeting = greeter.greetMe("Milestone-" + idx); 49 assertNotNull("no response received from service", greeting); 50 String exResponse = response1 + idx; 51 assertEquals(exResponse, greeting); 52 53 String reply = greeter.sayHi(); 54 assertNotNull("no response received from service", reply); 55 assertEquals(response2, reply); 56 } 57 } catch (UndeclaredThrowableException ex) { 58 throw (Exception )ex.getCause(); 59 } 60 } 61 62 public void testComplexType() throws Exception { 63 64 URL wsdl = getClass().getResource("/wsdl/hello_world_rpc_lit.wsdl"); 65 assertNotNull(wsdl); 66 67 SOAPServiceRPCLit service = new SOAPServiceRPCLit(wsdl, serviceName); 68 assertNotNull(service); 69 70 MyComplexStruct argument = new MyComplexStruct(); 71 MyComplexStruct retVal = null; 72 73 try { 74 GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class); 75 for (int idx = 0; idx < 5; idx++) { 76 argument.setElem1("Hello Milestone-" + idx); 77 argument.setElem2("Bonjour-" + idx); 78 argument.setElem3(idx); 79 80 retVal = greeter.sendReceiveData(argument); 81 assertNotNull("no response received from service", retVal); 82 83 assertTrue(argument.getElem1().equals(retVal.getElem1())); 84 assertTrue(argument.getElem2().equals(retVal.getElem2())); 85 assertTrue(argument.getElem3() == retVal.getElem3()); 86 87 retVal = null; 88 } 89 } catch (UndeclaredThrowableException ex) { 90 throw (Exception )ex.getCause(); 91 } 92 } 93 94 95 public static void main(String [] args) { 96 junit.textui.TestRunner.run(RPCLitClientServerTest.class); 97 } 98 } 99 | Popular Tags |