KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > celtix > systest > xml_bare > XMLBareSystemTest


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