use of com.linkedin.r2.transport.common.bridge.client.TransportClient in project rest.li by linkedin.
the class TestHttpClientFactory method testClientShutdownBeingCalledMultipleTimes.
@Test
public void testClientShutdownBeingCalledMultipleTimes() throws InterruptedException, ExecutionException, TimeoutException {
HttpClientFactory factory = new HttpClientFactory.Builder().build();
TransportClient client = factory.getClient(Collections.<String, Object>emptyMap());
// first shutdown call
FutureCallback<None> clientShutdown = new FutureCallback<>();
client.shutdown(clientShutdown);
clientShutdown.get(30, TimeUnit.SECONDS);
// second shutdown call
clientShutdown = new FutureCallback<>();
client.shutdown(clientShutdown);
try {
clientShutdown.get(30, TimeUnit.SECONDS);
Assert.fail("should have thrown exception on the second shutdown call.");
} catch (ExecutionException ex) {
Assert.assertTrue(ex.getCause() instanceof IllegalStateException);
}
FutureCallback<None> shutdownCallback = new FutureCallback<>();
factory.shutdown(shutdownCallback);
shutdownCallback.get(30, TimeUnit.SECONDS);
}
use of com.linkedin.r2.transport.common.bridge.client.TransportClient in project rest.li by linkedin.
the class TestHttpNettyStreamClient method testUnsupportedRestRequest.
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testUnsupportedRestRequest() throws UnsupportedOperationException {
TransportClient client = new HttpClientBuilder(_eventLoop, _scheduler).buildStreamClient();
client.restRequest(null, new RequestContext(), new HashMap<>(), null);
Assert.fail("The Http Stream clients should throw UnsupportedOperationException when streamRequest is called");
}
Aggregations