1   /*
2    * Created on Oct 22, 2003
3    * 
4    * Copyright neotechnologies.org
5    */
6   package functional.simpleapp;
7   
8   
9   import java.net.InetAddress;
10  
11  import junit.framework.TestCase;
12  import org.neo.swarm.ApplicationContext;
13  import org.neo.swarm.SwarmContainer;
14  import org.neo.swarm.config.JMXConfig;
15  
16  /***
17   *
18   * 
19   * @author neil.avery
20   */
21  public class JMXSimpleEndToEndTest extends TestCase {
22  
23  	SwarmContainer silc1;
24  	SwarmContainer silc2;
25  	
26  	public void testInvokeAandBfromSilc1() throws Exception {
27  		silc1 = new JMXConfig("firstAppContext", InetAddress.getLocalHost(), 8081, 8091, false).setup();
28  		silc2 = new JMXConfig("secondAppContext",InetAddress.getLocalHost(), 8082, 8092, false).setup();
29  		
30  		ApplicationContext ac = silc1.getAppContext("firstAppContext");
31          ac.addCachedComponent("compA",ComponentA.class);
32  
33  		ApplicationContext ac2 = silc2.getAppContext("secondAppContext");
34  		ac2.addCachedComponent("compB", ComponentB.class);
35          
36  		silc1.start();
37  		silc2.start();
38  		ac.retrieveComponent("compA");
39  		ac2.retrieveComponent("compB");
40  		Thread.sleep(3 * 1000);
41  
42  		ComponentBI compBb = (ComponentBI) silc1.getComponent("compB");
43  
44  		System.out.println(" ============== got object =================");
45  		compBb.doStuffB();
46  		compBb.doStuffB();
47  
48  		ComponentBI compB2 = (ComponentBI) silc2.getComponent("compB");
49  		compB2.doStuffB();
50  		compB2.doStuffB();
51  	}
52  	
53  	/* (non-Javadoc)
54  	 * @see junit.framework.TestCase#tearDown()
55  	 */
56  	protected void tearDown() throws Exception {
57  		if (silc1 != null) silc1.stop();
58  		if (silc2 != null) silc2.stop();
59  	}
60  }