1 package org.objectweb.celtix.routing; 2 3 import java.net.URL ; 4 import java.util.HashMap ; 5 import java.util.Map ; 7 8 import javax.wsdl.Definition; 9 import javax.xml.namespace.QName ; 10 import javax.xml.transform.stream.StreamSource ; 11 import javax.xml.ws.Dispatch; 12 import javax.xml.ws.Service; 13 14 import junit.framework.TestCase; 15 import org.objectweb.celtix.Bus; 16 import org.objectweb.celtix.routing.configuration.RouteType; 17 18 public class MessageProviderTest extends TestCase { 19 20 private Map <String , Object > properties; 21 public void setUp() { 22 properties = new HashMap <String , Object >(); 23 } 24 25 public void tearDown() throws Exception { 26 Bus bus = Bus.getCurrent(); 27 bus.shutdown(true); 28 Bus.setCurrent(null); 29 } 30 31 public void testServiceCreation() throws Exception { 32 properties.put("org.objectweb.celtix.BusId", "MPT1"); 33 Bus bus = Bus.init(null, properties); 34 Bus.setCurrent(bus); 35 36 URL wsdlUrl = getClass().getResource("resources/router.wsdl"); 37 Definition def = bus.getWSDLManager().getDefinition(wsdlUrl); 38 39 QName sourceSrv = new QName ("http://objectweb.org/HWRouter", "HTTPSoapServiceSource"); 40 String sourcePort = new String ("HTTPSoapPortSource"); 41 QName destSrv = new QName ("http://objectweb.org/HWRouter", "HTTPSoapServiceDestination"); 42 String destPort = new String ("HTTPSoapPortDestination"); 43 44 RouteType rt = 45 RouteTypeUtil.createRouteType("route_0", 46 sourceSrv, sourcePort, 47 destSrv, destPort); 48 TestProvider tp = new TestProvider(def, rt); 49 50 Service s = tp.createService(wsdlUrl, destSrv); 51 assertNotNull("Service should not be null", s); 52 assertEquals(destSrv, s.getServiceName()); 53 assertEquals(wsdlUrl, s.getWSDLDocumentLocation()); 54 55 Dispatch<StreamSource > d = tp.createDispatch(s, destPort); 56 assertNotNull("Dispatch instance should be present", d); 57 58 tp.init(); 59 60 tp.testDispatchList(1); 61 } 62 63 public static void main(String [] args) { 64 junit.textui.TestRunner.run(MessageProviderTest.class); 65 } 66 67 68 class TestProvider extends StreamSourceMessageProvider { 69 70 public TestProvider(Definition def, RouteType rt) { 71 super(def, rt); 72 } 73 74 public void testDispatchList(int expectedCount) { 75 assertEquals(expectedCount, this.dList.size()); 76 } 77 } 78 } 79 | Popular Tags |