use of com.hotels.styx.client.connectionpool.ConnectionPool 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.client.connectionpool.ConnectionPool in project styx by ExpediaGroup.
the class StyxHostHttpClientTest method closesTheConnectionPool.
@Test
public void closesTheConnectionPool() {
ConnectionPool pool = mock(ConnectionPool.class);
StyxHostHttpClient hostClient = new StyxHostHttpClient(pool);
hostClient.close();
verify(pool).close();
}
use of com.hotels.styx.client.connectionpool.ConnectionPool 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"));
}
use of com.hotels.styx.client.connectionpool.ConnectionPool in project styx by ExpediaGroup.
the class DashboardDataTest method pool.
private RemoteHost pool(Origin origin) {
ConnectionPool pool = mock(ConnectionPool.class);
when(pool.getOrigin()).thenReturn(origin);
return remoteHost(origin, mock(HttpHandler.class), mock(LoadBalancingMetricSupplier.class));
}
Aggregations