Search in sources :

Example 1 with DirectoryProvider

use of com.linkedin.d2.balancer.util.DirectoryProvider 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");
}
Also used : RestResponse(com.linkedin.r2.message.rest.RestResponse) KeyMapperProvider(com.linkedin.d2.balancer.util.KeyMapperProvider) ClientFactoryProvider(com.linkedin.d2.balancer.util.ClientFactoryProvider) TestCallback(com.linkedin.d2.balancer.clients.TrackerClientTest.TestCallback) URI(java.net.URI) Facilities(com.linkedin.d2.balancer.Facilities) DelegatingFacilities(com.linkedin.d2.balancer.util.DelegatingFacilities) RestRequest(com.linkedin.r2.message.rest.RestRequest) DirectoryProvider(com.linkedin.d2.balancer.util.DirectoryProvider) RestRequestBuilder(com.linkedin.r2.message.rest.RestRequestBuilder) DelegatingFacilities(com.linkedin.d2.balancer.util.DelegatingFacilities) Test(org.testng.annotations.Test)

Aggregations

Facilities (com.linkedin.d2.balancer.Facilities)1 TestCallback (com.linkedin.d2.balancer.clients.TrackerClientTest.TestCallback)1 ClientFactoryProvider (com.linkedin.d2.balancer.util.ClientFactoryProvider)1 DelegatingFacilities (com.linkedin.d2.balancer.util.DelegatingFacilities)1 DirectoryProvider (com.linkedin.d2.balancer.util.DirectoryProvider)1 KeyMapperProvider (com.linkedin.d2.balancer.util.KeyMapperProvider)1 RestRequest (com.linkedin.r2.message.rest.RestRequest)1 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)1 RestResponse (com.linkedin.r2.message.rest.RestResponse)1 URI (java.net.URI)1 Test (org.testng.annotations.Test)1