Skip to content

Commit

Permalink
GH-456: Fix EnableRetryWithBackoffTests.randomExponential() for random
Browse files Browse the repository at this point in the history
Fixes: #456

The random logic in the `ExponentialRandomBackOffPolicy` may end up with close to the `1`.
And after casting to `long` we got the same `1000`

* Fix test respectively to include that possibility.
  • Loading branch information
artembilan committed Jul 18, 2024
1 parent 04f12a7 commit a9b329a
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2006-2023 the original author or authors.
* Copyright 2006-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,6 +31,7 @@

/**
* @author Dave Syer
* @author Artem Bilan
*
*/
public class EnableRetryWithBackoffTests {
Expand Down Expand Up @@ -74,9 +75,10 @@ public void randomExponential() {
assertThat(service.getCount()).isEqualTo(3);
List<Long> periods = context.getBean(PeriodSleeper.class).getPeriods();
assertThat(context.getBean(PeriodSleeper.class).getPeriods().toString()).isNotEqualTo("[1000, 1100]");
assertThat(periods.get(0) > 1000).describedAs("Wrong periods: %s" + periods.toString()).isTrue();
assertThat(periods.get(1) > 1100 && periods.get(1) < 1210).describedAs("Wrong periods: %s" + periods.toString())
.isTrue();
assertThat(periods.get(0)).describedAs("Wrong periods: %s" + periods).isGreaterThanOrEqualTo(1000);
assertThat(periods.get(1)).describedAs("Wrong periods: %s" + periods)
.isGreaterThanOrEqualTo(1100)
.isLessThanOrEqualTo(1210);
context.close();
}

Expand Down

0 comments on commit a9b329a

Please sign in to comment.