MCPcopy Index your code
hub / github.com/apache/tomcat / testError

Method testError

test/org/apache/coyote/http2/TestAsyncError.java:46–93  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

44public class TestAsyncError extends Http2TestBase {
45
46 @Test
47 public void testError() throws Exception {
48
49 enableHttp2();
50
51 Tomcat tomcat = getTomcatInstance();
52
53 AsyncErrorServlet asyncErrorServlet = new AsyncErrorServlet();
54
55 Context ctxt = getProgrammaticRootContext();
56 Tomcat.addServlet(ctxt, "simple", new SimpleServlet());
57 ctxt.addServletMappingDecoded("/simple", "simple");
58 Wrapper w = Tomcat.addServlet(ctxt, "async", asyncErrorServlet);
59 w.setAsyncSupported(true);
60 ctxt.addServletMappingDecoded("/async", "async");
61 tomcat.start();
62
63 openClientConnection();
64 doHttpUpgrade();
65 sendClientPreface();
66 validateHttp2InitialResponse();
67
68 // Send request
69 byte[] frameHeader = new byte[9];
70 ByteBuffer headersPayload = ByteBuffer.allocate(128);
71 buildGetRequest(frameHeader, headersPayload, null, 3, "/async");
72 writeFrame(frameHeader, headersPayload);
73
74 // Read response
75 // Headers
76 parser.readFrame();
77
78 // Read 3 'events'
79 parser.readFrame();
80 parser.readFrame();
81 parser.readFrame();
82
83 // Reset the stream
84 sendRst(3, Http2Error.CANCEL.getCode());
85
86 int count = 0;
87 while (count < 50 && asyncErrorServlet.getErrorCount() == 0) {
88 count++;
89 Thread.sleep(100);
90 }
91
92 Assert.assertEquals(1, asyncErrorServlet.getErrorCount());
93 }
94
95
96 private static final class AsyncErrorServlet extends HttpServlet {

Callers

nothing calls this directly

Calls 15

addServletMethod · 0.95
setAsyncSupportedMethod · 0.95
startMethod · 0.95
getErrorCountMethod · 0.95
enableHttp2Method · 0.80
getTomcatInstanceMethod · 0.80
openClientConnectionMethod · 0.80
sendClientPrefaceMethod · 0.80
buildGetRequestMethod · 0.80
writeFrameMethod · 0.80

Tested by

no test coverage detected