aboutsummaryrefslogtreecommitdiff
path: root/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureCancellationCauseTest.java
diff options
context:
space:
mode:
authorSadaf Ebrahimi <sadafebrahimi@google.com>2024-01-02 18:15:48 +0000
committerSadaf Ebrahimi <sadafebrahimi@google.com>2024-01-02 18:23:02 +0000
commit1b60467f3624ad6bae92bb65652a10c49639023e (patch)
treecbc7e4894708533a0ddc4e61da1d74e64393e0e1 /android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureCancellationCauseTest.java
parenteec82bd5ace8fd2c4ba647f153c4c03e1bb41268 (diff)
parentd258d3ed3336934354f340518065b04528fb1f2b (diff)
downloadguava-1b60467f3624ad6bae92bb65652a10c49639023e.tar.gz
Upgrade guava to v33.0.0
This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update guava For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md Test: TreeHugger Change-Id: I9a54a36317484a947b630a037e23c9919c2951cd
Diffstat (limited to 'android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureCancellationCauseTest.java')
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureCancellationCauseTest.java27
1 files changed, 8 insertions, 19 deletions
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureCancellationCauseTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureCancellationCauseTest.java
index 9aee78029..d00f95f31 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureCancellationCauseTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureCancellationCauseTest.java
@@ -17,6 +17,7 @@
package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import java.lang.reflect.Method;
import java.net.URLClassLoader;
@@ -89,12 +90,8 @@ public class AbstractFutureCancellationCauseTest extends TestCase {
assertTrue(future.isCancelled());
assertTrue(future.isDone());
assertNull(tryInternalFastPathGetFailure(future));
- try {
- future.get();
- fail("Expected CancellationException");
- } catch (CancellationException e) {
- assertNotNull(e.getCause());
- }
+ CancellationException e = assertThrows(CancellationException.class, () -> future.get());
+ assertNotNull(e.getCause());
}
public void testCancel_notDoneInterrupt() throws Exception {
@@ -103,12 +100,8 @@ public class AbstractFutureCancellationCauseTest extends TestCase {
assertTrue(future.isCancelled());
assertTrue(future.isDone());
assertNull(tryInternalFastPathGetFailure(future));
- try {
- future.get();
- fail("Expected CancellationException");
- } catch (CancellationException e) {
- assertNotNull(e.getCause());
- }
+ CancellationException e = assertThrows(CancellationException.class, () -> future.get());
+ assertNotNull(e.getCause());
}
public void testSetFuture_misbehavingFutureDoesNotThrow() throws Exception {
@@ -151,13 +144,9 @@ public class AbstractFutureCancellationCauseTest extends TestCase {
"setFuture",
future.getClass().getClassLoader().loadClass(ListenableFuture.class.getName()))
.invoke(future, badFuture);
- try {
- future.get();
- fail();
- } catch (CancellationException expected) {
- assertThat(expected).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
- assertThat(expected).hasCauseThat().hasMessageThat().contains(badFuture.toString());
- }
+ CancellationException expected = assertThrows(CancellationException.class, () -> future.get());
+ assertThat(expected).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
+ assertThat(expected).hasCauseThat().hasMessageThat().contains(badFuture.toString());
}
private Future<?> newFutureInstance() throws Exception {