From ae1807fca2a9170abd547f6caf22017974aa3ac7 Mon Sep 17 00:00:00 2001 From: priyank-sriv Date: Mon, 22 Jul 2019 00:55:41 +0530 Subject: [PATCH] backoff with jitter --- .../com/baeldung/backoff/jitter/BackoffWithJitterTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/patterns/backoff-jitter/src/test/java/com/baeldung/backoff/jitter/BackoffWithJitterTest.java b/patterns/backoff-jitter/src/test/java/com/baeldung/backoff/jitter/BackoffWithJitterTest.java index 966207f430..0f0e652596 100644 --- a/patterns/backoff-jitter/src/test/java/com/baeldung/backoff/jitter/BackoffWithJitterTest.java +++ b/patterns/backoff-jitter/src/test/java/com/baeldung/backoff/jitter/BackoffWithJitterTest.java @@ -65,6 +65,12 @@ public class BackoffWithJitterTest { test(intervalFn); } + @Test + public void whenRetryExponentialBackoffWithJitter_thenRetriesAreSpread() throws InterruptedException { + IntervalFunction intervalFn = ofExponentialRandomBackoff(INITIAL_INTERVAL, MULTIPLIER, RANDOMIZATION_FACTOR); + test(intervalFn); + } + private void test(IntervalFunction intervalFn) throws InterruptedException { Function pingPongFn = getRetryablePingPongFn(intervalFn); ExecutorService executors = newFixedThreadPool(NUM_TASKS);