@Test public void testWithMoreThanOneWaitStrategyOneBeingIncremental() throws Exception { Callable<Boolean> callable = notNullAfter5Attempts(); Retryer retryer = RetryerBuilder.newBuilder() .withWaitStrategy(WaitStrategies.join( WaitStrategies.incrementingWait(10L, TimeUnit.MILLISECONDS, 10L, TimeUnit.MILLISECONDS), WaitStrategies.fibonacciWait(10, Long.MAX_VALUE, TimeUnit.MILLISECONDS))) .retryIfResult(Objects::isNull) .build(); long start = System.currentTimeMillis(); boolean result = retryer.call(callable); assertTrue(System.currentTimeMillis() - start >= 270L); assertTrue(result); }
@Test public void testIncrementingWait() { WaitStrategy incrementingWait = WaitStrategies.incrementingWait(500L, TimeUnit.MILLISECONDS, 100L, TimeUnit.MILLISECONDS); assertEquals(500L, incrementingWait.computeSleepTime(failedAttempt(1, 6546L))); assertEquals(600L, incrementingWait.computeSleepTime(failedAttempt(2, 6546L))); assertEquals(700L, incrementingWait.computeSleepTime(failedAttempt(3, 6546L))); }