1 package org.objectweb.celtix.systest.js; 2 3 import java.lang.reflect.UndeclaredThrowableException ; 4 import java.net.URL ; 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 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", launchServer(Server.class)); 26 } 27 }; 28 } 29 30 public void testJSMessageMode() throws Exception { 31 QName serviceName = new QName (NS, "SOAPService"); 32 QName portName = new QName (NS, "SoapPort"); 33 34 URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl"); 35 assertNotNull(wsdl); 36 37 SOAPService service = new SOAPService(wsdl, serviceName); 38 assertNotNull(service); 39 40 String response1 = new String ("TestGreetMeResponse"); 41 String response2 = new String ("TestSayHiResponse"); 42 try { 43 Greeter greeter = service.getPort(portName, Greeter.class); 44 String greeting = greeter.greetMe("TestGreetMeRequest"); 45 assertNotNull("no response received from service", greeting); 46 assertEquals(response1, greeting); 47 48 String reply = greeter.sayHi(); 49 assertNotNull("no response received from service", reply); 50 assertEquals(response2, reply); 51 } catch (UndeclaredThrowableException ex) { 52 ex.printStackTrace(); 53 throw (Exception )ex.getCause(); 54 } 55 } 56 57 public void testJSPayloadMode() throws Exception { 58 URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl"); 59 assertNotNull(wsdl); 60 61 QName serviceName = new QName (NS, "SOAPServiceTest1"); 62 QName portName = new QName (NS, "SoapPort_Test1"); 63 64 SOAPServiceTest1 service = new SOAPServiceTest1(wsdl, serviceName); 65 assertNotNull(service); 66 67 String response1 = new String ("TestGreetMeResponse"); 68 String response2 = new String ("TestSayHiResponse"); 69 try { 70 Greeter greeter = service.getPort(portName, Greeter.class); 71 String greeting = greeter.greetMe("TestGreetMeRequest"); 72 assertNotNull("no response received from service", greeting); 73 assertEquals(response1, greeting); 74 75 String reply = greeter.sayHi(); 76 assertNotNull("no response received from service", reply); 77 assertEquals(response2, reply); 78 } catch (UndeclaredThrowableException ex) { 79 ex.printStackTrace(); 80 throw (Exception )ex.getCause(); 81 } 82 } 83 84 public static void main(String [] args) { 85 junit.textui.TestRunner.run(JSClientServerTest.class); 86 } 87 } 88 | Popular Tags |