01: package org.objectweb.celtix.systest.js;
02:
03: import java.lang.reflect.UndeclaredThrowableException;
04: import java.net.URL;
05: import javax.xml.namespace.QName;
06:
07: import junit.framework.Test;
08: import junit.framework.TestSuite;
09:
10: import org.objectweb.celtix.systest.common.ClientServerSetupBase;
11: import org.objectweb.celtix.systest.common.ClientServerTestBase;
12:
13: import org.objectweb.hello_world_soap_http.Greeter;
14: import org.objectweb.hello_world_soap_http.SOAPService;
15: import org.objectweb.hello_world_soap_http.SOAPServiceTest1;
16:
17: public class JSClientServerTest extends ClientServerTestBase {
18:
19: private static final String NS = "http://objectweb.org/hello_world_soap_http";
20:
21: public static Test suite() throws Exception {
22: TestSuite suite = new TestSuite(JSClientServerTest.class);
23: return new ClientServerSetupBase(suite) {
24: public void startServers() throws Exception {
25: assertTrue("server did not launch correctly",
26: launchServer(Server.class));
27: }
28: };
29: }
30:
31: public void testJSMessageMode() throws Exception {
32: QName serviceName = new QName(NS, "SOAPService");
33: QName portName = new QName(NS, "SoapPort");
34:
35: URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
36: assertNotNull(wsdl);
37:
38: SOAPService service = new SOAPService(wsdl, serviceName);
39: assertNotNull(service);
40:
41: String response1 = new String("TestGreetMeResponse");
42: String response2 = new String("TestSayHiResponse");
43: try {
44: Greeter greeter = service.getPort(portName, Greeter.class);
45: String greeting = greeter.greetMe("TestGreetMeRequest");
46: assertNotNull("no response received from service", greeting);
47: assertEquals(response1, greeting);
48:
49: String reply = greeter.sayHi();
50: assertNotNull("no response received from service", reply);
51: assertEquals(response2, reply);
52: } catch (UndeclaredThrowableException ex) {
53: ex.printStackTrace();
54: throw (Exception) ex.getCause();
55: }
56: }
57:
58: public void testJSPayloadMode() throws Exception {
59: URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
60: assertNotNull(wsdl);
61:
62: QName serviceName = new QName(NS, "SOAPServiceTest1");
63: QName portName = new QName(NS, "SoapPort_Test1");
64:
65: SOAPServiceTest1 service = new SOAPServiceTest1(wsdl,
66: serviceName);
67: assertNotNull(service);
68:
69: String response1 = new String("TestGreetMeResponse");
70: String response2 = new String("TestSayHiResponse");
71: try {
72: Greeter greeter = service.getPort(portName, Greeter.class);
73: String greeting = greeter.greetMe("TestGreetMeRequest");
74: assertNotNull("no response received from service", greeting);
75: assertEquals(response1, greeting);
76:
77: String reply = greeter.sayHi();
78: assertNotNull("no response received from service", reply);
79: assertEquals(response2, reply);
80: } catch (UndeclaredThrowableException ex) {
81: ex.printStackTrace();
82: throw (Exception) ex.getCause();
83: }
84: }
85:
86: public static void main(String[] args) {
87: junit.textui.TestRunner.run(JSClientServerTest.class);
88: }
89: }
|