use of org.springframework.util.backoff.ExponentialBackOff in project spring-framework by spring-projects.
the class ExponentialBackOffTests method defaultInstance.
@Test
public void defaultInstance() {
ExponentialBackOff backOff = new ExponentialBackOff();
BackOffExecution execution = backOff.start();
assertEquals(2000l, execution.nextBackOff());
assertEquals(3000l, execution.nextBackOff());
assertEquals(4500l, execution.nextBackOff());
}
use of org.springframework.util.backoff.ExponentialBackOff in project spring-framework by spring-projects.
the class ExponentialBackOffTests method fixedIncrease.
@Test
public void fixedIncrease() {
ExponentialBackOff backOff = new ExponentialBackOff(100L, 1.0);
backOff.setMaxElapsedTime(300l);
BackOffExecution execution = backOff.start();
assertEquals(100l, execution.nextBackOff());
assertEquals(100l, execution.nextBackOff());
assertEquals(100l, execution.nextBackOff());
assertEquals(BackOffExecution.STOP, execution.nextBackOff());
}
use of org.springframework.util.backoff.ExponentialBackOff in project spring-framework by spring-projects.
the class ExponentialBackOffTests method maxIntervalReachedImmediately.
@Test
public void maxIntervalReachedImmediately() {
ExponentialBackOff backOff = new ExponentialBackOff(1000L, 2.0);
backOff.setMaxInterval(50L);
BackOffExecution execution = backOff.start();
assertEquals(50L, execution.nextBackOff());
assertEquals(50L, execution.nextBackOff());
}
use of org.springframework.util.backoff.ExponentialBackOff in project spring-framework by spring-projects.
the class ExponentialBackOffTests method toStringContent.
@Test
public void toStringContent() {
ExponentialBackOff backOff = new ExponentialBackOff(2000L, 2.0);
BackOffExecution execution = backOff.start();
assertEquals("ExponentialBackOff{currentInterval=n/a, multiplier=2.0}", execution.toString());
execution.nextBackOff();
assertEquals("ExponentialBackOff{currentInterval=2000ms, multiplier=2.0}", execution.toString());
execution.nextBackOff();
assertEquals("ExponentialBackOff{currentInterval=4000ms, multiplier=2.0}", execution.toString());
}
Aggregations