use of com.linkedin.d2.balancer.clients.DegraderTrackerClientTest.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 {
LoadBalancerMock balancer = new LoadBalancerMock(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<>();
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");
}
use of com.linkedin.d2.balancer.clients.DegraderTrackerClientTest.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 {
LoadBalancerMock balancer = new LoadBalancerMock(false);
DirectoryProvider dirProvider = new DirectoryProviderMock();
KeyMapperProvider keyMapperProvider = new KeyMapperProviderMock();
ClientFactoryProvider clientFactoryProvider = Mockito.mock(ClientFactoryProvider.class);
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<>();
client.restRequest(restRequest, restCallback);
assertNull(restCallback.e);
assertNotNull(restCallback.t);
Facilities myFacilities = client.getFacilities();
assertNotNull(facilities, "facilities should not be null");
}
Aggregations