System.setProperty("org.xlightweb.showDetailedError", "true");
final HttpClient httpClient = new HttpClient();
final IServer server = new HttpServer(new EchoHandler());
ConnectionUtils.start(server);
for (int i = 0; i < 5; i++) {
Thread t = new Thread() {
@Override
public void run() {
running.incrementAndGet();
try {
for (int j = 0; j < 30; j++) {
IHttpResponseHandler hdl = new IHttpResponseHandler() {
public void onResponse(IHttpResponse response) throws IOException {
openResponses.incrementAndGet();
}
public void onException(IOException ioe) {
}
};
openResponses.decrementAndGet();
httpClient.send(new PostRequest("http://localhost:" + server.getLocalPort() + "/", "text/plian", "test"), hdl);
QAUtil.sleep(10);
}
} catch (Exception e) {
errors.add(e.toString());
}
running.decrementAndGet();
}
};
t.start();
}
do {
QAUtil.sleep(200);
} while ((running.get() > 0) || (openResponses.get() > 0));
for (String error : errors) {
System.out.println(error);
}
Assert.assertTrue(errors.isEmpty());
Assert.assertTrue(httpClient.getNumDestroyed() == 0);
server.close();
httpClient.close();
}