@Test
public void testBackoff() throws InterruptedException {

  Clock.setClock(mock);
  System.out.println(mock);
  ExponentialBackoff bo = new ExponentialBackoff(100, 5);
  // time = 0
  Assert.assertTrue(bo.isRetryOk());
  Assert.assertFalse(bo.isFailed());
  mock.forward(1); // time = 1
  System.out.println(mock);
  Assert.assertTrue(bo.isRetryOk());
  Assert.assertFalse(bo.isFailed());
  // should be ok in +100, but not at +99
  bo.backoff();
  mock.forward(99);
  System.out.println(mock);
  Assert.assertFalse(bo.isFailed());
  Assert.assertFalse(bo.isRetryOk());
  mock.forward(1); // time = 100
  System.out.println(mock);
  Assert.assertTrue(bo.isRetryOk());
  Assert.assertFalse(bo.isFailed());
  // we were succesfull
  bo.reset();
  // I'm going to cheat and max out backoff.. (note: i should fastforward
  // time.)
  bo.backoff(); // 100
  bo.backoff(); // 200
  bo.backoff(); // 400
  bo.backoff(); // 800
  bo.backoff(); // 1600
  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()); // still should be false despite time out
  // because in failed state
  Assert.assertTrue(bo.isFailed());
}