"\r\n" +
"12");
return true;
}
};
IServer server = new Server(dh);
server.start();
NonBlockingConnectionPool pool = new NonBlockingConnectionPool();
for (int i = 0; i < 5; i++) {
INonBlockingConnection con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
HttpClientConnection httpCon = new HttpClientConnection(con);
IHttpResponse response = httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("12", response.getBody().readString());
}
QAUtil.sleep(1000);
Assert.assertEquals(5, pool.getNumActive());
Assert.assertEquals(0, pool.getNumIdle());
Assert.assertEquals(0, pool.getNumDestroyed());
INonBlockingConnection con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
HttpClientConnection httpCon = new HttpClientConnection(con);
IHttpResponse response = httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("12", response.getBody().readString());
httpCon.close();
QAUtil.sleep(1000);
con = pool.getNonBlockingConnection("localhost", server.getLocalPort());
httpCon = new HttpClientConnection(con);
response = httpCon.call(new GetRequest("http://localhost:" + server.getLocalPort()+ "/"));
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("12", response.getBody().readString());
httpCon.close();
QAUtil.sleep(1000);
Assert.assertEquals(5, pool.getNumActive());
Assert.assertEquals(1, pool.getNumIdle());
Assert.assertEquals(0, pool.getNumDestroyed());
pool.destroy();
server.close();
}