aboutsummaryrefslogtreecommitdiff
path: root/android/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'android/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java')
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java13
1 files changed, 5 insertions, 8 deletions
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java b/android/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java
index 6d1591354..32bbe0c25 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java
@@ -16,6 +16,7 @@
package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.InterruptibleTask.Blocker;
import java.nio.channels.spi.AbstractInterruptibleChannel;
@@ -61,14 +62,10 @@ public final class InterruptibleTaskTest extends TestCase {
Thread runner = new Thread(task);
runner.start();
isInterruptibleRegistered.await();
- try {
- task.interruptTask();
- fail();
- } catch (RuntimeException expected) {
- assertThat(expected)
- .hasMessageThat()
- .isEqualTo("I bet you didn't think Thread.interrupt could throw");
- }
+ RuntimeException expected = assertThrows(RuntimeException.class, () -> task.interruptTask());
+ assertThat(expected)
+ .hasMessageThat()
+ .isEqualTo("I bet you didn't think Thread.interrupt could throw");
// We need to wait for the runner to exit. It used to be that the runner would get stuck in the
// busy loop when interrupt threw.
runner.join(TimeUnit.SECONDS.toMillis(10));