use of org.springframework.util.backoff.BackOffExecution in project spring-framework by spring-projects.
the class FixedBackOffTests method toStringContent.
@Test
void toStringContent() {
FixedBackOff backOff = new FixedBackOff(200L, 10);
BackOffExecution execution = backOff.start();
assertThat(execution.toString()).isEqualTo("FixedBackOff{interval=200, currentAttempts=0, maxAttempts=10}");
execution.nextBackOff();
assertThat(execution.toString()).isEqualTo("FixedBackOff{interval=200, currentAttempts=1, maxAttempts=10}");
execution.nextBackOff();
assertThat(execution.toString()).isEqualTo("FixedBackOff{interval=200, currentAttempts=2, maxAttempts=10}");
}
use of org.springframework.util.backoff.BackOffExecution in project spring-framework by spring-projects.
the class ExponentialBackOffTests method toStringContent.
@Test
void toStringContent() {
ExponentialBackOff backOff = new ExponentialBackOff(2000L, 2.0);
BackOffExecution execution = backOff.start();
assertThat(execution.toString()).isEqualTo("ExponentialBackOff{currentInterval=n/a, multiplier=2.0}");
execution.nextBackOff();
assertThat(execution.toString()).isEqualTo("ExponentialBackOff{currentInterval=2000ms, multiplier=2.0}");
execution.nextBackOff();
assertThat(execution.toString()).isEqualTo("ExponentialBackOff{currentInterval=4000ms, multiplier=2.0}");
}
use of org.springframework.util.backoff.BackOffExecution in project spring-framework by spring-projects.
the class ExponentialBackOffTests method maxIntervalReachedImmediately.
@Test
void maxIntervalReachedImmediately() {
ExponentialBackOff backOff = new ExponentialBackOff(1000L, 2.0);
backOff.setMaxInterval(50L);
BackOffExecution execution = backOff.start();
assertThat(execution.nextBackOff()).isEqualTo(50L);
assertThat(execution.nextBackOff()).isEqualTo(50L);
}
use of org.springframework.util.backoff.BackOffExecution in project spring-framework by spring-projects.
the class ExponentialBackOffTests method fixedIncrease.
@Test
void fixedIncrease() {
ExponentialBackOff backOff = new ExponentialBackOff(100L, 1.0);
backOff.setMaxElapsedTime(300L);
BackOffExecution execution = backOff.start();
assertThat(execution.nextBackOff()).isEqualTo(100L);
assertThat(execution.nextBackOff()).isEqualTo(100L);
assertThat(execution.nextBackOff()).isEqualTo(100L);
assertThat(execution.nextBackOff()).isEqualTo(BackOffExecution.STOP);
}
Aggregations