mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-10-05 22:49:02 +00:00
Improve Javadoc and tests for BackOff strategies
This commit is contained in:
@@ -92,28 +92,29 @@ class ExponentialBackOffTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void startReturnDifferentInstances() {
|
||||
void startReturnsDifferentInstances() {
|
||||
ExponentialBackOff backOff = new ExponentialBackOff();
|
||||
backOff.setInitialInterval(2000L);
|
||||
backOff.setMultiplier(2.0);
|
||||
backOff.setMaxElapsedTime(4000L);
|
||||
|
||||
BackOffExecution execution = backOff.start();
|
||||
BackOffExecution execution1 = backOff.start();
|
||||
BackOffExecution execution2 = backOff.start();
|
||||
|
||||
assertThat(execution.nextBackOff()).isEqualTo(2000L);
|
||||
assertThat(execution1).isNotSameAs(execution2);
|
||||
|
||||
assertThat(execution1.nextBackOff()).isEqualTo(2000L);
|
||||
assertThat(execution2.nextBackOff()).isEqualTo(2000L);
|
||||
assertThat(execution.nextBackOff()).isEqualTo(4000L);
|
||||
assertThat(execution1.nextBackOff()).isEqualTo(4000L);
|
||||
assertThat(execution2.nextBackOff()).isEqualTo(4000L);
|
||||
assertThat(execution.nextBackOff()).isEqualTo(BackOffExecution.STOP);
|
||||
assertThat(execution1.nextBackOff()).isEqualTo(BackOffExecution.STOP);
|
||||
assertThat(execution2.nextBackOff()).isEqualTo(BackOffExecution.STOP);
|
||||
}
|
||||
|
||||
@Test
|
||||
void invalidInterval() {
|
||||
ExponentialBackOff backOff = new ExponentialBackOff();
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
backOff.setMultiplier(0.9));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> backOff.setMultiplier(0.9));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -24,6 +24,8 @@ import org.springframework.util.backoff.FixedBackOff;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link FixedBackOff}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
class FixedBackOffTests {
|
||||
@@ -54,14 +56,17 @@ class FixedBackOffTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void startReturnDifferentInstances() {
|
||||
void startReturnsDifferentInstances() {
|
||||
FixedBackOff backOff = new FixedBackOff(100L, 1);
|
||||
BackOffExecution execution = backOff.start();
|
||||
|
||||
BackOffExecution execution1 = backOff.start();
|
||||
BackOffExecution execution2 = backOff.start();
|
||||
|
||||
assertThat(execution.nextBackOff()).isEqualTo(100L);
|
||||
assertThat(execution1).isNotSameAs(execution2);
|
||||
|
||||
assertThat(execution1.nextBackOff()).isEqualTo(100L);
|
||||
assertThat(execution2.nextBackOff()).isEqualTo(100L);
|
||||
assertThat(execution.nextBackOff()).isEqualTo(BackOffExecution.STOP);
|
||||
assertThat(execution1.nextBackOff()).isEqualTo(BackOffExecution.STOP);
|
||||
assertThat(execution2.nextBackOff()).isEqualTo(BackOffExecution.STOP);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user