| 1 package org.objectweb.celtix.bus.configuration.wsdl; 2 3 import java.net.URL ; 4 5 import javax.wsdl.Port; 6 import javax.wsdl.WSDLException; 7 import javax.xml.bind.JAXBException; 8 import javax.xml.namespace.QName ; 9 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.getResource("/wsdl/wsdl_provider_test.wsdl"); 24 private static final QName SERVICE = new QName ("http://celtix.objectweb.org/HelloWorld", 25 "HelloWorldPortBinding"); 26 private static final String PORT = "HelloWorldPort"; 27 private static WSDLManager wmgr; 28 29 public void setUp() throws WSDLException, BusException, JAXBException { 30 if (null == wmgr) { 31 wmgr = new WSDLManagerImpl(null); 32 JAXBExtensionHelper.addExtensions(wmgr.getExtenstionRegistry(), javax.wsdl.Port.class, 33 org.objectweb.celtix.transports.http.configuration.HTTPServerPolicy.class); 34 JAXBExtensionHelper.addExtensions(wmgr.getExtenstionRegistry(), javax.wsdl.Port.class, 35 org.objectweb.celtix.transports.http.configuration.HTTPClientPolicy.class); 36 } 37 } 38 39 public void testWsdlPortProvider() throws WSDLException { 40 41 EndpointReferenceType ref = EndpointReferenceUtils.getEndpointReference(WSDL_URL, SERVICE, PORT); 42 Port p = EndpointReferenceUtils.getPort(wmgr, ref); 43 44 WsdlPortProvider pp = new WsdlPortProvider(p); 45 assertNotNull(pp); 46 47 Object value = pp.getObject("bindingId"); 48 assertEquals(value.toString(), "http://schemas.xmlsoap.org/wsdl/soap/", value); 49 50 value = pp.getObject("address"); 51 assertEquals("http://localhost:9876", (String )value); 52 53 pp = new WsdlPortProvider(null); 54 assertNull(pp.getObject("bindingId")); 55 } 56 57 public void testWsdlHttpConfigurationProvider() throws WSDLException, JAXBException { 58 EndpointReferenceType ref = EndpointReferenceUtils.getEndpointReference(WSDL_URL, SERVICE, PORT); 59 Port p = EndpointReferenceUtils.getPort(wmgr, ref); 60 61 WsdlHttpConfigurationProvider hcp = new WsdlHttpConfigurationProvider(p, true); 62 assertNull(hcp.getObject("SendTimeout")); 63 Object value = hcp.getObject("httpServer"); 64 assertNotNull(value); 65 assertEquals(30000, ((HTTPServerPolicy)value).getReceiveTimeout()); 66 67 68 hcp = new WsdlHttpConfigurationProvider(p, false); 69 assertNull(hcp.getObject("ReceiveTimeout")); 70 value = hcp.getObject("httpClient"); 71 assertEquals(90000, ((HTTPClientPolicy)value).getReceiveTimeout()); 72 73 hcp = new WsdlHttpConfigurationProvider(null, false); 74 value = hcp.getObject("httpClient"); 75 assertNull(value); 76 } 77 78 79 } 80 | Popular Tags |