use of com.linkedin.r2.message.Response 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.Response 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.Response 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.Response 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.Response in project rest.li by linkedin.
the class TestStreamEcho method testDelayedEcho.
@Test
public void testDelayedEcho() throws Exception {
for (Client client : clients()) {
RestRequest restRequest = new RestRequestBuilder(Bootstrap.createHttpURI(PORT, DELAYED_ECHO_URI)).setEntity("wei ni hao ma?".getBytes()).build();
RestResponse response = client.restRequest(restRequest).get();
Assert.assertEquals(response.getEntity().asString(Charset.defaultCharset()), "wei ni hao ma?");
}
}
Aggregations