use of org.webpieces.http2client.mock.MockPushListener in project webpieces by deanhiller.
the class AbstractTest method sendPushPromise.
protected void sendPushPromise(MockResponseListener listener1, int streamId, boolean eos) {
MockPushListener pushListener = new MockPushListener();
pushListener.setDefaultResponse(CompletableFuture.completedFuture(null));
listener1.addReturnValuePush(pushListener);
Http2Push push = Requests.createPush(streamId);
//endOfStream=false
mockChannel.write(push);
Assert.assertEquals(push, listener1.getSinglePush());
Http2Response preemptiveResponse = Requests.createEosResponse(2);
mockChannel.write(preemptiveResponse);
Http2Response frame2 = (Http2Response) pushListener.getSingleParam();
Assert.assertEquals(preemptiveResponse, frame2);
}
use of org.webpieces.http2client.mock.MockPushListener in project webpieces by deanhiller.
the class TestC5_1StreamStates method testSection5_1BadFrameReceivedInReservedRemoteState.
/**
* Receiving any type of frame other than HEADERS, RST_STREAM, or PRIORITY on a
* stream in this state MUST be treated as a connection
* error (Section 5.4.1) of type PROTOCOL_ERROR.
*/
@Test
public void testSection5_1BadFrameReceivedInReservedRemoteState() {
MockPushListener pushListener = new MockPushListener();
pushListener.setIncomingRespDefault(CompletableFuture.<Void>completedFuture(null));
MockResponseListener listener1 = new MockResponseListener();
listener1.setIncomingRespDefault(CompletableFuture.<StreamWriter>completedFuture(null));
listener1.addReturnValuePush(pushListener);
Http2Request request = sendRequestToServer(listener1);
Http2Push push = sendPushFromServer(listener1, request);
DataFrame dataFrame = new DataFrame(push.getPromisedStreamId(), false);
mockChannel.write(dataFrame);
//remote receives goAway
GoAwayFrame goAway = (GoAwayFrame) mockChannel.getFrameAndClear();
Assert.assertEquals(Http2ErrorCode.PROTOCOL_ERROR, goAway.getKnownErrorCode());
DataWrapper debugData = goAway.getDebugData();
String msg = debugData.createStringFromUtf8(0, debugData.getReadableSize());
Assert.assertEquals("ConnectionException: MockHttp2Channel1:stream2:(BAD_FRAME_RECEIVED_FOR_THIS_STATE) " + "No transition defined on statemachine for event=RECV_DATA when in state=Reserved(remote)", msg);
Assert.assertTrue(mockChannel.isClosed());
ShutdownStream failResp1 = (ShutdownStream) listener1.getSingleRstStream();
Assert.assertEquals(CancelReasonCode.BAD_FRAME_RECEIVED_FOR_THIS_STATE, failResp1.getCause().getReasonCode());
ShutdownStream failResp2 = (ShutdownStream) listener1.getSingleCancelPush();
Assert.assertEquals(CancelReasonCode.BAD_FRAME_RECEIVED_FOR_THIS_STATE, failResp2.getCause().getReasonCode());
}
Aggregations