Skip to content

Commit 84bbc86

Browse files
author
Gary Gregory
committed
Use assertThrows() in test.
1 parent aec423b commit 84bbc86

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/test/java/org/apache/commons/io/ThreadMonitorTestCase.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static org.junit.jupiter.api.Assertions.assertNull;
2020
import static org.junit.jupiter.api.Assertions.fail;
21+
import static org.junit.jupiter.api.Assertions.assertThrows;
2122

2223
import java.time.Duration;
2324

@@ -80,13 +81,10 @@ public void testNoTimeoutZero() {
8081
*/
8182
@Test
8283
public void testTimeout() {
83-
try {
84+
assertThrows(InterruptedException.class, () -> {
8485
final Thread monitor = ThreadMonitor.start(Duration.ofMillis(100));
8586
TestUtils.sleep(400);
8687
ThreadMonitor.stop(monitor);
87-
fail("Expected InterruptedException");
88-
} catch (final InterruptedException e) {
89-
// expected result - timeout
90-
}
88+
});
9189
}
9290
}

0 commit comments

Comments
 (0)