1 package org.objectweb.celtix.systest.xml_bare; 2 3 import java.lang.reflect.UndeclaredThrowableException ; 4 import java.net.*; 5 import javax.xml.namespace.QName ; 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 TEST_NAMESPACE = "http://objectweb.org/hello_world_xml_http/bare"; 19 private final QName serviceName = new QName (TEST_NAMESPACE, "XMLService"); 20 private final QName portName = new QName (TEST_NAMESPACE, "XMLPort"); 21 22 public static Test suite() throws Exception { 23 TestSuite suite = new TestSuite(XMLBareSystemTest.class); 24 return new ClientServerSetupBase(suite) { 25 public void startServers() throws Exception { 26 assertTrue("server did not launch correctly", launchServer(Server.class)); 27 } 28 }; 29 } 30 31 public void testBasicConnection() throws Exception { 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 response1 = new String ("Hello Milestone-"); 41 String response2 = new String ("Bonjour"); 42 MyComplexStruct argument = new MyComplexStruct(); 43 MyComplexStruct retVal = null; 44 45 try { 46 for (int idx = 0; idx < 5; idx++) { 47 String greeting = greeter.greetMe("Milestone-" + idx); 48 assertNotNull("no response received from service", greeting); 49 String exResponse = response1 + idx; 50 assertEquals(exResponse, greeting); 51 52 String 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 ex) { 69 throw (Exception )ex.getCause(); 70 } 71 } 72 73 public static void main(String [] args) { 74 junit.textui.TestRunner.run(XMLBareSystemTest.class); 75 } 76 } 77 | Popular Tags |