use of com.linkedin.r2.RemoteInvocationException in project rest.li by linkedin.
the class TestMockFailedResponseFutureBuilder method testBuildWithEntityTreatServerErrorAsSuccess.
@Test
public void testBuildWithEntityTreatServerErrorAsSuccess() {
ResponseFuture<Greeting> future = buildWithEntity(ErrorHandlingBehavior.TREAT_SERVER_ERROR_AS_SUCCESS);
try {
Response<Greeting> response = future.getResponse();
Assert.assertEquals(response.getEntity(), new Greeting().setId(1L).setMessage("foo"));
Assert.assertEquals(response.getStatus(), 500);
Assert.assertEquals(response.getError().getStatus(), 500);
} catch (RemoteInvocationException e) {
Assert.fail("No exception should have been thrown!");
}
}
use of com.linkedin.r2.RemoteInvocationException in project rest.li by linkedin.
the class TestCompressionServer method testSearchWithoutDecompression.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "clientsCompressedResponsesBuilderDataProvider")
public void testSearchWithoutDecompression(RestClient client, String operationsForCompression, RootBuilderWrapper<Long, Greeting> builders, ProtocolVersion protocolVersion) throws RemoteInvocationException {
Request<CollectionResponse<Greeting>> findRequest = builders.findBy("Search").setQueryParam("tone", Tone.FRIENDLY).build();
RequestContext requestContext = new RequestContext();
RequestContextUtil.turnOffResponseDecompression(requestContext);
Map<String, Set<String>> methodsAndFamilies = getCompressionMethods(operationsForCompression);
Set<String> methods = methodsAndFamilies.get("methods");
Set<String> families = methodsAndFamilies.get("families");
if (shouldCompress(families, methods, "finder:search")) {
// The server sends a compressed response, but the client does not decompress it so it cannot read the response.
try {
client.sendRequest(findRequest, requestContext).getResponse();
Assert.fail("Expected RemoteInvocationException, but getResponse() succeeded.");
} catch (RemoteInvocationException e) {
Assert.assertEquals(e.getCause().getMessage(), "Could not decode REST response");
}
} else {
// The server doesn't compress the response in the first place, so the client can read the response.
client.sendRequest(findRequest, requestContext).getResponse();
}
}
use of com.linkedin.r2.RemoteInvocationException in project rest.li by linkedin.
the class TestDebugRequestHandlers method testParseqTraceDebugDeleteRequestHandlerRaw.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testParseqTraceDebugDeleteRequestHandlerRaw(RootBuilderWrapper<Long, Greeting> builders) throws URISyntaxException, ExecutionException, InterruptedException, RemoteInvocationException {
Long newId = createNewGreetingOnTheServer(builders);
RestRequest request = new RestRequestBuilder(new URI(URI_PREFIX + "greetingsPromise/" + newId + "/__debug/parseqtrace/raw")).setMethod("DELETE").setEntity(createNewGreetingBytes(newId)).build();
sendRequestAndVerifyParseqTraceRaw(request);
}
Aggregations