Search in sources :

Example 16 with PassedIn

use of org.webpieces.httpfrontend2.api.mock2.MockHttp2RequestListener.PassedIn in project webpieces by deanhiller.

the class AbstractHttp2Test method sendRequestToServer.

protected PassedIn sendRequestToServer(int streamId, boolean eos) {
    Http2Request request1 = Http2Requests.createRequest(streamId, eos);
    mockChannel.send(request1);
    PassedIn req = mockListener.getSingleRequest();
    Assert.assertEquals(request1, req.request);
    return req;
}
Also used : Http2Request(com.webpieces.hpack.api.dto.Http2Request) PassedIn(org.webpieces.httpfrontend2.api.mock2.MockHttp2RequestListener.PassedIn)

Example 17 with PassedIn

use of org.webpieces.httpfrontend2.api.mock2.MockHttp2RequestListener.PassedIn in project webpieces by deanhiller.

the class TestSBasicRequestResponse method testPushPromise.

@Test
public void testPushPromise() throws InterruptedException, ExecutionException, TimeoutException {
    Http2Request request1 = Http2Requests.createRequest(1, true);
    mockChannel.send(request1);
    PassedIn incoming = mockListener.getSingleRequest();
    Assert.assertEquals(request1, incoming.request);
    Http2Push push = Http2Requests.createPush(request1.getStreamId());
    CompletableFuture<PushPromiseListener> future = incoming.stream.openPushStream().process(push);
    PushPromiseListener pushWriter = future.get(2, TimeUnit.SECONDS);
    Http2Push pushRecv = (Http2Push) mockChannel.getFrameAndClear();
    Assert.assertEquals(push, pushRecv);
    Http2Response preEmptive = Http2Requests.createResponse(push.getPromisedStreamId());
    pushWriter.processPushResponse(preEmptive);
    Http2Headers preEmptRecv = (Http2Headers) mockChannel.getFrameAndClear();
    Assert.assertEquals(preEmptive, preEmptRecv);
    Http2Response response = Http2Requests.createResponse(request1.getStreamId());
    incoming.stream.sendResponse(response);
    Http2Headers responseRecv = (Http2Headers) mockChannel.getFrameAndClear();
    Assert.assertEquals(response, responseRecv);
}
Also used : Http2Response(com.webpieces.hpack.api.dto.Http2Response) PushPromiseListener(com.webpieces.http2engine.api.PushPromiseListener) Http2Request(com.webpieces.hpack.api.dto.Http2Request) Http2Headers(com.webpieces.hpack.api.dto.Http2Headers) Http2Push(com.webpieces.hpack.api.dto.Http2Push) PassedIn(org.webpieces.httpfrontend2.api.mock2.MockHttp2RequestListener.PassedIn) Test(org.junit.Test)

Example 18 with PassedIn

use of org.webpieces.httpfrontend2.api.mock2.MockHttp2RequestListener.PassedIn in project webpieces by deanhiller.

the class TestSBasicRequestResponse method testWithNoData.

@Test
public void testWithNoData() throws InterruptedException, ExecutionException, TimeoutException {
    Http2Request request1 = Http2Requests.createRequest(1, true);
    mockChannel.send(request1);
    PassedIn incoming = mockListener.getSingleRequest();
    Assert.assertEquals(request1, incoming.request);
    Http2Response resp = Http2Requests.createResponse(request1.getStreamId(), true);
    incoming.stream.sendResponse(resp);
    Http2Msg response = mockChannel.getFrameAndClear();
    Assert.assertEquals(resp, response);
}
Also used : Http2Response(com.webpieces.hpack.api.dto.Http2Response) Http2Request(com.webpieces.hpack.api.dto.Http2Request) Http2Msg(com.webpieces.http2parser.api.dto.lib.Http2Msg) PassedIn(org.webpieces.httpfrontend2.api.mock2.MockHttp2RequestListener.PassedIn) Test(org.junit.Test)

Aggregations

PassedIn (org.webpieces.httpfrontend2.api.mock2.MockHttp2RequestListener.PassedIn)18 Test (org.junit.Test)16 Http2Response (com.webpieces.hpack.api.dto.Http2Response)13 Http2Request (com.webpieces.hpack.api.dto.Http2Request)9 StreamWriter (com.webpieces.http2engine.api.StreamWriter)8 DataFrame (com.webpieces.http2parser.api.dto.DataFrame)8 DataWrapper (org.webpieces.data.api.DataWrapper)8 HttpRequest (org.webpieces.httpparser.api.dto.HttpRequest)8 Header (org.webpieces.httpparser.api.common.Header)7 HttpResponse (org.webpieces.httpparser.api.dto.HttpResponse)6 Http2Msg (com.webpieces.http2parser.api.dto.lib.Http2Msg)5 HttpPayload (org.webpieces.httpparser.api.dto.HttpPayload)5 Cancel (org.webpieces.httpfrontend2.api.mock2.MockHttp2RequestListener.Cancel)4 MockStreamWriter (org.webpieces.httpfrontend2.api.mock2.MockStreamWriter)4 HttpData (org.webpieces.httpparser.api.dto.HttpData)4 Http2Push (com.webpieces.hpack.api.dto.Http2Push)3 Http2Headers (com.webpieces.hpack.api.dto.Http2Headers)2 PushPromiseListener (com.webpieces.http2engine.api.PushPromiseListener)2 GoAwayFrame (com.webpieces.http2parser.api.dto.GoAwayFrame)2 ResponseStream (org.webpieces.frontend2.api.ResponseStream)2