Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean deprecated API usages (StopStrategies.stopAfterDelay) #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/test/java/com/github/rholder/retry/StopStrategiesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.github.rholder.retry;

import static java.util.concurrent.TimeUnit.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

Expand All @@ -39,16 +40,16 @@ public void testStopAfterAttempt() {

@Test
public void testStopAfterDelayWithMilliseconds() {
assertFalse(StopStrategies.stopAfterDelay(1000L).shouldStop(failedAttempt(2, 999L)));
assertTrue(StopStrategies.stopAfterDelay(1000L).shouldStop(failedAttempt(2, 1000L)));
assertTrue(StopStrategies.stopAfterDelay(1000L).shouldStop(failedAttempt(2, 1001L)));
assertFalse(StopStrategies.stopAfterDelay(1, SECONDS).shouldStop(failedAttempt(2, 999L)));
assertTrue(StopStrategies.stopAfterDelay(1, SECONDS).shouldStop(failedAttempt(2, 1000L)));
assertTrue(StopStrategies.stopAfterDelay(1, SECONDS).shouldStop(failedAttempt(2, 1001L)));
}

@Test
public void testStopAfterDelayWithTimeUnit() {
assertFalse(StopStrategies.stopAfterDelay(1, TimeUnit.SECONDS).shouldStop(failedAttempt(2, 999L)));
assertTrue(StopStrategies.stopAfterDelay(1, TimeUnit.SECONDS).shouldStop(failedAttempt(2, 1000L)));
assertTrue(StopStrategies.stopAfterDelay(1, TimeUnit.SECONDS).shouldStop(failedAttempt(2, 1001L)));
assertFalse(StopStrategies.stopAfterDelay(1, SECONDS).shouldStop(failedAttempt(2, 999L)));
assertTrue(StopStrategies.stopAfterDelay(1, SECONDS).shouldStop(failedAttempt(2, 1000L)));
assertTrue(StopStrategies.stopAfterDelay(1, SECONDS).shouldStop(failedAttempt(2, 1001L)));
}

public Attempt<Boolean> failedAttempt(long attemptNumber, long delaySinceFirstAttempt) {
Expand Down