MCPcopy Create free account
hub / github.com/apache/tomcat / TestRequest

Class TestRequest

test/org/apache/coyote/TestRequest.java:33–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31import org.easymock.EasyMock;
32
33public class TestRequest {
34
35 private final Http11NioProtocol protocol = new Http11NioProtocol();
36 private final Http11Processor processor = new Http11Processor(protocol, null);
37 private final Request request = processor.getRequest();
38 private final Response response = request.getResponse();
39 private final SocketWrapperBase<?> socketWrapper = EasyMock.createNiceMock(SocketWrapperBase.class);
40
41
42 @Before
43 public void setupTest() {
44 // Set up the socket wrapper
45 EasyMock.expect(socketWrapper.getSocketBufferHandler()).andReturn(new SocketBufferHandler(0, 0, false));
46 EasyMock.replay(socketWrapper);
47 // Cast to make the method visible
48 ((AbstractProcessor) processor).setSocketWrapper(socketWrapper);
49 }
50
51
52 @Test
53 public void test100ContinueExpectationImmediately() throws IOException {
54 // Tests that response.sendAcknowledgement is only called when
55 // request.setContinueHandlingResponsePolicy is called.
56
57 request.setExpectation(true);
58
59 // Configure the mock to verify that a network write is made.
60 configureMockForOneAcknowledgementWrite(socketWrapper);
61
62 protocol.setContinueResponseTiming(ContinueResponseTiming.IMMEDIATELY.toString());
63 response.action(ActionCode.ACK, ContinueResponseTiming.IMMEDIATELY);
64
65 // Verify that acknowledgement is written to network.
66 EasyMock.verify(socketWrapper);
67
68 // Configure the mock to verify that no network write is made.
69 configureMockForNoAcknowledgementWrite(socketWrapper);
70
71 request.doRead(new DoNothingApplicationBufferHandler());
72
73 // Verify that acknowledgement is not written to network.
74 EasyMock.verify(socketWrapper);
75 }
76
77
78 @Test
79 public void test100ContinueExpectationOnRequestBodyRead() throws IOException {
80 // Tests that response.sendAcknowledgement is only called when
81 // request.doRead is called.
82
83 request.setExpectation(true);
84
85 // Configure the mock to verify that no network write is made.
86 configureMockForNoAcknowledgementWrite(socketWrapper);
87
88 protocol.setContinueResponseTiming(ContinueResponseTiming.ON_REQUEST_BODY_READ.toString());
89 response.action(ActionCode.ACK, ContinueResponseTiming.IMMEDIATELY);
90

Callers

nothing calls this directly

Calls 2

getRequestMethod · 0.65
getResponseMethod · 0.65

Tested by

no test coverage detected