Random random = new Random(System.nanoTime());
String contextPath = "/lightLoad";
String servletMapping = "/server";
int port1 = random.nextInt(50000) + 10000;
Server server1 = new Server(port1);
WebAppContext context1 = new WebAppContext(warDir.getCanonicalPath(), contextPath);
context1.setSessionHandler(new SessionHandler());
context1.addServlet(TestServlet.class, servletMapping);
server1.setHandler(context1);
server1.start();
try
{
int port2 = random.nextInt(50000) + 10000;
Server server2 = new Server(port2);
WebAppContext context2 = new WebAppContext(warDir.getCanonicalPath(), contextPath);
context2.setSessionHandler(new SessionHandler());
context2.addServlet(TestServlet.class, servletMapping);
server2.setHandler(context2);
server2.start();
try
{
HttpClient client = new HttpClient();