@Test
public void testRetryUpToMaximumTimeWithFixedSleep() throws Exception {

  RetryPolicy policy = mock(RetryUpToMaximumTimeWithFixedSleep.class);
  long maxTime = 80L;
  RetryPolicy realPolicy = retryUpToMaximumTimeWithFixedSleep(maxTime, 10,
      TimeUnit.NANOSECONDS);
  setupMockPolicy(policy, realPolicy);
  UnreliableInterface unreliable = (UnreliableInterface)
    RetryProxy.create(UnreliableInterface.class, unreliableImpl, policy);
  unreliable.alwaysSucceeds();
  unreliable.failsOnceThenSucceeds();
  try {
    unreliable.failsTenTimesThenSucceeds();
    fail("Should fail");
  } catch (UnreliableException e) {
    // expected
    verify(policy, times((int)(maxTime/10) + 2)).shouldRetry(any(Exception.class),
        anyInt(), anyInt(), anyBoolean());
    assertEquals(RetryDecision.FAIL, caughtRetryAction.action);
    assertEquals(RetryUpToMaximumTimeWithFixedSleep.constructReasonString(
        maxTime, TimeUnit.NANOSECONDS), caughtRetryAction.reason);
  } catch (Exception e) {
    fail("Other exception other than UnreliableException should also get " +
        "failed.");
  }
}