@Test public void test302DoesNotRetryAfterLimit() { HttpCommand command = createMock(HttpCommand.class); HttpResponse response = new HttpResponse( 302, "HTTP/1.1 302 Found", null, ImmutableMultimap.of( HttpHeaders.LOCATION, "/api/v0.8b-ext2.5/Error.aspx?aspxerrorpath=/api/v0.8b-ext2.5/org.svc/1906645")); expect(command.incrementRedirectCount()).andReturn(5); replay(command); RedirectionRetryHandler retry = Guice.createInjector(new MockModule(), new RestModule()) .getInstance(RedirectionRetryHandler.class); assert !retry.shouldRetryRequest(command, response); verify(command); }
protected void verifyRedirectRoutes( HttpRequest request, HttpResponse response, HttpRequest expected) { HttpCommand command = createMock(HttpCommand.class); expect(command.incrementRedirectCount()).andReturn(0); expect(command.getCurrentRequest()).andReturn(request); command.setCurrentRequest(expected); replay(command); RedirectionRetryHandler retry = Guice.createInjector(new MockModule(), new RestModule()) .getInstance(RedirectionRetryHandler.class); assert retry.shouldRetryRequest(command, response); verify(command); }
@Test public void test302DoesNotRetry() { HttpCommand command = createMock(HttpCommand.class); HttpResponse response = new HttpResponse(302, "HTTP/1.1 302 Found", null); expect(command.incrementRedirectCount()).andReturn(0); replay(command); RedirectionRetryHandler retry = Guice.createInjector(new MockModule(), new RestModule()) .getInstance(RedirectionRetryHandler.class); assert !retry.shouldRetryRequest(command, response); verify(command); }