Examples of CaptureLastCallFilter


Examples of com.linkedin.r2.testutils.filter.CaptureLastCallFilter

  @SuppressWarnings("deprecation")
  public void testReplayWithNoMatch()
  {
    final Request req = request();
    final Response res = response();
    final CaptureLastCallFilter captureFilter = new CaptureLastCallFilter();
    final FilterChain fc = getFilterChain()
            .addFirst(captureFilter);

    FilterUtil.fireUntypedRequestResponse(fc, req, res);

    Assert.assertEquals(res, captureFilter.getLastRes());
  }
View Full Code Here

Examples of com.linkedin.r2.testutils.filter.CaptureLastCallFilter

  @Test
  public void testReplayWithMatch()
  {
    final Request req = request();
    final Response res = response();
    final CaptureLastCallFilter captureFilter = new CaptureLastCallFilter();
    final FilterChain fc = getFilterChain().addFirst(captureFilter);

    // Record a response for the request we will fire
    getDb().record(req, res);

    // We should be able to fire just the request - the response should be replayed from the
    // capture we set up above.
    FilterUtil.fireUntypedRequest(fc, req);
    Assert.assertEquals(res, captureFilter.getLastRes());
  }
View Full Code Here

Examples of com.linkedin.r2.testutils.filter.CaptureLastCallFilter

  public void testReplayWithRestException()
  {
    final Request req = request();
    final RestResponse res = new RestResponseBuilder().setStatus(RestStatus.NOT_FOUND).build();

    final CaptureLastCallFilter captureFilter = new CaptureLastCallFilter();
    final FilterChain fc = getFilterChain().addFirst(captureFilter);

    // Record a response for the request we will fire
    getDb().record(req, res);

    // We should be able to fire just the request - the response should be replayed from the
    // capture we set up above. The response should be a RestException since the status code is 404.
    FilterUtil.fireUntypedRequest(fc, req);

    Assert.assertTrue(captureFilter.getLastErr() instanceof RestException);
    Assert.assertEquals(res, ((RestException)captureFilter.getLastErr()).getResponse());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.