1 package org.objectweb.celtix.systest.callback; 2 3 import java.net.URL ; 4 5 import javax.xml.namespace.QName ; 6 import javax.xml.ws.Endpoint; 7 8 import junit.framework.Test; 9 import junit.framework.TestSuite; 10 11 import org.objectweb.callback.SOAPService; 12 import org.objectweb.callback.ServerPortType; 13 import org.objectweb.celtix.Bus; 14 import org.objectweb.celtix.BusException; 15 import org.objectweb.celtix.bus.wsdl.WSDLManagerImpl; 16 import org.objectweb.celtix.systest.common.ClientServerSetupBase; 17 import org.objectweb.celtix.systest.common.ClientServerTestBase; 18 import org.objectweb.celtix.ws.addressing.EndpointReferenceType; 19 import org.objectweb.celtix.wsdl.EndpointReferenceUtils; 20 21 22 public final class CallbackClientServerTest extends ClientServerTestBase { 23 24 private static final QName SERVICE_NAME 25 = new QName ("http://objectweb.org/callback", "SOAPService"); 26 29 30 public static Test suite() throws Exception { 31 TestSuite suite = new TestSuite(CallbackClientServerTest.class); 32 return new ClientServerSetupBase(suite) { 33 public void startServers() throws Exception { 34 assertTrue("server did not launch correctly", launchServer(Server.class)); 35 } 36 }; 37 } 38 39 public void testCallback() { 40 41 Bus bus = null; 42 try { 43 bus = Bus.init(); 44 } catch (BusException e) { 45 e.printStackTrace(); 47 } 48 49 Object implementor = new CallbackImpl(); 50 String address = "http://localhost:9005/CallbackContext/CallbackPort"; 51 Endpoint.publish(address, implementor); 52 53 URL wsdlURL = getClass().getResource("/wsdl/basic_callback.wsdl"); 54 55 SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME); 56 ServerPortType port = ss.getSOAPPort(); 57 58 EndpointReferenceType ref = null; 59 try { 60 ref = EndpointReferenceUtils.getEndpointReference(new WSDLManagerImpl(bus), implementor); 61 } catch (BusException e) { 62 e.printStackTrace(); 64 } 65 66 String resp = port.registerCallback(ref); 67 68 assertTrue(resp.equals("registerCallback called")); 69 70 try { 71 bus.shutdown(true); 72 } catch (BusException e) { 73 e.printStackTrace(); 75 } 76 77 79 } 80 81 } 82 83 | Popular Tags |