1
2
3
4
5
6 package functional.simpleapp;
7
8
9 import java.net.InetAddress;
10
11 import junit.framework.TestCase;
12
13 import org.neo.swarm.ApplicationContext;
14 import org.neo.swarm.SwarmContainer;
15 import org.neo.swarm.config.DynamicConfig;
16
17 /***
18 * A SimpleTest where two containers are created and components lookedup from each other, demonstrating the shared nature of container spaces.
19 * @author neil.avery
20 */
21 public class SimpleEndToEndTest extends TestCase {
22
23 SwarmContainer silc1;
24 SwarmContainer silc2;
25
26 public void testInvokeAandBfromSilc1() throws Exception {
27 silc1 = (SwarmContainer) new DynamicConfig("A", InetAddress.getLocalHost(), 8081, false).setup().getComponent("container");
28 silc2 = (SwarmContainer) new DynamicConfig("B", InetAddress.getLocalHost(), 8082, false).setup().getComponent("container");
29
30
31 ApplicationContext ac = silc1.getAppContext("A");
32 ac.addCachedComponent("compA", ComponentA.class);
33
34 ac = silc2.getAppContext("B");
35 ac.addCachedComponent("compB", ComponentB.class);
36 silc1.start();
37 silc2.start();
38
39 Thread.sleep(5 * 1000);
40
41 ComponentBI compB = (ComponentBI) silc1.getComponent("compB");
42
43 System.out.println(" ============== got object =================");
44
45
46 compB.doStuffB();
47 compB.doStuffB();
48 compB.doStuffB();
49 compB.doStuffB();
50
51 ComponentBI compB2 = (ComponentBI) silc2.getComponent("compB");
52 compB2.doStuffB();
53 compB2.doStuffB();
54
55 System.out.println(" ============== shutdown =================");
56 assertNotNull(compB);
57 }
58
59
60
61 protected void tearDown() throws Exception {
62 if (silc1 != null) silc1.stop();
63 if (silc2 != null) silc2.stop();
64 }
65
66 }