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));
}
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));
}
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));
}
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());
}
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")));
}
Aggregations