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); }
public void testMethodWithTimeoutRunsTimeLimiter() throws Exception { expect(config.getTimeoutNanos(get)).andReturn(Optional.of(250000000L)); InvokeAndTransform invoke = invokeHttpMethod.new InvokeAndTransform("ns:get", getCommand); expect(timeLimiter.callWithTimeout(invoke, 250000000, TimeUnit.NANOSECONDS, true)).andReturn(response); replay(http, timeLimiter, fallback, config); invokeHttpMethod.apply(get); }
public void testMethodWithTimeoutRunsTimeLimiter() throws Exception { expect(config.getTimeoutNanos(get)).andReturn(Optional.of(250000000l)); InvokeAndTransform invoke = invokeHttpMethod.new InvokeAndTransform("ns:get", getCommand); expect(timeLimiter.callWithTimeout(invoke, 250000000, TimeUnit.NANOSECONDS, true)).andReturn(response); replay(http, timeLimiter, fallback, config, future); invokeHttpMethod.apply(get); }
public void testTimeLimitedRunsFallbackCreateOrPropagate() throws Exception { IllegalStateException exception = new IllegalStateException(); expect(config.getTimeoutNanos(get)).andReturn(Optional.of(250000000l)); InvokeAndTransform invoke = invokeHttpMethod.new InvokeAndTransform("ns:get", getCommand); expect(timeLimiter.callWithTimeout(invoke, 250000000, TimeUnit.NANOSECONDS, true)).andThrow(exception); expect(fallback.createOrPropagate(exception)).andReturn(fallbackResponse); replay(http, timeLimiter, fallback, config, future); assertEquals(invokeHttpMethod.apply(get), fallbackResponse); } }
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); invokeHttpMethod.apply(get); }
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 testTimeLimitedRunsFallbackCreateOrPropagate() throws Exception { IllegalStateException exception = new IllegalStateException(); expect(config.getTimeoutNanos(get)).andReturn(Optional.of(250000000L)); InvokeAndTransform invoke = invokeHttpMethod.new InvokeAndTransform("ns:get", getCommand); expect(timeLimiter.callWithTimeout(invoke, 250000000, TimeUnit.NANOSECONDS, true)).andThrow(exception); expect(fallback.createOrPropagate(exception)).andReturn(fallbackResponse); replay(http, timeLimiter, fallback, config); 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); assertEquals(invokeHttpMethod.apply(get), fallbackResponse); }