01: package org.objectweb.celtix.wsdl;
02:
03: import javax.wsdl.Definition;
04: import javax.wsdl.Port;
05:
06: import junit.framework.TestCase;
07:
08: import org.objectweb.celtix.Bus;
09: import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
10: import org.objectweb.hello_world_soap_http.AnnotatedGreeterNoOverloadImpl;
11: import org.objectweb.hello_world_soap_http.AnotherDerivedGreeterImpl;
12: import org.objectweb.hello_world_soap_http.DerivedGreeterImpl;
13:
14: public class EndpointReferenceUtilsTest extends TestCase {
15:
16: public EndpointReferenceUtilsTest(String arg0) {
17: super (arg0);
18: }
19:
20: public void testGetWSDLDefinitionFromImplementation()
21: throws Exception {
22: Bus bus = Bus.init();
23:
24: // This implementor is not derived from an SEI and does not implement
25: // the Remote interface. It is however annotated with a WebService
26: // annotation
27: // in which the wsdl location attribute is not set.
28: Object implementor = new AnnotatedGreeterNoOverloadImpl();
29: WSDLManager manager = bus.getWSDLManager();
30: EndpointReferenceType ref = EndpointReferenceUtils
31: .getEndpointReference(manager, implementor);
32:
33: Definition def = EndpointReferenceUtils.getWSDLDefinition(
34: manager, ref);
35: assertNotNull("Could not generate wsdl", def);
36:
37: Port port = EndpointReferenceUtils.getPort(
38: bus.getWSDLManager(), ref);
39: // FIXME - a soap binding and service/port should have been
40: // generated
41: // negative test case
42: // fail("Did not expect a port to be found. Did someone fix this?");
43:
44: assertNotNull("Expected to find a port", port);
45:
46: // This implementor is annotated with a WebService annotation that has
47: // no
48: // wsdl location specified but it is derived from an interface that is
49: // annotated with a WebService annotation in which the attribute IS set
50: // -
51: // to a url that can be resolved because the interface was generated as
52: // part
53: // of the test build.
54: implementor = new DerivedGreeterImpl();
55: ref = EndpointReferenceUtils.getEndpointReference(manager,
56: implementor);
57: def = EndpointReferenceUtils.getWSDLDefinition(manager, ref);
58: assertNotNull("Could not load wsdl", def);
59:
60: port = EndpointReferenceUtils
61: .getPort(bus.getWSDLManager(), ref);
62: // FIXME - a soap binding and service/port should have been generated
63: // negative test case
64:
65: // fail("Did not expect a port to be found. Did someone fix this?");
66:
67: assertNotNull("Could not find port", port);
68: bus.shutdown(true);
69: }
70:
71: public void testEndpointInterfaceAnnotation() throws Exception {
72:
73: Bus bus = Bus.init();
74:
75: Object implementor = new AnotherDerivedGreeterImpl();
76:
77: WSDLManager manager = bus.getWSDLManager();
78: EndpointReferenceType ref = EndpointReferenceUtils
79: .getEndpointReference(manager, implementor);
80: Definition def = EndpointReferenceUtils.getWSDLDefinition(
81: manager, ref);
82: assertNotNull("Could not load wsdl", def);
83:
84: Port port = EndpointReferenceUtils.getPort(
85: bus.getWSDLManager(), ref);
86:
87: assertNull("Port should not be present in the reference.", port);
88:
89: bus.shutdown(true);
90:
91: }
92:
93: }
|