Search in sources :

Example 26 with RestRequest

use of com.linkedin.r2.message.rest.RestRequest in project rest.li by linkedin.

the class AbstractCaptureFilterTest method testInitialCapture.

@Test
public void testInitialCapture() {
    final RestRequest req = request();
    final RestResponse res = response();
    Assert.assertNull(getDb().replay(req));
    FilterUtil.fireUntypedRequestResponse(getFilterChain(), req, res);
    Assert.assertEquals(res, getDb().<Response>replay(req));
}
Also used : RestRequest(com.linkedin.r2.message.rest.RestRequest) RestResponse(com.linkedin.r2.message.rest.RestResponse) Test(org.testng.annotations.Test)

Example 27 with RestRequest

use of com.linkedin.r2.message.rest.RestRequest in project rest.li by linkedin.

the class AbstractCaptureFilterTest method testException.

@Test
public void testException() {
    final RestRequest req = request();
    final Exception ex = new Exception();
    FilterUtil.fireUntypedRequestError(getFilterChain(), req, ex);
    // Request / response should not be recorded
    Assert.assertNull(getDb().replay(req));
}
Also used : RestRequest(com.linkedin.r2.message.rest.RestRequest) Test(org.testng.annotations.Test)

Example 28 with RestRequest

use of com.linkedin.r2.message.rest.RestRequest in project rest.li by linkedin.

the class AbstractCaptureFilterTest method testTwoDifferentRequests.

@Test
public void testTwoDifferentRequests() {
    final RestRequest req1 = request();
    final RestRequest req2 = req1.builder().setEntity("This is a different request".getBytes()).build();
    final RestResponse res1 = response();
    final RestResponse res2 = res1.builder().setEntity("This is a different response".getBytes()).build();
    FilterUtil.fireUntypedRequestResponse(getFilterChain(), req1, res1);
    FilterUtil.fireUntypedRequestResponse(getFilterChain(), req2, res2);
    // Should have created two separate entries
    Assert.assertEquals(res1, getDb().<Response>replay(req1));
    Assert.assertEquals(res2, getDb().<Response>replay(req2));
}
Also used : RestRequest(com.linkedin.r2.message.rest.RestRequest) RestResponse(com.linkedin.r2.message.rest.RestResponse) Test(org.testng.annotations.Test)

Example 29 with RestRequest

use of com.linkedin.r2.message.rest.RestRequest in project rest.li by linkedin.

the class AbstractReplayFilterTest method testReplayWithNoMatch.

@Test
public void testReplayWithNoMatch() {
    final RestRequest req = request();
    final RestResponse res = response();
    final CaptureLastCallFilter captureFilter = new CaptureLastCallFilter();
    final FilterChain fc = getFilterChain().addFirstRest(captureFilter);
    FilterUtil.fireUntypedRequestResponse(fc, req, res);
    Assert.assertEquals(res, captureFilter.getLastRes());
}
Also used : RestRequest(com.linkedin.r2.message.rest.RestRequest) CaptureLastCallFilter(com.linkedin.r2.testutils.filter.CaptureLastCallFilter) RestResponse(com.linkedin.r2.message.rest.RestResponse) FilterChain(com.linkedin.r2.filter.FilterChain) Test(org.testng.annotations.Test)

Example 30 with RestRequest

use of com.linkedin.r2.message.rest.RestRequest in project rest.li by linkedin.

the class TestDefaultMessageSerializer method testSimpleRestReq.

@Test
public void testSimpleRestReq() throws IOException {
    final RestRequest expected = new RestRequestBuilder(URI.create("http://localhost:1234")).build();
    assertMsgEquals(expected, _serializer.readRestRequest(getResource("simple-rest-req.txt")));
}
Also used : RestRequest(com.linkedin.r2.message.rest.RestRequest) RestRequestBuilder(com.linkedin.r2.message.rest.RestRequestBuilder) Test(org.testng.annotations.Test)

Aggregations

RestRequest (com.linkedin.r2.message.rest.RestRequest)293 Test (org.testng.annotations.Test)243 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)174 RequestContext (com.linkedin.r2.message.RequestContext)154 RestResponse (com.linkedin.r2.message.rest.RestResponse)147 URI (java.net.URI)124 ByteString (com.linkedin.data.ByteString)65 RoutingResult (com.linkedin.restli.internal.server.RoutingResult)62 FutureCallback (com.linkedin.common.callback.FutureCallback)50 RestException (com.linkedin.r2.message.rest.RestException)49 ResourceMethodDescriptor (com.linkedin.restli.internal.server.model.ResourceMethodDescriptor)44 ExecutionException (java.util.concurrent.ExecutionException)43 StreamResponse (com.linkedin.r2.message.stream.StreamResponse)38 ResourceModel (com.linkedin.restli.internal.server.model.ResourceModel)36 HashMap (java.util.HashMap)35 StreamRequest (com.linkedin.r2.message.stream.StreamRequest)33 Map (java.util.Map)28 Callback (com.linkedin.common.callback.Callback)27 URISyntaxException (java.net.URISyntaxException)25 ResourceContext (com.linkedin.restli.server.ResourceContext)24