@Override
    public boolean retryRequest(final HttpResponse response, final int executionCount, final HttpContext context) {
        switch(response.getStatusLine().getStatusCode()) {
            case HttpStatus.SC_MOVED_TEMPORARILY:
                try {
                    log.info(String.format("Attempt to refresh cookie for failure %s", response));
                    this.validate();
                    // Try again
                    return true;
                }
                catch(BackgroundException e) {
                    log.error(String.format("Failure refreshing cookie. %s", e));
                    return false;
                }
        }
        return false;
    }
@Test
    public void retryRequest() {
        final ServiceUnavailableRetryStrategy handler =
                new CustomServiceUnavailableRetryStrategy(session.getHost(), 2,
                        new ExecutionCountServiceUnavailableRetryStrategy(1, session.authentication));
        assertTrue(handler.retryRequest(
                new BasicHttpResponse(new BasicStatusLine(HTTP_1_1, HttpStatus.SC_SERVICE_UNAVAILABLE, "Service Unavailable")),
                1, new BasicHttpContext()));
        assertTrue(handler.retryRequest(
                new BasicHttpResponse(new BasicStatusLine(HTTP_1_1, HttpStatus.SC_SERVICE_UNAVAILABLE, "Service Unavailable")),
                2, new BasicHttpContext()));
        assertTrue(handler.retryRequest(
                new BasicHttpResponse(new BasicStatusLine(HTTP_1_1, HttpStatus.SC_MOVED_TEMPORARILY, "Service Unavailable")),
                1, new BasicHttpContext()));
        assertFalse(handler.retryRequest(
                new BasicHttpResponse(new BasicStatusLine(HTTP_1_1, HttpStatus.SC_MOVED_TEMPORARILY, "Service Unavailable")),
                2, new BasicHttpContext()));
    }