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