Search in sources :

Example 11 with Response

use of com.linkedin.restli.client.Response in project rest.li by linkedin.

the class TestMultiplexerIntegration method singleCall.

@Test
public void singleCall() throws Exception {
    GetRequest<Greeting> request = new GreetingsCallbackBuilders().get().id(1L).build();
    FutureCallback<Response<Greeting>> muxCallback = new FutureCallback<Response<Greeting>>();
    FutureCallback<Response<Greeting>> directCallback = new FutureCallback<Response<Greeting>>();
    FutureCallback<MultiplexedResponse> aggregatedCallback = new FutureCallback<MultiplexedResponse>();
    MultiplexedRequest multiplexedRequest = MultiplexedRequestBuilder.createParallelRequest().addRequest(request, muxCallback).build();
    getClient().sendRequest(multiplexedRequest, aggregatedCallback);
    getClient().sendRequest(request, directCallback);
    assertEqualResponses(muxCallback, directCallback);
    MultiplexedResponse multiplexedResponse = aggregatedCallback.get();
    Assert.assertEquals(multiplexedResponse.getStatus(), HttpStatus.S_200_OK.getCode());
    Assert.assertFalse(multiplexedResponse.getHeaders().isEmpty());
}
Also used : Response(com.linkedin.restli.client.Response) Greeting(com.linkedin.restli.examples.greetings.api.Greeting) FutureCallback(com.linkedin.common.callback.FutureCallback) GreetingsCallbackBuilders(com.linkedin.restli.examples.greetings.client.GreetingsCallbackBuilders) RestLiIntegrationTest(com.linkedin.restli.examples.RestLiIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

Response (com.linkedin.restli.client.Response)11 Greeting (com.linkedin.restli.examples.greetings.api.Greeting)8 Test (org.testng.annotations.Test)8 FutureCallback (com.linkedin.common.callback.FutureCallback)6 RestLiIntegrationTest (com.linkedin.restli.examples.RestLiIntegrationTest)6 GreetingsCallbackBuilders (com.linkedin.restli.examples.greetings.client.GreetingsCallbackBuilders)6 CountDownLatch (java.util.concurrent.CountDownLatch)3 RestResponse (com.linkedin.r2.message.rest.RestResponse)2 RestLiResponseException (com.linkedin.restli.client.RestLiResponseException)2 CollectionResponse (com.linkedin.restli.common.CollectionResponse)2 ErrorResponse (com.linkedin.restli.common.ErrorResponse)2 IdResponse (com.linkedin.restli.common.IdResponse)2 ResponseFutureImpl (com.linkedin.restli.internal.client.ResponseFutureImpl)2 ArrayList (java.util.ArrayList)2 ExecutionException (java.util.concurrent.ExecutionException)2 Callback (com.linkedin.common.callback.Callback)1 HostSet (com.linkedin.d2.balancer.util.HostSet)1 ConsistentHashKeyMapper (com.linkedin.d2.balancer.util.hashing.ConsistentHashKeyMapper)1 ConsistentHashKeyMapperTest (com.linkedin.d2.balancer.util.hashing.ConsistentHashKeyMapperTest)1 FieldDef (com.linkedin.data.template.FieldDef)1