01: package org.objectweb.celtix.systest.routing;
02:
03: import java.io.File;
04: import java.net.URL;
05:
06: import javax.xml.ws.WebServiceException;
07:
08: import org.objectweb.celtix.Bus;
09: import org.objectweb.celtix.BusException;
10: import org.objectweb.celtix.routing.RouterManager;
11: import org.objectweb.celtix.systest.common.TestServerBase;
12: import org.objectweb.celtix.testutil.common.TestUtil;
13:
14: public class RouterServer extends TestServerBase {
15: private static final String CELTIX_ROUTER_TMP = new String(
16: "/celtix-router-tmp");
17: private Bus bus;
18:
19: public RouterServer(String[] args) {
20: URL routerConfigFileUrl = RouterServer.class
21: .getResource("router_config.xml");
22: System.setProperty("celtix.config.file", routerConfigFileUrl
23: .toString());
24: try {
25: bus = Bus.init(args);
26: } catch (BusException be) {
27: throw new WebServiceException("Could not initialize bus",
28: be);
29: }
30: }
31:
32: protected void run() {
33: RouterManager rm = new RouterManager(bus);
34: rm.init();
35: }
36:
37: private void cleanup() {
38: TestUtil.deleteDir(new File(System.getProperty("user.dir"),
39: CELTIX_ROUTER_TMP));
40: }
41:
42: public boolean stopInProcess() throws Exception {
43: System.clearProperty("celtix.config.file");
44: tearDown();
45: return super .stopInProcess();
46: }
47:
48: //Called in context of start method
49: public void tearDown() throws Exception {
50: cleanup();
51: super.tearDown();
52: }
53: }
|