}
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() + "/start", res, null);
} catch (IOException ioe) {
// Ignore - expected for some error conditions
}
StringBuilder expected = new StringBuilder("requestInitialized-");
expected.append("TimeoutServletGet-");
if (completeOnTimeout == null) {
expected.append("requestDestroyed");
} else if (completeOnTimeout.booleanValue()) {
expected.append("onTimeout-");
expected.append("onComplete-");
expected.append("requestDestroyed");
} else {
expected.append("onTimeout-");
if (asyncDispatch != null) {
if (asyncDispatch.booleanValue()) {
expected.append("onStartAsync-Runnable-");
} else {
expected.append("NonAsyncServletGet-");
}
}
expected.append("onComplete-");
expected.append("requestDestroyed");
}
assertEquals(expected.toString(), res.toString());
// Check the access log
if (completeOnTimeout == null) {
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);
} else {
long timeoutDelay = TimeoutServlet.ASYNC_TIMEOUT;
if (asyncDispatch != null && asyncDispatch.booleanValue() &&
!completeOnTimeout.booleanValue()) {
// Extra timeout in this case
timeoutDelay += TimeoutServlet.ASYNC_TIMEOUT;
}
alvGlobal.validateAccessLog(1, 200, timeoutDelay,
timeoutDelay + TIMEOUT_MARGIN + REQUEST_TIME);
alv.validateAccessLog(1, 200, timeoutDelay,
timeoutDelay + TIMEOUT_MARGIN + REQUEST_TIME);
}
}