ctx.addServletMapping(dispatchUrl, "nonasync");
}
ctx.addApplicationListener(TrackingRequestListener.class.getName());
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("requestInitialized-");
expected.append("TimeoutServletGet-");
if (completeOnTimeout == null) {
expected.append("requestDestroyed");
} else if (completeOnTimeout.booleanValue()) {
expected.append("onTimeout-");
if (dispatchUrl == null) {
expected.append("onComplete-");
expected.append("requestDestroyed");
} else {
// Error - no further output
// There is no onComplete- since the complete event would be
// fired during post processing but since there is an error that
// never happens.
}
} else {
expected.append("onTimeout-");
if (dispatchUrl != null) {
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 if (completeOnTimeout.booleanValue() && dispatchUrl != null) {
// This error is written into Host-level AccessLogValve only
alvGlobal.validateAccessLog(1, 500, 0, TimeoutServlet.ASYNC_TIMEOUT
+ TIMEOUT_MARGIN + REQUEST_TIME);
alv.validateAccessLog(0, 500, 0, 0);
} else {
alvGlobal.validateAccessLog(1, 200, TimeoutServlet.ASYNC_TIMEOUT,
TimeoutServlet.ASYNC_TIMEOUT + TIMEOUT_MARGIN +
REQUEST_TIME);
alv.validateAccessLog(1, 200, TimeoutServlet.ASYNC_TIMEOUT,
TimeoutServlet.ASYNC_TIMEOUT + TIMEOUT_MARGIN +
REQUEST_TIME);