1 package org.objectweb.celtix.routing; 2 3 import java.util.HashMap ; 4 import java.util.List ; 5 import java.util.Map ; 6 7 import javax.wsdl.Definition; 8 9 import junit.framework.TestCase; 10 import org.objectweb.celtix.Bus; 11 import org.objectweb.celtix.routing.configuration.RouteType; 12 13 public class RouterFactoryTest extends TestCase { 14 15 private Map <String , Object > properties; 16 public void setUp() { 17 properties = new HashMap <String , Object >(); 18 } 19 20 public void tearDown() throws Exception { 21 Bus bus = Bus.getCurrent(); 22 bus.shutdown(true); 23 Bus.setCurrent(null); 24 } 25 26 public void testAddRoutes() throws Exception { 27 properties.put("org.objectweb.celtix.BusId", "celtix1"); 28 Bus bus = Bus.init(null, properties); 29 Bus.setCurrent(bus); 30 31 TestRouterFactory factory = new TestRouterFactory(); 32 factory.init(bus); 33 34 Definition def = bus.getWSDLManager().getDefinition(getClass().getResource("resources/router.wsdl")); 35 36 List <Router> rList = factory.addRoutes(def); 37 assertEquals(4, rList.size()); 38 assertEquals(4, factory.routerCount); 39 } 40 41 public static void main(String [] args) { 42 junit.textui.TestRunner.run(RouterFactoryTest.class); 43 } 44 45 46 class TestRouterFactory extends RouterFactory { 47 private int routerCount; 48 public TestRouterFactory() { 49 super(null); 50 routerCount = 0; 51 } 52 53 public Router createRouter(Definition model, RouteType route) { 54 ++routerCount; 56 return new TestRouter(); 57 } 58 } 59 60 class TestRouter implements Router { 61 public TestRouter() { 62 } 64 65 public Definition getWSDLModel() { 66 return null; 67 } 68 69 public RouteType getRoute() { 70 return null; 71 } 72 73 public void init() { 74 } 76 77 public void publish() { 78 } 80 } 81 } 82 | Popular Tags |