use of com.linkedin.d2.balancer.Facilities in project rest.li by linkedin.
the class ZKFSTest method testClientFactoryProvider.
@Test
public void testClientFactoryProvider() throws Exception {
startServer();
try {
ZKFSLoadBalancer balancer = getBalancer();
FutureCallback<None> callback = new FutureCallback<None>();
balancer.start(callback);
callback.get(30, TimeUnit.SECONDS);
Facilities facilities = balancer.getFacilities();
TransportClientFactory factory = facilities.getClientFactory("http");
Assert.assertNotNull(factory);
Assert.assertTrue(factory instanceof HttpClientFactory);
} finally {
stopServer();
}
}
use of com.linkedin.d2.balancer.Facilities 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.Facilities 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