use of com.hotels.styx.api.HttpInterceptor.Context in project styx by ExpediaGroup.
the class StyxHostHttpClientTest method returnsConnectionBackToPool.
@Test
public void returnsConnectionBackToPool() {
Connection connection = mockConnection(just(response));
ConnectionPool pool = mockPool(connection);
Context context = mockContext();
StyxHostHttpClient hostClient = new StyxHostHttpClient(pool);
StepVerifier.create(hostClient.sendRequest(request, context)).consumeNextWith(response -> response.consume()).expectComplete().verify();
verify(pool).borrowConnection();
verify(connection).write(any(LiveHttpRequest.class));
verify(pool).returnConnection(any(Connection.class));
verify(context).add(ORIGINID_CONTEXT_KEY, Id.id("mockorigin"));
}
use of com.hotels.styx.api.HttpInterceptor.Context in project styx by ExpediaGroup.
the class StyxHostHttpClientTest method terminatesConnectionWhenResponseObservableCompletesWithoutHeaders.
@Test
public void terminatesConnectionWhenResponseObservableCompletesWithoutHeaders() {
// A connection that yields no response:
Connection connection = mockConnection(Flux.empty());
ConnectionPool pool = mockPool(connection);
Context context = mockContext();
StyxHostHttpClient hostClient = new StyxHostHttpClient(pool);
StepVerifier.create(hostClient.sendRequest(request, context)).expectNextCount(0).expectComplete().log().verify();
verify(pool).closeConnection(any(Connection.class));
verify(context).add(ORIGINID_CONTEXT_KEY, Id.id("mockorigin"));
}
Aggregations