Search in sources :

Example 1 with BackOffContext

use of org.springframework.retry.backoff.BackOffContext in project molgenis by molgenis.

the class ConnectionRetryConfigTest method testBackOffPolicyIsExponential.

@Test
public void testBackOffPolicyIsExponential() {
    List<Long> sleeps = newArrayList();
    ExponentialBackOffPolicy fakeBackOff = this.backOffPolicy.withSleeper(sleeps::add);
    BackOffContext context = fakeBackOff.start(null);
    for (int i = 0; i < 11; i++) {
        fakeBackOff.backOff(context);
    }
    assertEquals(sleeps, Arrays.asList(1000L, 2000L, 4000L, 8000L, 16000L, 32000L, 64000L, 128000L, 256000L, 300000L, 300000L));
}
Also used : ExponentialBackOffPolicy(org.springframework.retry.backoff.ExponentialBackOffPolicy) BackOffContext(org.springframework.retry.backoff.BackOffContext) Test(org.testng.annotations.Test)

Aggregations

BackOffContext (org.springframework.retry.backoff.BackOffContext)1 ExponentialBackOffPolicy (org.springframework.retry.backoff.ExponentialBackOffPolicy)1 Test (org.testng.annotations.Test)1