use of com.linkedin.d2.balancer.clients.DegraderTrackerClientTest.TestTransportCallback in project rest.li by linkedin.
the class RewriteClientTest method testClient.
@Test(groups = { "small", "back-end" })
public void testClient() throws URISyntaxException {
URI uri = URI.create("http://test.linkedin.com/test");
String serviceName = "HistoryService";
TestClient wrappedClient = new TestClient();
RewriteClient client = new RewriteClient(serviceName, uri, wrappedClient);
assertEquals(client.getUri(), uri);
assertEquals(client.getServiceName(), serviceName);
assertEquals(client.getWrappedClient(), wrappedClient);
RestRequest restRequest = new RestRequestBuilder(URI.create("d2://HistoryService/getCube")).build();
Map<String, String> restWireAttrs = new HashMap<String, String>();
TestTransportCallback<RestResponse> restCallback = new TestTransportCallback<RestResponse>();
client.restRequest(restRequest, new RequestContext(), restWireAttrs, restCallback);
assertFalse(restCallback.response.hasError());
assertEquals(wrappedClient.restRequest.getHeaders(), restRequest.getHeaders());
assertEquals(wrappedClient.restRequest.getEntity(), restRequest.getEntity());
assertEquals(wrappedClient.restRequest.getMethod(), restRequest.getMethod());
// check the rewrite
assertEquals(wrappedClient.restRequest.getURI(), URI.create("http://test.linkedin.com/test/getCube"));
assertEquals(wrappedClient.restWireAttrs, restWireAttrs);
}
use of com.linkedin.d2.balancer.clients.DegraderTrackerClientTest.TestTransportCallback in project rest.li by linkedin.
the class RewriteClientTest method testPathAppend.
@Test
public void testPathAppend() {
URI uri = URI.create("http://test.linkedin.com:9876/test");
String serviceName = "HistoryService";
TestClient wrappedClient = new TestClient();
RewriteClient client = new RewriteClient(serviceName, uri, wrappedClient);
assertEquals(client.getUri(), uri);
assertEquals(client.getServiceName(), serviceName);
assertEquals(client.getWrappedClient(), wrappedClient);
RestRequest restRequest;
Map<String, String> restWireAttrs = new HashMap<String, String>();
TestTransportCallback<RestResponse> restCallback = new TestTransportCallback<RestResponse>();
restRequest = new RestRequestBuilder(URI.create("d2://HistoryService")).build();
client.restRequest(restRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, restRequest, restCallback, "http://test.linkedin.com:9876/test");
restRequest = new RestRequestBuilder(URI.create("d2://HistoryService/")).build();
client.restRequest(restRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, restRequest, restCallback, "http://test.linkedin.com:9876/test/");
restRequest = new RestRequestBuilder(URI.create("d2://HistoryService//")).build();
client.restRequest(restRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, restRequest, restCallback, "http://test.linkedin.com:9876/test//");
restRequest = new RestRequestBuilder(URI.create("d2://HistoryService/foo")).build();
client.restRequest(restRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, restRequest, restCallback, "http://test.linkedin.com:9876/test/foo");
restRequest = new RestRequestBuilder(URI.create("d2://HistoryService/foo/")).build();
client.restRequest(restRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, restRequest, restCallback, "http://test.linkedin.com:9876/test/foo/");
}
use of com.linkedin.d2.balancer.clients.DegraderTrackerClientTest.TestTransportCallback in project rest.li by linkedin.
the class RewriteClientTest method testWithQueryAndFragment.
@Test
public void testWithQueryAndFragment() {
URI uri = URI.create("http://test.linkedin.com/test");
String serviceName = "HistoryService";
TestClient wrappedClient = new TestClient();
RewriteClient client = new RewriteClient(serviceName, uri, wrappedClient);
assertEquals(client.getUri(), uri);
assertEquals(client.getServiceName(), serviceName);
assertEquals(client.getWrappedClient(), wrappedClient);
RestRequest restRequest = new RestRequestBuilder(URI.create("d2://HistoryService/getCube?bar=baz#fragId")).build();
Map<String, String> restWireAttrs = new HashMap<String, String>();
TestTransportCallback<RestResponse> restCallback = new TestTransportCallback<RestResponse>();
client.restRequest(restRequest, new RequestContext(), restWireAttrs, restCallback);
assertFalse(restCallback.response.hasError());
assertEquals(wrappedClient.restRequest.getHeaders(), restRequest.getHeaders());
assertEquals(wrappedClient.restRequest.getEntity(), restRequest.getEntity());
assertEquals(wrappedClient.restRequest.getMethod(), restRequest.getMethod());
assertEquals(wrappedClient.restRequest.getURI(), URI.create("http://test.linkedin.com/test/getCube?bar=baz#fragId"));
}
use of com.linkedin.d2.balancer.clients.DegraderTrackerClientTest.TestTransportCallback in project rest.li by linkedin.
the class RewriteClientTestStreamRequest method testPathAppend.
@Test
public void testPathAppend() {
URI uri = URI.create("http://test.linkedin.com:9876/test");
String serviceName = "HistoryService";
TestClient wrappedClient = new TestClient();
RewriteClient client = new RewriteClient(serviceName, uri, wrappedClient);
assertEquals(client.getUri(), uri);
assertEquals(client.getServiceName(), serviceName);
assertEquals(client.getWrappedClient(), wrappedClient);
StreamRequest streamRequest;
Map<String, String> restWireAttrs = new HashMap<String, String>();
TestTransportCallback<StreamResponse> restCallback = new TestTransportCallback<StreamResponse>();
streamRequest = getRequest("d2://HistoryService");
client.streamRequest(streamRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, streamRequest, restCallback, "http://test.linkedin.com:9876/test");
streamRequest = getRequest("d2://HistoryService/");
client.streamRequest(streamRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, streamRequest, restCallback, "http://test.linkedin.com:9876/test/");
streamRequest = getRequest("d2://HistoryService//");
client.streamRequest(streamRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, streamRequest, restCallback, "http://test.linkedin.com:9876/test//");
streamRequest = getRequest("d2://HistoryService/foo");
client.streamRequest(streamRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, streamRequest, restCallback, "http://test.linkedin.com:9876/test/foo");
streamRequest = getRequest("d2://HistoryService/foo/");
client.streamRequest(streamRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, streamRequest, restCallback, "http://test.linkedin.com:9876/test/foo/");
}
use of com.linkedin.d2.balancer.clients.DegraderTrackerClientTest.TestTransportCallback in project rest.li by linkedin.
the class RewriteLoadBalancerClientTest method testPathAppend.
@Test
public void testPathAppend() {
URI uri = URI.create("http://test.linkedin.com:9876/test");
String serviceName = "HistoryService";
TestClient wrappedClient = new TestClient();
RewriteLoadBalancerClient client = new RewriteLoadBalancerClient(serviceName, uri, wrappedClient);
assertEquals(client.getUri(), uri);
assertEquals(client.getServiceName(), serviceName);
RestRequest restRequest;
Map<String, String> restWireAttrs = new HashMap<>();
TestTransportCallback<RestResponse> restCallback = new TestTransportCallback<>();
restRequest = new RestRequestBuilder(URI.create("d2://HistoryService")).build();
client.restRequest(restRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, restRequest, restCallback, "http://test.linkedin.com:9876/test");
restRequest = new RestRequestBuilder(URI.create("d2://HistoryService/")).build();
client.restRequest(restRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, restRequest, restCallback, "http://test.linkedin.com:9876/test/");
restRequest = new RestRequestBuilder(URI.create("d2://HistoryService//")).build();
client.restRequest(restRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, restRequest, restCallback, "http://test.linkedin.com:9876/test//");
restRequest = new RestRequestBuilder(URI.create("d2://HistoryService/foo")).build();
client.restRequest(restRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, restRequest, restCallback, "http://test.linkedin.com:9876/test/foo");
restRequest = new RestRequestBuilder(URI.create("d2://HistoryService/foo/")).build();
client.restRequest(restRequest, new RequestContext(), restWireAttrs, restCallback);
checkRewrite(wrappedClient, restRequest, restCallback, "http://test.linkedin.com:9876/test/foo/");
}
Aggregations