use of org.apache.catalina.valves.TesterAccessLogValve in project tomcat by apache.
the class TestAsyncContextImpl method testBug50753.
@Test
public void testBug50753() throws Exception {
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
// No file system docBase required
Context ctx = tomcat.addContext("", null);
Bug50753Servlet servlet = new Bug50753Servlet();
Wrapper wrapper = Tomcat.addServlet(ctx, "servlet", servlet);
wrapper.setAsyncSupported(true);
ctx.addServletMappingDecoded("/", "servlet");
TesterAccessLogValve alv = new TesterAccessLogValve();
ctx.getPipeline().addValve(alv);
tomcat.start();
// Call the servlet once
Map<String, List<String>> headers = new LinkedHashMap<>();
ByteChunk bc = new ByteChunk();
int rc = getUrl("http://localhost:" + getPort() + "/", bc, headers);
assertEquals(200, rc);
assertEquals("OK", bc.toString());
List<String> testHeader = headers.get("A");
assertNotNull(testHeader);
assertEquals(1, testHeader.size());
assertEquals("xyz", testHeader.get(0));
// Check the access log
alv.validateAccessLog(1, 200, Bug50753Servlet.THREAD_SLEEP_TIME, Bug50753Servlet.THREAD_SLEEP_TIME + REQUEST_TIME);
}
Aggregations