HttpServer server = new HttpServer(new RequestHandler2());
server.setSessionMaxInactiveIntervalSec(1);
server.start();
SessionManager sessionManager = (SessionManager) server.getSessionManager();
ConnectionUtils.registerMBean(server);
HttpClient httpClient = new HttpClient();
IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
Assert.assertEquals(200, response.getStatus());
response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/"));
Assert.assertEquals(200, response.getStatus());
QAUtil.sleep(500);
Assert.assertEquals(0, sessionManager.getNumExpiredSessions());
QAUtil.sleep(6000); // cleaner runs each 5 sec!
Assert.assertEquals(1, sessionManager.getNumExpiredSessions());
httpClient.close();
server.close();
}