Search in sources :

Example 16 with BackOffExecution

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}");
}
Also used : BackOffExecution(org.springframework.util.backoff.BackOffExecution) FixedBackOff(org.springframework.util.backoff.FixedBackOff) Test(org.junit.jupiter.api.Test)

Example 17 with BackOffExecution

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}");
}
Also used : BackOffExecution(org.springframework.util.backoff.BackOffExecution) ExponentialBackOff(org.springframework.util.backoff.ExponentialBackOff) Test(org.junit.jupiter.api.Test)

Example 18 with BackOffExecution

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);
}
Also used : BackOffExecution(org.springframework.util.backoff.BackOffExecution) ExponentialBackOff(org.springframework.util.backoff.ExponentialBackOff) Test(org.junit.jupiter.api.Test)

Example 19 with BackOffExecution

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);
}
Also used : BackOffExecution(org.springframework.util.backoff.BackOffExecution) ExponentialBackOff(org.springframework.util.backoff.ExponentialBackOff) Test(org.junit.jupiter.api.Test)

Aggregations

BackOffExecution (org.springframework.util.backoff.BackOffExecution)19 Test (org.junit.jupiter.api.Test)17 ExponentialBackOff (org.springframework.util.backoff.ExponentialBackOff)9 FixedBackOff (org.springframework.util.backoff.FixedBackOff)6 BackOff (org.springframework.util.backoff.BackOff)3 Connection (jakarta.jms.Connection)1 JMSException (jakarta.jms.JMSException)1 ArrayList (java.util.ArrayList)1 JmsException (org.springframework.jms.JmsException)1