Search in sources :

Example 1 with GreetingsCallbackBuilders

use of com.linkedin.restli.examples.greetings.client.GreetingsCallbackBuilders in project rest.li by linkedin.

the class TestMultiplexerIntegration method twoSequentialCalls.

@Test
public void twoSequentialCalls() throws Exception {
    GetRequest<Greeting> request1 = new GreetingsCallbackBuilders().get().id(1L).build();
    FutureCallback<Response<Greeting>> muxCallback1 = new FutureCallback<Response<Greeting>>();
    FutureCallback<Response<Greeting>> directCallback1 = new FutureCallback<Response<Greeting>>();
    GetRequest<Greeting> request2 = new GreetingsCallbackBuilders().get().id(2L).build();
    FutureCallback<Response<Greeting>> muxCallback2 = new FutureCallback<Response<Greeting>>();
    FutureCallback<Response<Greeting>> directCallback2 = new FutureCallback<Response<Greeting>>();
    MultiplexedRequest multiplexedRequest = MultiplexedRequestBuilder.createSequentialRequest().addRequest(request1, muxCallback1).addRequest(request2, muxCallback2).build();
    getClient().sendRequest(multiplexedRequest);
    getClient().sendRequest(request1, directCallback1);
    getClient().sendRequest(request2, directCallback2);
    assertEqualResponses(muxCallback1, directCallback1);
    assertEqualResponses(muxCallback2, directCallback2);
}
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)

Example 2 with GreetingsCallbackBuilders

use of com.linkedin.restli.examples.greetings.client.GreetingsCallbackBuilders in project rest.li by linkedin.

the class TestMultiplexerIntegration method twoSequentialCallsWithOneError.

@Test
public void twoSequentialCallsWithOneError() throws Exception {
    GetRequest<Greeting> request1 = new GreetingsCallbackBuilders().get().id(1L).build();
    FutureCallback<Response<Greeting>> muxCallback1 = new FutureCallback<Response<Greeting>>();
    FutureCallback<Response<Greeting>> directCallback1 = new FutureCallback<Response<Greeting>>();
    GetRequest<Greeting> request2 = new GreetingsCallbackBuilders().get().id(Long.MAX_VALUE).build();
    FutureCallback<Response<Greeting>> muxCallback2 = new FutureCallback<Response<Greeting>>();
    FutureCallback<Response<Greeting>> directCallback2 = new FutureCallback<Response<Greeting>>();
    MultiplexedRequest multiplexedRequest = MultiplexedRequestBuilder.createSequentialRequest().addRequest(request1, muxCallback1).addRequest(request2, muxCallback2).build();
    getClient().sendRequest(multiplexedRequest);
    getClient().sendRequest(request1, directCallback1);
    getClient().sendRequest(request2, directCallback2);
    assertEqualResponses(muxCallback1, directCallback1);
    assertEqualErrors(muxCallback2, directCallback2);
}
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)

Example 3 with GreetingsCallbackBuilders

use of com.linkedin.restli.examples.greetings.client.GreetingsCallbackBuilders in project rest.li by linkedin.

the class TestMultiplexerIntegration method twoParallelCalls.

@Test
public void twoParallelCalls() throws Exception {
    GetRequest<Greeting> request1 = new GreetingsCallbackBuilders().get().id(1L).build();
    FutureCallback<Response<Greeting>> muxCallback1 = new FutureCallback<Response<Greeting>>();
    FutureCallback<Response<Greeting>> directCallback1 = new FutureCallback<Response<Greeting>>();
    GetRequest<Greeting> request2 = new GreetingsCallbackBuilders().get().id(2L).build();
    FutureCallback<Response<Greeting>> muxCallback2 = new FutureCallback<Response<Greeting>>();
    FutureCallback<Response<Greeting>> directCallback2 = new FutureCallback<Response<Greeting>>();
    MultiplexedRequest multiplexedRequest = MultiplexedRequestBuilder.createParallelRequest().addRequest(request1, muxCallback1).addRequest(request2, muxCallback2).build();
    getClient().sendRequest(multiplexedRequest);
    getClient().sendRequest(request1, directCallback1);
    getClient().sendRequest(request2, directCallback2);
    assertEqualResponses(muxCallback1, directCallback1);
    assertEqualResponses(muxCallback2, directCallback2);
}
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)

Example 4 with GreetingsCallbackBuilders

use of com.linkedin.restli.examples.greetings.client.GreetingsCallbackBuilders in project rest.li by linkedin.

the class TestMultiplexerIntegration method singleCallWithError.

@Test
public void singleCallWithError() throws Exception {
    GetRequest<Greeting> request = new GreetingsCallbackBuilders().get().id(Long.MAX_VALUE).build();
    FutureCallback<Response<Greeting>> muxCallback = new FutureCallback<Response<Greeting>>();
    FutureCallback<Response<Greeting>> directCallback = new FutureCallback<Response<Greeting>>();
    MultiplexedRequest multiplexedRequest = MultiplexedRequestBuilder.createParallelRequest().addRequest(request, muxCallback).build();
    getClient().sendRequest(multiplexedRequest);
    getClient().sendRequest(request, directCallback);
    assertEqualErrors(muxCallback, directCallback);
}
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)

Example 5 with GreetingsCallbackBuilders

use of com.linkedin.restli.examples.greetings.client.GreetingsCallbackBuilders in project rest.li by linkedin.

the class TestMultiplexerIntegration method twoParallelCallsWithOneError.

@Test
public void twoParallelCallsWithOneError() throws Exception {
    GetRequest<Greeting> request1 = new GreetingsCallbackBuilders().get().id(1L).build();
    FutureCallback<Response<Greeting>> muxCallback1 = new FutureCallback<Response<Greeting>>();
    FutureCallback<Response<Greeting>> directCallback1 = new FutureCallback<Response<Greeting>>();
    GetRequest<Greeting> request2 = new GreetingsCallbackBuilders().get().id(Long.MAX_VALUE).build();
    FutureCallback<Response<Greeting>> muxCallback2 = new FutureCallback<Response<Greeting>>();
    FutureCallback<Response<Greeting>> directCallback2 = new FutureCallback<Response<Greeting>>();
    MultiplexedRequest multiplexedRequest = MultiplexedRequestBuilder.createParallelRequest().addRequest(request1, muxCallback1).addRequest(request2, muxCallback2).build();
    getClient().sendRequest(multiplexedRequest);
    getClient().sendRequest(request1, directCallback1);
    getClient().sendRequest(request2, directCallback2);
    assertEqualResponses(muxCallback1, directCallback1);
    assertEqualErrors(muxCallback2, directCallback2);
}
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

FutureCallback (com.linkedin.common.callback.FutureCallback)6 Response (com.linkedin.restli.client.Response)6 RestLiIntegrationTest (com.linkedin.restli.examples.RestLiIntegrationTest)6 Greeting (com.linkedin.restli.examples.greetings.api.Greeting)6 GreetingsCallbackBuilders (com.linkedin.restli.examples.greetings.client.GreetingsCallbackBuilders)6 Test (org.testng.annotations.Test)6