This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git

commit 84bbc86a9409e4ee76dd9334876404cea842bcf4
Author: Gary Gregory <gardgreg...@gmail.com>
AuthorDate: Sun Sep 19 22:05:28 2021 -0400

    Use assertThrows() in test.
---
 src/test/java/org/apache/commons/io/ThreadMonitorTestCase.java | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/test/java/org/apache/commons/io/ThreadMonitorTestCase.java 
b/src/test/java/org/apache/commons/io/ThreadMonitorTestCase.java
index 5a70484..bcd35d0 100644
--- a/src/test/java/org/apache/commons/io/ThreadMonitorTestCase.java
+++ b/src/test/java/org/apache/commons/io/ThreadMonitorTestCase.java
@@ -18,6 +18,7 @@ package org.apache.commons.io;
 
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.time.Duration;
 
@@ -80,13 +81,10 @@ public class ThreadMonitorTestCase {
      */
     @Test
     public void testTimeout() {
-        try {
+        assertThrows(InterruptedException.class, () -> {
             final Thread monitor = ThreadMonitor.start(Duration.ofMillis(100));
             TestUtils.sleep(400);
             ThreadMonitor.stop(monitor);
-            fail("Expected InterruptedException");
-        } catch (final InterruptedException e) {
-            // expected result - timeout
-        }
+        });
     }
 }

Reply via email to