01: package org.objectweb.celtix.systest.callback;
02:
03: import java.net.URL;
04:
05: import javax.xml.namespace.QName;
06: import javax.xml.ws.Endpoint;
07:
08: import junit.framework.Test;
09: 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: public final class CallbackClientServerTest extends
22: ClientServerTestBase {
23:
24: private static final QName SERVICE_NAME = new QName(
25: "http://objectweb.org/callback", "SOAPService");
26:
27: //private static final QName CALLBACK_SERVICE_NAME
28: // = new QName("http://objectweb.org/callback", "CallbackService");
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",
35: launchServer(Server.class));
36: }
37: };
38: }
39:
40: public void testCallback() {
41:
42: Bus bus = null;
43: try {
44: bus = Bus.init();
45: } catch (BusException e) {
46: // TODO Auto-generated catch block
47: e.printStackTrace();
48: }
49:
50: Object implementor = new CallbackImpl();
51: String address = "http://localhost:9005/CallbackContext/CallbackPort";
52: Endpoint.publish(address, implementor);
53:
54: URL wsdlURL = getClass().getResource(
55: "/wsdl/basic_callback.wsdl");
56:
57: SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
58: ServerPortType port = ss.getSOAPPort();
59:
60: EndpointReferenceType ref = null;
61: try {
62: ref = EndpointReferenceUtils.getEndpointReference(
63: new WSDLManagerImpl(bus), implementor);
64: } catch (BusException e) {
65: // TODO Auto-generated catch block
66: e.printStackTrace();
67: }
68:
69: String resp = port.registerCallback(ref);
70:
71: assertTrue(resp.equals("registerCallback called"));
72:
73: try {
74: bus.shutdown(true);
75: } catch (BusException e) {
76: // TODO Auto-generated catch block
77: e.printStackTrace();
78: }
79:
80: //System.exit(0);
81:
82: }
83:
84: }
|