use of com.linkedin.r2.message.Request in project rest.li by linkedin.
the class TestDebugRequestHandlers method testParseqTraceDebugPutRequestHandlerRaw.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testParseqTraceDebugPutRequestHandlerRaw(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("PUT").setEntity(createNewGreetingBytes(newId)).build();
sendRequestAndVerifyParseqTraceRaw(request);
}
use of com.linkedin.r2.message.Request in project rest.li by linkedin.
the class TestDebugRequestHandlers method sendRequestAndVerifyParseqTracevisResponse.
private void sendRequestAndVerifyParseqTracevisResponse(RestRequest request) throws InterruptedException, ExecutionException {
Future<RestResponse> restResponseFuture = getDefaultTransportClient().restRequest(request);
RestResponse restResponse = restResponseFuture.get();
Assert.assertEquals(restResponse.getStatus(), 200);
List<String> contentTypeValues = restResponse.getHeaderValues(RestConstants.HEADER_CONTENT_TYPE);
Assert.assertTrue(contentTypeValues.size() == 1);
Assert.assertEquals(contentTypeValues.get(0), HEADER_VALUE_TEXT_HTML);
}
use of com.linkedin.r2.message.Request in project rest.li by linkedin.
the class TestDebugRequestHandlers method testParseqTraceDebugGetRequestHandlerTracevis.
@Test
public void testParseqTraceDebugGetRequestHandlerTracevis() throws URISyntaxException, ExecutionException, InterruptedException {
RestRequest request = new RestRequestBuilder(new URI(URI_PREFIX + "greetingsPromise/1/__debug/parseqtrace/tracevis")).setMethod("GET").build();
sendRequestAndVerifyParseqTracevisResponse(request);
}
use of com.linkedin.r2.message.Request in project rest.li by linkedin.
the class TestDebugRequestHandlers method testParseqTraceDebugDeleteRequestHandlerTracevis.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
public void testParseqTraceDebugDeleteRequestHandlerTracevis(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/tracevis")).setMethod("DELETE").setEntity(createNewGreetingBytes(newId)).build();
sendRequestAndVerifyParseqTracevisResponse(request);
}
use of com.linkedin.r2.message.Request in project rest.li by linkedin.
the class TestParseqTraceDebugRequestHandler method testResponseStreamingAttachmentsForbidden.
@Test
public void testResponseStreamingAttachmentsForbidden() {
//This test verifies that the ParseqTraceDebugRequestHandler aborts any potential outgoing response attachments
//set by a resource method.
final URI uri = URI.create("http://host/abc/12/__debug/parseqtrace/raw");
ParseqTraceDebugRequestHandler requestHandler = new ParseqTraceDebugRequestHandler();
RestRequestBuilder requestBuilder = new RestRequestBuilder(uri);
RestRequest request = requestBuilder.build();
RequestContext requestContext = new RequestContext();
final RequestExecutionCallback<RestResponse> callback = new RequestExecutionCallback<RestResponse>() {
@Override
public void onError(Throwable e, RequestExecutionReport executionReport, RestLiAttachmentReader requestAttachmentReader, RestLiResponseAttachments responseAttachments) {
Assert.fail("Request execution failed unexpectedly.");
}
@Override
public void onSuccess(RestResponse result, RequestExecutionReport executionReport, RestLiResponseAttachments responseAttachments) {
}
};
final RestLiTestAttachmentDataSource testAttachmentDataSource = RestLiTestAttachmentDataSource.createWithRandomPayload("1");
final RestLiResponseAttachments responseAttachments = new RestLiResponseAttachments.Builder().appendSingleAttachment(testAttachmentDataSource).build();
requestHandler.handleRequest(request, requestContext, new RestLiDebugRequestHandler.ResourceDebugRequestHandler() {
@Override
public void handleRequest(RestRequest request, RequestContext requestContext, RequestExecutionCallback<RestResponse> callback) {
RestResponse response = EasyMock.createMock(RestResponse.class);
//Provide some attachments that should be aborted.
callback.onSuccess(response, new RequestExecutionReportBuilder().build(), responseAttachments);
}
}, null, callback);
Assert.assertTrue(testAttachmentDataSource.dataSourceAborted());
}
Aggregations