private HttpCommand toCommand(String commandName, Invocation invocation) { logger.trace(">> converting %s", commandName); HttpRequest request = annotationProcessor.apply(invocation); logger.trace("<< converted %s to %s", commandName, request.getRequestLine()); return new HttpCommand(request); }
private HttpCommand toCommand(String commandName, Invocation invocation) { logger.trace(">> converting %s", commandName); HttpRequest request = annotationProcessor.apply(invocation); logger.trace("<< converted %s to %s", commandName, request.getRequestLine()); return new HttpCommand(request); }
private HttpCommand toCommand(String commandName, Invocation invocation) { logger.trace(">> converting %s", commandName); HttpRequest request = annotationProcessor.apply(invocation); logger.trace("<< converted %s to %s", commandName, request.getRequestLine()); return new HttpCommand(request); }
private HttpCommand toCommand(String commandName, Invocation invocation) { logger.trace(">> converting %s", commandName); HttpRequest request = annotationProcessor.apply(invocation); logger.trace("<< converted %s to %s", commandName, request.getRequestLine()); return new HttpCommand(request); }
private HttpCommand toCommand(String commandName, Invocation invocation) { logger.trace(">> converting %s", commandName); HttpRequest request = annotationProcessor.apply(invocation); logger.trace("<< converted %s to %s", commandName, request.getRequestLine()); return new HttpCommand(request); }
private HttpCommand toCommand(String commandName, Invocation invocation) { logger.trace(">> converting %s", commandName); HttpRequest request = annotationProcessor.apply(invocation); logger.trace("<< converted %s to %s", commandName, request.getRequestLine()); return new HttpCommand(request); }
private static HttpResponseException returnResponseException(int code) { HttpResponse response = HttpResponse.builder().statusCode(code).build(); return new HttpResponseException(new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://stub") .build()), response); }
public static HttpResponseException returnResponseException(int code) { HttpResponse response = HttpResponse.builder().statusCode(code).build(); return new HttpResponseException(new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://stub") .build()), response); }
public static HttpResponseException returnResponseException(int code) { HttpResponse response = HttpResponse.builder().statusCode(code).build(); return new HttpResponseException(new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://stub") .build()), response); }
public static HttpResponseException returnResponseException(int code) { HttpResponse response = HttpResponse.builder().statusCode(code).build(); return new HttpResponseException(new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://stub") .build()), response); }
private static HttpResponseException returnResponseException(int code) { HttpResponse response = HttpResponse.builder().statusCode(code).build(); return new HttpResponseException(new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://stub") .build()), response); }
public void testMethodWithNoTimeoutCallGetDirectly() throws Exception { expect(config.getTimeoutNanos(get)).andReturn(Optional.<Long> absent()); expect(http.invoke(new HttpCommand(getRequest))).andReturn(response); replay(http, timeLimiter, fallback, config, future); invokeHttpMethod.apply(get); }
@SuppressWarnings("unchecked") public void testSubmitRunsFallbackCreateOnGet() throws Exception { IllegalStateException exception = new IllegalStateException(); expect(http.submit(new HttpCommand(getRequest))).andReturn( Futures.<HttpResponse> immediateFailedFuture(exception)); expect(fallback.create(exception)).andReturn(Futures.<HttpResponse> immediateFuture(fallbackResponse)); // not using the field, as you can see above we are making an immediate // failed future instead. future = createMock(ListenableFuture.class); replay(http, timeLimiter, fallback, config, future); assertEquals(ListenableFuture.class.cast(invokeHttpMethod.apply(asyncGet)).get(), fallbackResponse); } }
public void testMethodWithNoTimeoutCallGetDirectly() throws Exception { expect(config.getTimeoutNanos(asyncGet)).andReturn(Optional.<Long> absent()); expect(http.invoke(new HttpCommand(getRequest))).andReturn(response); replay(http, timeLimiter, fallback, config, future); invokeHttpMethod.apply(get); }
public void testDirectCallRunsFallbackCreateOrPropagate() throws Exception { IllegalStateException exception = new IllegalStateException(); expect(config.getTimeoutNanos(asyncGet)).andReturn(Optional.<Long> absent()); expect(http.invoke(new HttpCommand(getRequest))).andThrow(exception); expect(fallback.createOrPropagate(exception)).andReturn(fallbackResponse); replay(http, timeLimiter, fallback, config, future); assertEquals(invokeHttpMethod.apply(get), fallbackResponse); }
public void testDirectCallRunsFallbackCreateOrPropagate() throws Exception { IllegalStateException exception = new IllegalStateException(); expect(config.getTimeoutNanos(get)).andReturn(Optional.<Long> absent()); expect(http.invoke(new HttpCommand(getRequest))).andThrow(exception); expect(fallback.createOrPropagate(exception)).andReturn(fallbackResponse); replay(http, timeLimiter, fallback, config, future); assertEquals(invokeHttpMethod.apply(get), fallbackResponse); }
public void testAsyncMethodSubmitsRequest() throws Exception { expect(http.submit(new HttpCommand(getRequest))).andReturn(future); future.addListener(anyObject(Runnable.class), eq(userThreads)); replay(http, timeLimiter, fallback, config, future); invokeHttpMethod.apply(asyncGet); }
@Test public void testDescribeMethodIsRetried() throws Exception { AWSEC2IOExceptionRetryHandler handler = new AWSEC2IOExceptionRetryHandler(); IOException e = new IOException("test exception"); HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://test.endpoint.com/").addFormParam(FormParameters.ACTION, "DescribeInstance").build(); HttpCommand command = new HttpCommand(request); assertTrue(handler.shouldRetryRequest(command, e)); }
HttpCommand createHttpCommandForFailureCount(final int failureCount) { HttpCommand command = new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://localhost").build()); while (command.getFailureCount() != failureCount) command.incrementFailureCount(); return command; } }
@Test public void testDoesNotRetryWhenRateLimitError() { HttpCommand command = new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://localhost").build()); HttpResponse response = HttpResponse.builder().statusCode(429).addHeader(HttpHeaders.RETRY_AFTER, "15").build(); assertFalse(handler.shouldRetryRequest(command, response)); }