IServer server = new HttpServer(chain);
server.start();
// first request
HttpClientConnection con = new HttpClientConnection("localhost", server.getLocalPort());
IHttpResponse response = con.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/" + file.getName()));
Assert.assertEquals(200, response.getStatus());
Assert.assertNotNull(response.getHeader("Expires"));
Assert.assertTrue(QAUtil.isEquals(file, response.getBody().readByteBuffer()));
con.close();
QAUtil.sleep(1000);
// repeated request (served by cache!)
con = new HttpClientConnection("localhost", server.getLocalPort());
response = con.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/" + file.getName()));
Assert.assertEquals(200, response.getStatus());
Assert.assertNotNull(response.getHeader("Expires"));
Assert.assertTrue(response.getHeader("X-Cache").startsWith("HIT"));
Assert.assertTrue(QAUtil.isEquals(file, response.getBody().readByteBuffer()));
con.close();
server.close();
}