Tomcat tomcat = getTomcatInstance();
// Must have a real docBase - just use temp
File docBase = new File(System.getProperty("java.io.tmpdir"));
Context ctx = tomcat.addContext("", docBase.getAbsolutePath());
TimeoutServlet timeout = new TimeoutServlet(null, null);
Wrapper w1 = Tomcat.addServlet(ctx, "time", timeout);
w1.setAsyncSupported(true);
ctx.addServletMapping("/async", "time");
NonAsyncServlet nonAsync = new NonAsyncServlet();
Wrapper w2 = Tomcat.addServlet(ctx, "nonAsync", nonAsync);
w2.setAsyncSupported(true);
ctx.addServletMapping("/error/nonasync", "nonAsync");
AsyncErrorPage asyncErrorPage = new AsyncErrorPage(mode);
Wrapper w3 = Tomcat.addServlet(ctx, "asyncErrorPage", asyncErrorPage);
w3.setAsyncSupported(true);
ctx.addServletMapping("/error/async", "asyncErrorPage");
if (asyncError != null) {
ErrorPage ep = new ErrorPage();
ep.setErrorCode(500);
if (asyncError.booleanValue()) {
ep.setLocation("/error/async");
} else {
ep.setLocation("/error/nonasync");
}
ctx.addErrorPage(ep);
}
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();