use of com.linkedin.r2.filter.transport.ClientRetryFilter in project rest.li by linkedin.
the class TestClientRetryFilter method testRetryFilter.
@Test
public void testRetryFilter() {
String retryMessage = "this is a retry";
ClientRetryFilter clientRetryFilter = new ClientRetryFilter();
RestFilter captureFilter = new RestFilter() {
@Override
public void onRestError(Throwable ex, RequestContext requestContext, Map<String, String> wireAttrs, NextFilter<RestRequest, RestResponse> nextFilter) {
Assert.assertTrue(ex instanceof RetriableRequestException);
Assert.assertEquals(retryMessage, ex.getMessage());
}
};
Map<String, String> wireAttributes = new HashMap<>();
wireAttributes.put(R2Constants.RETRY_MESSAGE_ATTRIBUTE_KEY, retryMessage);
FilterChain filterChain = FilterChains.createRestChain(captureFilter, clientRetryFilter);
FilterUtil.fireRestError(filterChain, new RemoteInvocationException("exception"), wireAttributes);
}
use of com.linkedin.r2.filter.transport.ClientRetryFilter in project rest.li by linkedin.
the class TestClientRetryFilter method testNoWireAttribute.
@Test
public void testNoWireAttribute() {
ClientRetryFilter clientRetryFilter = new ClientRetryFilter();
RemoteInvocationException exception = new RemoteInvocationException("exception");
RestFilter captureFilter = new RestFilter() {
@Override
public void onRestError(Throwable ex, RequestContext requestContext, Map<String, String> wireAttrs, NextFilter<RestRequest, RestResponse> nextFilter) {
Assert.assertEquals(exception, ex);
}
};
FilterChain filterChain = FilterChains.createRestChain(captureFilter, clientRetryFilter);
FilterUtil.fireRestError(filterChain, exception, new HashMap<>());
}
Aggregations