Search in sources :

Example 1 with StreamMsg

use of com.webpieces.http2parser.api.dto.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();
    CompletableFuture<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(CompletableFuture.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());
}
Also used : StreamMsg(com.webpieces.http2parser.api.dto.lib.StreamMsg) Http2Headers(com.webpieces.hpack.api.dto.Http2Headers) MockStreamWriter(org.webpieces.http2client.mock.MockStreamWriter) StreamWriter(com.webpieces.http2engine.api.StreamWriter) RequestsSent(org.webpieces.http2client.util.RequestsSent) MockResponseListener(org.webpieces.http2client.mock.MockResponseListener) DataFrame(com.webpieces.http2parser.api.dto.DataFrame) RequestHolder(org.webpieces.http2client.util.RequestHolder) MockStreamWriter(org.webpieces.http2client.mock.MockStreamWriter) Test(org.junit.Test)

Aggregations

Http2Headers (com.webpieces.hpack.api.dto.Http2Headers)1 StreamWriter (com.webpieces.http2engine.api.StreamWriter)1 DataFrame (com.webpieces.http2parser.api.dto.DataFrame)1 StreamMsg (com.webpieces.http2parser.api.dto.lib.StreamMsg)1 Test (org.junit.Test)1 MockResponseListener (org.webpieces.http2client.mock.MockResponseListener)1 MockStreamWriter (org.webpieces.http2client.mock.MockStreamWriter)1 RequestHolder (org.webpieces.http2client.util.RequestHolder)1 RequestsSent (org.webpieces.http2client.util.RequestsSent)1