RetryHandlerWrapper extends DefaultHttpRequestRetryHandler { @Override public boolean retryRequest( final IOException exception, final int executionCount, final HttpContext context) { return super.retryRequest(exception, executionCount, context) && retryHandler.retryRequest(exception, executionCount); } RetryHandlerWrapper(RetryHandler retryHandler); @Override boolean retryRequest(
      final IOException exception,
      final int executionCount,
      final HttpContext context);  }
@Test public void testForNonRetriableExceptions() throws Exception { RetryHandlerWrapper handler = new RetryHandlerWrapper(mock(RetryHandler.class)); assertThat(handler.retryRequest(mock(InterruptedIOException.class), 1, mock(HttpContext.class)), is(false)); assertThat(handler.retryRequest(mock(UnknownHostException.class), 1, mock(HttpContext.class)), is(false)); assertThat(handler.retryRequest(mock(ConnectException.class), 1, mock(HttpContext.class)), is(false)); assertThat(handler.retryRequest(mock(SSLException.class), 1, mock(HttpContext.class)), is(false)); }
@Test public void testForRetriableExceptions() throws Exception { RetryHandler retryHandler = mock(RetryHandler.class); RetryHandlerWrapper handler = new RetryHandlerWrapper(retryHandler); doReturn(true).when(retryHandler).retryRequest(any(IOException.class), anyInt()); assertThat(handler.retryRequest(mock(IOException.class), 29, mock(HttpContext.class)), is(true)); verify(retryHandler).retryRequest(any(IOException.class), eq(29)); }