01: package org.objectweb.celtix.systest.xml_bare;
02:
03: import java.lang.reflect.UndeclaredThrowableException;
04: import java.net.*;
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: import org.objectweb.hello_world_xml_http.bare.Greeter;
13: import org.objectweb.hello_world_xml_http.bare.XMLService;
14: import org.objectweb.hello_world_xml_http.bare.types.MyComplexStruct;
15:
16: public class XMLBareSystemTest extends ClientServerTestBase {
17:
18: private static final String TEST_NAMESPACE = "http://objectweb.org/hello_world_xml_http/bare";
19: private final QName serviceName = new QName(TEST_NAMESPACE,
20: "XMLService");
21: private final QName portName = new QName(TEST_NAMESPACE, "XMLPort");
22:
23: public static Test suite() throws Exception {
24: TestSuite suite = new TestSuite(XMLBareSystemTest.class);
25: return new ClientServerSetupBase(suite) {
26: public void startServers() throws Exception {
27: assertTrue("server did not launch correctly",
28: launchServer(Server.class));
29: }
30: };
31: }
32:
33: public void testBasicConnection() throws Exception {
34: URL wsdl = getClass().getResource(
35: "/wsdl/hello_world_xml_bare.wsdl");
36: assertNotNull(wsdl);
37:
38: XMLService service = new XMLService(wsdl, serviceName);
39: assertNotNull(service);
40:
41: Greeter greeter = service.getPort(portName, Greeter.class);
42:
43: String response1 = new String("Hello Milestone-");
44: String response2 = new String("Bonjour");
45: MyComplexStruct argument = new MyComplexStruct();
46: MyComplexStruct retVal = null;
47:
48: try {
49: for (int idx = 0; idx < 5; idx++) {
50: String greeting = greeter.greetMe("Milestone-" + idx);
51: assertNotNull("no response received from service",
52: greeting);
53: String exResponse = response1 + idx;
54: assertEquals(exResponse, greeting);
55:
56: String reply = greeter.sayHi();
57: assertNotNull("no response received from service",
58: reply);
59: assertEquals(response2, reply);
60:
61: argument.setElem1("Hello Milestone-" + idx);
62: argument.setElem2("Bonjour-" + idx);
63: argument.setElem3(idx);
64:
65: retVal = null;
66: retVal = greeter.sendReceiveData(argument);
67:
68: assertNotNull("no response received from service",
69: retVal);
70: assertTrue(argument.getElem1()
71: .equals(retVal.getElem1()));
72: assertTrue(argument.getElem2()
73: .equals(retVal.getElem2()));
74: assertTrue(argument.getElem3() == retVal.getElem3());
75: }
76: } catch (UndeclaredThrowableException ex) {
77: throw (Exception) ex.getCause();
78: }
79: }
80:
81: public static void main(String[] args) {
82: junit.textui.TestRunner.run(XMLBareSystemTest.class);
83: }
84: }
|