use of io.undertow.server.session.SecureRandomSessionIdGenerator in project undertow by undertow-io.
the class DefaultServletCachingTestCase method testFileExistanceCheckCached.
@Test
public void testFileExistanceCheckCached() throws IOException, InterruptedException {
TestHttpClient client = new TestHttpClient();
String fileName = new SecureRandomSessionIdGenerator().createSessionId() + ".html";
try {
HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/servletContext/" + fileName);
HttpResponse result = client.execute(get);
Assert.assertEquals(StatusCodes.NOT_FOUND, result.getStatusLine().getStatusCode());
HttpClientUtils.readResponse(result);
Path f = tmpDir.resolve(fileName);
Files.write(f, "hello".getBytes());
get = new HttpGet(DefaultServer.getDefaultServerURL() + "/servletContext/" + fileName);
result = client.execute(get);
Assert.assertEquals(StatusCodes.NOT_FOUND, result.getStatusLine().getStatusCode());
HttpClientUtils.readResponse(result);
Thread.sleep(METADATA_MAX_AGE);
get = new HttpGet(DefaultServer.getDefaultServerURL() + "/servletContext/" + fileName);
result = client.execute(get);
Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
String response = HttpClientUtils.readResponse(result);
Assert.assertEquals("hello", response);
Files.delete(f);
} finally {
client.getConnectionManager().shutdown();
}
}
Aggregations