01: package org.objectweb.celtix.systest.routing;
02:
03: import java.lang.reflect.UndeclaredThrowableException;
04: import java.net.URL;
05:
06: import javax.xml.namespace.QName;
07:
08: import junit.framework.TestCase;
09:
10: import org.objectweb.hello_world_doc_lit.Greeter;
11: import org.objectweb.hello_world_doc_lit.PingMeFault;
12: import org.objectweb.hello_world_doc_lit.SOAPService;
13: import org.objectweb.hello_world_doc_lit.types.FaultDetail;
14:
15: public class DocLitGreeterRouterBase extends TestCase {
16: protected Greeter greeter;
17: protected QName serviceName;
18: protected QName portName;
19: protected boolean enableOneway = true;
20:
21: protected void setUp() throws Exception {
22: super .setUp();
23: URL wsdl = getClass().getResource(
24: "/wsdl/hello_world_doc_lit.wsdl");
25: assertNotNull(wsdl);
26: SOAPService service = new SOAPService(wsdl, serviceName);
27: assertNotNull(service);
28:
29: greeter = service.getPort(portName, Greeter.class);
30: }
31:
32: public void testBasic() throws Exception {
33: String response1 = new String("Hello Milestone-");
34: String response2 = new String("Bonjour");
35: try {
36: for (int idx = 0; idx < 10; idx++) {
37: String greeting = greeter.greetMe("Milestone-" + idx);
38: assertNotNull("no response received from service",
39: greeting);
40: String exResponse = response1 + idx;
41: assertEquals(exResponse, greeting);
42:
43: if (enableOneway) {
44: greeter.greetMeOneWay("Milestone-" + idx);
45: }
46:
47: String reply = greeter.sayHi();
48: assertNotNull("no response received from service",
49: reply);
50: assertEquals(response2, reply);
51: }
52: } catch (UndeclaredThrowableException ex) {
53: throw (Exception) ex.getCause();
54: }
55: }
56:
57: public void testFaults() throws Exception {
58:
59: for (int idx = 0; idx < 10; idx++) {
60: try {
61: greeter.pingMe();
62: fail("Should have thrown a PingMeFault exception");
63: } catch (PingMeFault pmf) {
64: FaultDetail fd = pmf.getFaultInfo();
65: assertNotNull("FaultDetail should havea valid value",
66: fd);
67: assertEquals(2, fd.getMajor());
68: assertEquals(1, fd.getMinor());
69: }
70: }
71: }
72: }
|