1 package org.objectweb.celtix.systest.routing; 2 3 import java.lang.reflect.UndeclaredThrowableException ; 4 import java.net.URL ; 5 6 import javax.xml.namespace.QName ; 7 8 import junit.framework.TestCase; 9 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("/wsdl/hello_world_doc_lit.wsdl"); 24 assertNotNull(wsdl); 25 SOAPService service = new SOAPService(wsdl, serviceName); 26 assertNotNull(service); 27 28 greeter = service.getPort(portName, Greeter.class); 29 } 30 31 public void testBasic() throws Exception { 32 String response1 = new String ("Hello Milestone-"); 33 String response2 = new String ("Bonjour"); 34 try { 35 for (int idx = 0; idx < 10; idx++) { 36 String greeting = greeter.greetMe("Milestone-" + idx); 37 assertNotNull("no response received from service", greeting); 38 String exResponse = response1 + idx; 39 assertEquals(exResponse, greeting); 40 41 if (enableOneway) { 42 greeter.greetMeOneWay("Milestone-" + idx); 43 } 44 45 String reply = greeter.sayHi(); 46 assertNotNull("no response received from service", reply); 47 assertEquals(response2, reply); 48 } 49 } catch (UndeclaredThrowableException ex) { 50 throw (Exception )ex.getCause(); 51 } 52 } 53 54 public void testFaults() throws Exception { 55 56 for (int idx = 0; idx < 10; idx++) { 57 try { 58 greeter.pingMe(); 59 fail("Should have thrown a PingMeFault exception"); 60 } catch (PingMeFault pmf) { 61 FaultDetail fd = pmf.getFaultInfo(); 62 assertNotNull("FaultDetail should havea valid value", fd); 63 assertEquals(2, fd.getMajor()); 64 assertEquals(1, fd.getMinor()); 65 } 66 } 67 } 68 } 69 | Popular Tags |