use of com.linkedin.d2.balancer.clients.TrackerClientTest.TestCallback in project rest.li by linkedin.
the class DynamicClientTest method testClient.
@Test(groups = { "small", "back-end" }, dataProvider = "restOverStreamSwitch")
@SuppressWarnings("deprecation")
public void testClient(boolean restOverStream) throws URISyntaxException {
TestLoadBalancer balancer = new TestLoadBalancer(false);
DirectoryProvider dirProvider = new TestDirectoryProvider();
KeyMapperProvider keyMapperProvider = new TestKeyMapperProvider();
ClientFactoryProvider clientFactoryProvider = new TestClientFactoryProvider();
Facilities facilities = new DelegatingFacilities(dirProvider, keyMapperProvider, clientFactoryProvider);
DynamicClient client = new DynamicClient(balancer, facilities, restOverStream);
URI uri = URI.create("d2://test");
RestRequest restRequest = new RestRequestBuilder(uri).build();
TestCallback<RestResponse> restCallback = new TestCallback<RestResponse>();
client.restRequest(restRequest, restCallback);
assertNull(restCallback.e);
assertNotNull(restCallback.t);
Facilities myFacilities = client.getFacilities();
assertNotNull(facilities, "facilities should not be null");
}
use of com.linkedin.d2.balancer.clients.TrackerClientTest.TestCallback in project rest.li by linkedin.
the class DynamicClientTest method testUnavailable.
@Test(groups = { "small", "back-end" }, dataProvider = "restOverStreamSwitch")
public void testUnavailable(boolean restOverStream) throws URISyntaxException {
TestLoadBalancer balancer = new TestLoadBalancer(true);
DynamicClient client = new DynamicClient(balancer, null, restOverStream);
URI uri = URI.create("d2://test");
RestRequest restRequest = new RestRequestBuilder(uri).build();
TestCallback<RestResponse> restCallback = new TestCallback<RestResponse>();
client.restRequest(restRequest, restCallback);
assertNotNull(restCallback.e);
assertTrue(restCallback.e instanceof ServiceUnavailableException);
assertNull(restCallback.t);
Facilities facilities = client.getFacilities();
assertNull(facilities, "facilities should be null");
}
Aggregations