Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed May 24, 2019
2 parents a6a36cc + 26460c9 commit aac3b94
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/test/java/org/cactoos/func/RetryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@
package org.cactoos.func;

import java.security.SecureRandom;
import java.time.Duration;
import org.junit.Test;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.FuncApplies;
import org.llorllale.cactoos.matchers.Throws;

/**
* Test case for {@link Retry}.
*
* @since 0.8
* @checkstyle JavadocMethodCheck (500 lines)
* @checkstyle MagicNumberCheck (500 line)
* @todo #909:30min add a test to where an interrupt exception is thrown so
* that the catch and error assignment is verified. The exception should be
* thrown when Thread.sleep is called in Retry.java:129
*/
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
public final class RetryTest {
Expand Down Expand Up @@ -74,4 +73,29 @@ public void runsFuncConditionMultipleTimes() {
new FuncApplies<>(true, true)
).affirm();
}

@Test
public void processInterruptExceptionOnWait() {
final Thread main = Thread.currentThread();
new Thread(
() -> {
while (true) {
if (Thread.State.TIMED_WAITING == main.getState()) {
main.interrupt();
return;
}
}
}).start();
new Assertion<>(
"Must be interrupted on wait",
() -> new Retry<>(
input -> {
throw new IllegalArgumentException("Happens");
},
attempts -> false,
Duration.ofMillis(Long.MAX_VALUE)
).apply(true),
new Throws<>("sleep interrupted", InterruptedException.class)
).affirm();
}
}

1 comment on commit aac3b94

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on aac3b94 May 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 909-fb64001d disappeared from src/test/java/org/cactoos/func/RetryTest.java, that's why I closed #1088. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.