1 package org.objectweb.celtix.bus.jaxws; 2 3 import java.lang.reflect.Proxy ; 4 import java.util.Iterator ; 5 6 import javax.xml.namespace.QName ; 7 import javax.xml.soap.SOAPMessage ; 8 import javax.xml.transform.dom.DOMSource ; 9 import javax.xml.ws.Dispatch; 10 import javax.xml.ws.Service; 11 import javax.xml.ws.spi.Provider; 12 13 import junit.framework.TestCase; 14 15 import org.objectweb.celtix.Bus; 16 import org.objectweb.celtix.bus.jaxws.spi.ProviderImpl; 17 import org.objectweb.hello_world_soap_http.Greeter; 18 import org.objectweb.hello_world_soap_http.SOAPService; 19 20 public class ServiceTest extends TestCase { 21 22 public ServiceTest(String arg0) { 23 super(arg0); 24 } 25 26 public static void main(String [] args) { 27 junit.textui.TestRunner.run(ServiceTest.class); 28 } 29 30 public void setUp() { 31 System.setProperty(Provider.JAXWSPROVIDER_PROPERTY, 32 ProviderImpl.JAXWS_PROVIDER); 33 } 34 35 38 public void testGetPorts() throws Exception { 39 Bus bus = Bus.init(); 40 QName endpoint = new QName ("http://objectweb.org/hello_world_soap_http", 41 "SoapPort"); 42 43 try { 44 SOAPService hwService = new SOAPService(); 45 assertNotNull(hwService); 46 Iterator iter = hwService.getPorts(); 47 assertFalse("Should have no element", iter.hasNext()); 48 49 Greeter port = hwService.getSoapPort(); 50 assertNotNull(port); 51 assertTrue("Should be a proxy class. " 52 + port.getClass().getName(), 53 Proxy.isProxyClass(port.getClass())); 54 55 iter = hwService.getPorts(); 56 assertTrue("Should have one element", iter.hasNext()); 57 assertEquals("Activated EndPoints are not the same", endpoint, iter.next()); 58 } finally { 59 bus.shutdown(true); 60 } 61 } 62 63 public void testCreateDispatch() throws Exception { 64 QName endpoint = new QName ("http://objectweb.org/hello_world_soap_http", 65 "SoapPort"); 66 67 SOAPService service = new SOAPService(); 68 assertNotNull(service); 69 Dispatch<SOAPMessage > disp = service.createDispatch(endpoint, 70 SOAPMessage .class, Service.Mode.MESSAGE); 71 assertNotNull(disp); 72 assertTrue("Should be DispatchImpl class", disp.getClass().isAssignableFrom(DispatchImpl.class)); 73 74 Dispatch<DOMSource > disp2 = service.createDispatch(endpoint, 75 DOMSource .class, Service.Mode.PAYLOAD); 76 assertNotNull(disp2); 77 assertTrue("Should be DispatchImpl class", disp2.getClass().isAssignableFrom(DispatchImpl.class)); 78 } 79 80 } 81 82 | Popular Tags |