Search in sources :

Example 1 with HttpConnectionContext

use of io.servicetalk.http.api.HttpConnectionContext in project servicetalk by apple.

the class ProxyConnectConnectionFactoryFilterTest method cannotAccessNettyChannel.

@Test
void cannotAccessNettyChannel() {
    // Does not implement NettyConnectionContext:
    HttpExecutionContext executionContext = new HttpExecutionContextBuilder().build();
    HttpConnectionContext connectionContext = (mock(HttpConnectionContext.class));
    when(connectionContext.executionContext()).thenReturn(executionContext);
    when(connection.connectionContext()).thenReturn(connectionContext);
    configureRequestSend();
    configureConnectRequest();
    subscribeToProxyConnectionFactory();
    assertThat(subscriber.awaitOnError(), instanceOf(ClassCastException.class));
    assertConnectPayloadConsumed(false);
    assertConnectionClosed();
}
Also used : HttpConnectionContext(io.servicetalk.http.api.HttpConnectionContext) HttpExecutionContext(io.servicetalk.http.api.HttpExecutionContext) Test(org.junit.jupiter.api.Test)

Example 2 with HttpConnectionContext

use of io.servicetalk.http.api.HttpConnectionContext in project servicetalk by apple.

the class TimeoutHttpRequesterFilterTest method applyFilter.

private static Single<StreamingHttpResponse> applyFilter(TimeoutHttpRequesterFilter filterFactory, final HttpExecutionStrategy strategy, final Single<StreamingHttpResponse> responseSingle) {
    HttpExecutionContext executionContext = new DefaultHttpExecutionContext(DEFAULT_ALLOCATOR, IO_EXECUTOR, EXECUTOR, strategy);
    HttpConnectionContext connectionContext = mock(HttpConnectionContext.class);
    when(connectionContext.executionContext()).thenReturn(executionContext);
    FilterableStreamingHttpConnection connection = mock(FilterableStreamingHttpConnection.class);
    when(connection.executionContext()).thenReturn(executionContext);
    when(connection.request(any())).thenReturn(responseSingle);
    StreamingHttpRequester requester = filterFactory.create(connection);
    return requester.request(mock(StreamingHttpRequest.class));
}
Also used : StreamingHttpRequester(io.servicetalk.http.api.StreamingHttpRequester) HttpConnectionContext(io.servicetalk.http.api.HttpConnectionContext) DefaultHttpExecutionContext(io.servicetalk.http.api.DefaultHttpExecutionContext) HttpExecutionContext(io.servicetalk.http.api.HttpExecutionContext) FilterableStreamingHttpConnection(io.servicetalk.http.api.FilterableStreamingHttpConnection) DefaultHttpExecutionContext(io.servicetalk.http.api.DefaultHttpExecutionContext) StreamingHttpRequest(io.servicetalk.http.api.StreamingHttpRequest)

Aggregations

HttpConnectionContext (io.servicetalk.http.api.HttpConnectionContext)2 HttpExecutionContext (io.servicetalk.http.api.HttpExecutionContext)2 DefaultHttpExecutionContext (io.servicetalk.http.api.DefaultHttpExecutionContext)1 FilterableStreamingHttpConnection (io.servicetalk.http.api.FilterableStreamingHttpConnection)1 StreamingHttpRequest (io.servicetalk.http.api.StreamingHttpRequest)1 StreamingHttpRequester (io.servicetalk.http.api.StreamingHttpRequester)1 Test (org.junit.jupiter.api.Test)1