aboutsummaryrefslogtreecommitdiff
path: root/android/guava-tests/test/com/google/common/cache/AbstractLoadingCacheTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'android/guava-tests/test/com/google/common/cache/AbstractLoadingCacheTest.java')
-rw-r--r--android/guava-tests/test/com/google/common/cache/AbstractLoadingCacheTest.java37
1 files changed, 13 insertions, 24 deletions
diff --git a/android/guava-tests/test/com/google/common/cache/AbstractLoadingCacheTest.java b/android/guava-tests/test/com/google/common/cache/AbstractLoadingCacheTest.java
index 84e004a8b..c029ff3d0 100644
--- a/android/guava-tests/test/com/google/common/cache/AbstractLoadingCacheTest.java
+++ b/android/guava-tests/test/com/google/common/cache/AbstractLoadingCacheTest.java
@@ -17,6 +17,7 @@
package com.google.common.cache;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.ExecutionError;
import com.google.common.util.concurrent.UncheckedExecutionException;
@@ -52,12 +53,9 @@ public class AbstractLoadingCacheTest extends TestCase {
}
};
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(cause);
- }
+ UncheckedExecutionException expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isEqualTo(cause);
Object newValue = new Object();
valueRef.set(newValue);
@@ -84,12 +82,9 @@ public class AbstractLoadingCacheTest extends TestCase {
}
};
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(cause);
- }
+ UncheckedExecutionException expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isEqualTo(cause);
Object newValue = new Object();
valueRef.set(newValue);
@@ -116,12 +111,9 @@ public class AbstractLoadingCacheTest extends TestCase {
}
};
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (ExecutionError expected) {
- assertThat(expected).hasCauseThat().isEqualTo(cause);
- }
+ ExecutionError expected =
+ assertThrows(ExecutionError.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isEqualTo(cause);
Object newValue = new Object();
valueRef.set(newValue);
@@ -148,12 +140,9 @@ public class AbstractLoadingCacheTest extends TestCase {
}
};
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(cause);
- }
+ UncheckedExecutionException expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isEqualTo(cause);
Object newValue = new Object();
valueRef.set(newValue);