use of jakarta.servlet.Servlet in project tomcat by apache.
the class TestAsyncContextImpl method doTestDispatchWithSpaces.
private void doTestDispatchWithSpaces(boolean async) throws Exception {
Tomcat tomcat = getTomcatInstance();
Context context = tomcat.addContext("", null);
if (async) {
Servlet s = new AsyncDispatchUrlWithSpacesServlet();
Wrapper w = Tomcat.addServlet(context, "space", s);
w.setAsyncSupported(true);
} else {
Tomcat.addServlet(context, "space", new ForwardDispatchUrlWithSpacesServlet());
}
context.addServletMappingDecoded("/space/*", "space");
tomcat.start();
ByteChunk responseBody = new ByteChunk();
int rc = getUrl("http://localhost:" + getPort() + "/sp%61ce/foo%20bar", responseBody, null);
Assert.assertEquals(200, rc);
}
use of jakarta.servlet.Servlet in project tomcat by apache.
the class TestAsyncContextImpl method testAsyncContextListenerClearing.
// https://bz.apache.org/bugzilla/show_bug.cgi?id=57326
@Test
public void testAsyncContextListenerClearing() throws Exception {
resetTracker();
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
Context ctx = tomcat.addContext("", null);
Servlet stage1 = new DispatchingServletTracking("/stage2", true);
Wrapper wrapper1 = Tomcat.addServlet(ctx, "stage1", stage1);
wrapper1.setAsyncSupported(true);
ctx.addServletMappingDecoded("/stage1", "stage1");
Servlet stage2 = new DispatchingServletTracking("/stage3", false);
Wrapper wrapper2 = Tomcat.addServlet(ctx, "stage2", stage2);
wrapper2.setAsyncSupported(true);
ctx.addServletMappingDecoded("/stage2", "stage2");
Servlet stage3 = new NonAsyncServlet();
Tomcat.addServlet(ctx, "stage3", stage3);
ctx.addServletMappingDecoded("/stage3", "stage3");
TesterAccessLogValve alv = new TesterAccessLogValve();
ctx.getPipeline().addValve(alv);
tomcat.start();
getUrl("http://localhost:" + getPort() + "/stage1");
Assert.assertEquals("doGet-startAsync-doGet-startAsync-onStartAsync-NonAsyncServletGet-onComplete-", getTrack());
// Check the access log
alv.validateAccessLog(1, 200, 0, REQUEST_TIME);
}
Aggregations