### Question:
ExponentialBackoff implements BackoffPolicy { public void backoff() { retryTime = Clock.unixTime() + sleepIncrement; sleepIncrement *= 2; backoffCount++; } ExponentialBackoff(long initialSleep, long max); void backoff(); boolean isRetryOk(); boolean isFailed(); void reset(); @Override long sleepIncrement(); @Override String getName(); @Override ReportEvent getReport(); @Override void waitUntilRetryOk(); final static public String A_INITIAL; final static public String A_COUNT; final static public String A_COUNTCAP; final static public String A_CURRENTBACKOFF; final static public String A_RETRYTIME; }### Answer:
@Test public void testBackoff() throws InterruptedException { Clock.setClock(mock); System.out.println(mock); ExponentialBackoff bo = new ExponentialBackoff(100, 5); Assert.assertTrue(bo.isRetryOk()); Assert.assertFalse(bo.isFailed()); mock.forward(1); System.out.println(mock); Assert.assertTrue(bo.isRetryOk()); Assert.assertFalse(bo.isFailed()); bo.backoff(); mock.forward(99); System.out.println(mock); Assert.assertFalse(bo.isFailed()); Assert.assertFalse(bo.isRetryOk()); mock.forward(1); System.out.println(mock); Assert.assertTrue(bo.isRetryOk()); Assert.assertFalse(bo.isFailed()); bo.reset(); bo.backoff(); bo.backoff(); bo.backoff(); bo.backoff(); bo.backoff(); mock.forward(1599); System.out.println(mock); Assert.assertFalse(bo.isRetryOk()); Assert.assertTrue(bo.isFailed()); mock.forward(1); System.out.println(mock); Assert.assertFalse(bo.isRetryOk()); Assert.assertTrue(bo.isFailed()); }