Esempio n. 1
0
 @Test
 public void afterMaxFailsDelayIsStill310ms() {
   for (int i = 0; i < 6; ++i) {
     cut.begin().recordFailure();
   }
   assertThat(cut.begin().delay(), is(approx(310L, 10)));
 }
Esempio n. 2
0
  @Test
  public void succeedResetsDelayTo0ms() {
    for (int i = 0; i < 4; ++i) {
      cut.begin().recordFailure();
    }
    assertThat(cut.begin().delay(), is(approx(150L, 10)));

    cut.begin().recordSuccess();
    assertThat(cut.begin().delay(), is(0L));
  }
Esempio n. 3
0
  @Test
  public void successOnOldAttemptDoesNotResetDelay() {
    cut.begin().recordFailure();
    cut.begin().recordFailure();

    Attempt attempt = cut.begin();
    cut.begin().recordFailure();
    assertThat(cut.begin().delay(), is(approx(70L, 10)));
    attempt.recordSuccess();
    assertThat(cut.begin().delay(), is(approx(70L, 10)));
  }
Esempio n. 4
0
  @Test
  public void failureOnOldAttemptDoesNotIncreaseDelay() {
    for (int i = 0; i < 3; ++i) {
      cut.begin().recordFailure();
    }

    Attempt attempt = cut.begin();
    cut.begin().recordFailure();
    assertThat(cut.begin().delay(), is(approx(150L, 10)));
    attempt.recordFailure();
    assertThat(cut.begin().delay(), is(approx(150L, 10)));
  }
Esempio n. 5
0
 @Test
 public void afterTwoFailsDelayIs30ms() {
   cut.begin().recordFailure();
   cut.begin().recordFailure();
   assertThat(cut.begin().delay(), is(approx(30L, 10)));
 }
Esempio n. 6
0
 @Test
 public void afterOneFailDelayIs10ms() {
   cut.begin().recordFailure();
   assertThat(cut.begin().delay(), is(approx(10L, 10)));
 }
Esempio n. 7
0
 @Test
 public void initialDelayIsZero() {
   Attempt attempt = cut.begin();
   assertThat(attempt.delay(), is(0L));
 }