package i5.las2peer.testing;

import java.util.ArrayList;

import i5.las2peer.p2p.PastryNodeImpl;

/**
 * This class provides methods for developers to simplify JUnit test creation.
 *
 */
public class TestSuite {

	/**
	 * This method starts a network consisting of the given number of nodes.
	 *
	 * @param numOfNodes The number of nodes that should be in the network.
	 * @return Returns a list with all nodes from the network.
	 * @throws Exception If an error occurs.
	 */
	public static ArrayList<PastryNodeImpl> launchNetwork(int numOfNodes) throws Exception {
		ArrayList<PastryNodeImpl> result = new ArrayList<>();
		// launch bootstrap node
		PastryNodeImpl bootstrapNode = new PastryNodeImpl("");
		bootstrapNode.launch();
		final int bootstrapPort = bootstrapNode.getPort();
		result.add(bootstrapNode);
		System.out.println("bootstrap node launched with id " + bootstrapNode.getNodeId());
		// add more nodes
		for (int num = 1; num <= numOfNodes - 1; num++) {
			PastryNodeImpl node2 = new PastryNodeImpl("localhost:" + bootstrapPort);
			node2.launch();
			result.add(node2);
			System.out.println("network node launched with id " + bootstrapNode.getNodeId());
		}
		return result;
	}

}

@@ -23,16 +23,45 @@
 sting;%0A%0A
+import java.net.InetAddress;%0A
 import j
@@ -237,16 +237,66 @@
 uite %7B%0A%0A
+%09private static final int bootstrapPort = 14570;%0A%0A
 %09/**%0A%09 *
@@ -777,16 +777,31 @@
 eImpl(%22%22
+, bootstrapPort
 );%0A%09%09boo
@@ -825,61 +825,8 @@
 ();%0A
-%09%09final int bootstrapPort = bootstrapNode.getPort();%0A
 %09%09re
@@ -1057,36 +1057,99 @@
 mpl(
-%22localhost:%22 + bootstrapPort
+InetAddress.getLocalHost().getHostAddress() + %22:%22 + bootstrapPort,%0A%09%09%09%09%09bootstrapPort + num
 );%0A%09
@@ -1298,10 +1298,491 @@
 lt;%0A%09%7D%0A%0A
+%09/**%0A%09 * self test%0A%09 * %0A%09 * @param args%0A%09 */%0A%09public static void main(String%5B%5D args) %7B%0A%09%09try %7B%0A%09%09%09System.out.println(%22starting network%22);%0A%09%09%09ArrayList%3CPastryNodeImpl%3E nodes = launchNetwork(5);%0A%09%09%09System.out.println(%22network start complete%22);%0A%09%09%09Thread.sleep(1000);%0A%09%09%09System.out.println(%22shutting down network%22);%0A%09%09%09for (PastryNodeImpl node : nodes) %7B%0A%09%09%09%09node.shutDown();%0A%09%09%09%7D%0A%09%09%09System.out.println(%22self test complete%22);%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%7D%0A%0A
 %7D%0A

fix TestSuite multi node launch