use of com.webpieces.http2.api.dto.lowlevel.lib.StreamMsg in project webpieces by deanhiller.
the class TestCMaxConcurrentSetting method testSend2ndRequestOnlyOnCompletionOfFirst.
@Test
public void testSend2ndRequestOnlyOnCompletionOfFirst() throws InterruptedException, ExecutionException {
RequestsSent sent = sendTwoRequests();
int streamId1 = sent.getRequest1().getRequest().getStreamId();
XFuture<StreamWriter> future2 = sent.getRequest2().getFuture();
RequestHolder holder1 = sent.getRequest1();
RequestHolder holder2 = sent.getRequest2();
MockResponseListener listener1 = holder1.getListener();
MockStreamWriter writer1 = holder1.getWriter();
// endOfStream=false
mockChannel.write(Requests.createResponse(streamId1));
listener1.getSingleReturnValueIncomingResponse();
// endOfStream=false
mockChannel.write(new DataFrame(streamId1, false));
writer1.getSingleFrame();
// at this point, should not have a call outstanding
mockChannel.assertNoIncomingMessages();
Assert.assertFalse(future2.isDone());
MockResponseListener listener2 = holder2.getListener();
MockStreamWriter writer2 = holder2.getWriter();
listener2.addReturnValueIncomingResponse(XFuture.completedFuture(writer2));
Assert.assertFalse(future2.isDone());
DataFrame dataFrame = new DataFrame(streamId1, true);
// endOfStream = true
mockChannel.write(dataFrame);
StreamMsg data = writer1.getSingleFrame();
Assert.assertEquals(dataFrame.getStreamId(), data.getStreamId());
Http2Headers frame = (Http2Headers) mockChannel.getFrameAndClear();
Assert.assertEquals(sent.getRequest2().getRequest(), frame);
Assert.assertTrue(future2.isDone());
}
Aggregations