1   /*
2    * Created on May 13, 2004
3    *
4    */
5   package functional.agent.farm;
6   
7   import java.net.InetAddress;
8   import java.util.ArrayList;
9   
10  import junit.framework.TestCase;
11  
12  import org.neo.swarm.ApplicationContext;
13  import org.neo.swarm.SwarmContainer;
14  import org.neo.swarm.config.DynamicConfig;
15  
16  
17  /***
18   * Fires of a bunch of containers and allows remote  apps to use them
19   *  @author navery
20   */
21  public class RemoteNodeFarmTest extends TestCase {
22      public static void main(String[] args) {
23  
24          RemoteNodeFarmTest test = new RemoteNodeFarmTest();
25          try {
26  			test.testReceptionOfRemoteAgents();
27  		} catch (Exception e) {
28  			e.printStackTrace();
29  		}
30      }
31  
32  	public void testReceptionOfRemoteAgents() throws Exception {
33  		
34  		ArrayList containers = new ArrayList();
35  		int numContainers = 5;
36  		
37  		
38  		for (int i = 0; i < numContainers; i++ ) {
39  			SwarmContainer container = new DynamicConfig("remoteNode:" + i, InetAddress.getLocalHost(), 8082 + i, false).setup();
40  			ApplicationContext ac = container.getAppContext("remoteNode:" + i);
41  			container.start();
42  			containers.add(container);
43  		}
44  
45  	//	Thread.sleep( 10 * 60   * 1000);
46  		
47  		for (int i = 0; i < numContainers; i++ ) {
48  			SwarmContainer container = (SwarmContainer) containers.get(i);
49  			container.stop();
50  		}
51  	}
52  
53  }