01: package org.objectweb.celtix.bus.configuration.wsdl;
02:
03: import java.net.URL;
04:
05: import javax.wsdl.Port;
06: import javax.wsdl.WSDLException;
07: import javax.xml.bind.JAXBException;
08: import javax.xml.namespace.QName;
09:
10: import junit.framework.TestCase;
11:
12: import org.objectweb.celtix.BusException;
13: import org.objectweb.celtix.bus.wsdl.WSDLManagerImpl;
14: import org.objectweb.celtix.transports.http.configuration.HTTPClientPolicy;
15: import org.objectweb.celtix.transports.http.configuration.HTTPServerPolicy;
16: import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
17: import org.objectweb.celtix.wsdl.EndpointReferenceUtils;
18: import org.objectweb.celtix.wsdl.JAXBExtensionHelper;
19: import org.objectweb.celtix.wsdl.WSDLManager;
20:
21: public class WsdlProviderTest extends TestCase {
22:
23: private static final URL WSDL_URL = WsdlProviderTest.class
24: .getResource("/wsdl/wsdl_provider_test.wsdl");
25: private static final QName SERVICE = new QName(
26: "http://celtix.objectweb.org/HelloWorld",
27: "HelloWorldPortBinding");
28: private static final String PORT = "HelloWorldPort";
29: private static WSDLManager wmgr;
30:
31: public void setUp() throws WSDLException, BusException,
32: JAXBException {
33: if (null == wmgr) {
34: wmgr = new WSDLManagerImpl(null);
35: JAXBExtensionHelper
36: .addExtensions(
37: wmgr.getExtenstionRegistry(),
38: javax.wsdl.Port.class,
39: org.objectweb.celtix.transports.http.configuration.HTTPServerPolicy.class);
40: JAXBExtensionHelper
41: .addExtensions(
42: wmgr.getExtenstionRegistry(),
43: javax.wsdl.Port.class,
44: org.objectweb.celtix.transports.http.configuration.HTTPClientPolicy.class);
45: }
46: }
47:
48: public void testWsdlPortProvider() throws WSDLException {
49:
50: EndpointReferenceType ref = EndpointReferenceUtils
51: .getEndpointReference(WSDL_URL, SERVICE, PORT);
52: Port p = EndpointReferenceUtils.getPort(wmgr, ref);
53:
54: WsdlPortProvider pp = new WsdlPortProvider(p);
55: assertNotNull(pp);
56:
57: Object value = pp.getObject("bindingId");
58: assertEquals(value.toString(),
59: "http://schemas.xmlsoap.org/wsdl/soap/", value);
60:
61: value = pp.getObject("address");
62: assertEquals("http://localhost:9876", (String) value);
63:
64: pp = new WsdlPortProvider(null);
65: assertNull(pp.getObject("bindingId"));
66: }
67:
68: public void testWsdlHttpConfigurationProvider()
69: throws WSDLException, JAXBException {
70: EndpointReferenceType ref = EndpointReferenceUtils
71: .getEndpointReference(WSDL_URL, SERVICE, PORT);
72: Port p = EndpointReferenceUtils.getPort(wmgr, ref);
73:
74: WsdlHttpConfigurationProvider hcp = new WsdlHttpConfigurationProvider(
75: p, true);
76: assertNull(hcp.getObject("SendTimeout"));
77: Object value = hcp.getObject("httpServer");
78: assertNotNull(value);
79: assertEquals(30000, ((HTTPServerPolicy) value)
80: .getReceiveTimeout());
81:
82: hcp = new WsdlHttpConfigurationProvider(p, false);
83: assertNull(hcp.getObject("ReceiveTimeout"));
84: value = hcp.getObject("httpClient");
85: assertEquals(90000, ((HTTPClientPolicy) value)
86: .getReceiveTimeout());
87:
88: hcp = new WsdlHttpConfigurationProvider(null, false);
89: value = hcp.getObject("httpClient");
90: assertNull(value);
91: }
92:
93: }
|