use of io.undertow.server.handlers.StoredResponseHandler in project undertow by undertow-io.
the class AccessLogTestCase method testRemoteAddress.
@Test
public void testRemoteAddress() throws IOException, InterruptedException {
latch = new CountDownLatch(1);
DefaultServer.setRootHandler(new StoredResponseHandler(new AccessLogHandler(HELLO_HANDLER, RECEIVER, "Remote address %a Code %s test-header %{i,test-header} %{STORED_RESPONSE}", AccessLogFileTestCase.class.getClassLoader())));
TestHttpClient client = new TestHttpClient();
try {
HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/path");
get.addHeader("test-header", "test-value");
HttpResponse result = client.execute(get);
Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
Assert.assertEquals("HelloResponse", HttpClientUtils.readResponse(result));
latch.await(10, TimeUnit.SECONDS);
Assert.assertEquals("Remote address " + DefaultServer.getDefaultServerAddress().getAddress().getHostAddress() + " Code 200 test-header test-value HelloResponse", message);
} finally {
client.getConnectionManager().shutdown();
}
}
Aggregations