ExponentialBackOff implements BackOff { public ExponentialBackOff() { this(new Builder()); } ExponentialBackOff();  ExponentialBackOff(Builder builder); @Override long getBackOffInMillis(); @Override void reset(); long getInitialIntervalMillis(); long getMaximumIntervalMillis(); double getRandomizationFactor(); double getMultiplier(); int getMaximumRetries(); int getNumberOfRetries(); static final long INITIAL_INTERVAL_MILLIS; static final long MAXIMUM_INTERVAL_MILLIS; static final double RANDOMIZATION_FACTOR; static final double MULTIPLIER; static final int MAXIMUM_RETRIES; }
@Test public void testExponentialBackOff() { BackOff backOff = new ExponentialBackOff.Builder() .setInitialIntervalMillis(100) .setMaximumIntervalMillis(2700) .setMultiplier(3) .setRandomizationFactor(0) .setMaximumRetries(6) .build(); long[] expectedTimeouts = new long[] {100, 300, 900, 2700, 2700, 2700, -1}; for (long timeout : expectedTimeouts) { assertEquals(timeout, backOff.getBackOffInMillis()); } }