}
ctx.addApplicationListener(new ApplicationListener(
TrackingRequestListener.class.getName(), false));
TesterAccessLogValve alv = new TesterAccessLogValve();
ctx.getPipeline().addValve(alv);
TesterAccessLogValve alvGlobal = new TesterAccessLogValve();
tomcat.getHost().getPipeline().addValve(alvGlobal);
tomcat.start();
ByteChunk res = new ByteChunk();
try {
getUrl("http://localhost:" + getPort() + "/async", res, null);
} catch (IOException ioe) {
// Ignore - expected for some error conditions
}
StringBuilder expected = new StringBuilder();
if (asyncError == null) {
// No error handler - just get the 500 response
expected.append("requestInitialized-TimeoutServletGet-");
// Note: With an error handler the response will be reset and these
// will be lost
}
if (asyncError != null) {
if (asyncError.booleanValue()) {
expected.append("AsyncErrorPageGet-");
if (mode == ErrorPageAsyncMode.NO_COMPLETE){
expected.append("NoOp-");
} else if (mode == ErrorPageAsyncMode.COMPLETE) {
expected.append("Complete-");
} else if (mode == ErrorPageAsyncMode.DISPATCH) {
expected.append("Dispatch-NonAsyncServletGet-");
}
} else {
expected.append("NonAsyncServletGet-");
}
}
expected.append("requestDestroyed");
Assert.assertEquals(expected.toString(), res.toString());
// Check the access log
alvGlobal.validateAccessLog(1, 500, TimeoutServlet.ASYNC_TIMEOUT,
TimeoutServlet.ASYNC_TIMEOUT + TIMEOUT_MARGIN +
REQUEST_TIME);
alv.validateAccessLog(1, 500, TimeoutServlet.ASYNC_TIMEOUT,
TimeoutServlet.ASYNC_TIMEOUT + TIMEOUT_MARGIN +
REQUEST_TIME);