Exemplo 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)));
 }
Exemplo 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));
  }
Exemplo 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)));
  }
Exemplo 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)));
  }
Exemplo n.º 5
0
 @Test
 public void afterTwoFailsDelayIs30ms() {
   cut.begin().recordFailure();
   cut.begin().recordFailure();
   assertThat(cut.begin().delay(), is(approx(30L, 10)));
 }
Exemplo n.º 6
0
 @Test
 public void afterOneFailDelayIs10ms() {
   cut.begin().recordFailure();
   assertThat(cut.begin().delay(), is(approx(10L, 10)));
 }
Exemplo n.º 7
0
 @Test
 public void initialDelayIsZero() {
   Attempt attempt = cut.begin();
   assertThat(attempt.delay(), is(0L));
 }