use of org.springframework.util.backoff.BackOffExecution in project spring-framework by spring-projects.
the class ExponentialBackOffTests method startReturnDifferentInstances.
@Test
void startReturnDifferentInstances() {
ExponentialBackOff backOff = new ExponentialBackOff();
backOff.setInitialInterval(2000L);
backOff.setMultiplier(2.0);
backOff.setMaxElapsedTime(4000L);
BackOffExecution execution = backOff.start();
BackOffExecution execution2 = backOff.start();
assertThat(execution.nextBackOff()).isEqualTo(2000L);
assertThat(execution2.nextBackOff()).isEqualTo(2000L);
assertThat(execution.nextBackOff()).isEqualTo(4000L);
assertThat(execution2.nextBackOff()).isEqualTo(4000L);
assertThat(execution.nextBackOff()).isEqualTo(BackOffExecution.STOP);
assertThat(execution2.nextBackOff()).isEqualTo(BackOffExecution.STOP);
}
use of org.springframework.util.backoff.BackOffExecution in project spring-framework by spring-projects.
the class ExponentialBackOffTests method simpleIncrease.
@Test
void simpleIncrease() {
ExponentialBackOff backOff = new ExponentialBackOff(100L, 2.0);
BackOffExecution execution = backOff.start();
assertThat(execution.nextBackOff()).isEqualTo(100L);
assertThat(execution.nextBackOff()).isEqualTo(200L);
assertThat(execution.nextBackOff()).isEqualTo(400L);
assertThat(execution.nextBackOff()).isEqualTo(800L);
}
use of org.springframework.util.backoff.BackOffExecution in project spring-framework by spring-projects.
the class FixedBackOffTests method liveUpdate.
@Test
void liveUpdate() {
FixedBackOff backOff = new FixedBackOff(100L, 1);
BackOffExecution execution = backOff.start();
assertThat(execution.nextBackOff()).isEqualTo(100L);
backOff.setInterval(200L);
backOff.setMaxAttempts(2);
assertThat(execution.nextBackOff()).isEqualTo(200L);
assertThat(execution.nextBackOff()).isEqualTo(BackOffExecution.STOP);
}
use of org.springframework.util.backoff.BackOffExecution in project spring-framework by spring-projects.
the class FixedBackOffTests method startReturnDifferentInstances.
@Test
void startReturnDifferentInstances() {
FixedBackOff backOff = new FixedBackOff(100L, 1);
BackOffExecution execution = backOff.start();
BackOffExecution execution2 = backOff.start();
assertThat(execution.nextBackOff()).isEqualTo(100L);
assertThat(execution2.nextBackOff()).isEqualTo(100L);
assertThat(execution.nextBackOff()).isEqualTo(BackOffExecution.STOP);
assertThat(execution2.nextBackOff()).isEqualTo(BackOffExecution.STOP);
}
use of org.springframework.util.backoff.BackOffExecution in project spring-framework by spring-projects.
the class FixedBackOffTests method defaultInstance.
@Test
void defaultInstance() {
FixedBackOff backOff = new FixedBackOff();
BackOffExecution execution = backOff.start();
for (int i = 0; i < 100; i++) {
assertThat(execution.nextBackOff()).isEqualTo(FixedBackOff.DEFAULT_INTERVAL);
}
}
Aggregations