diff options
Diffstat (limited to 'android/guava-tests/test/com/google/common/cache/NullCacheTest.java')
-rw-r--r-- | android/guava-tests/test/com/google/common/cache/NullCacheTest.java | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/android/guava-tests/test/com/google/common/cache/NullCacheTest.java b/android/guava-tests/test/com/google/common/cache/NullCacheTest.java index 89dc3fb14..6fa8f7b13 100644 --- a/android/guava-tests/test/com/google/common/cache/NullCacheTest.java +++ b/android/guava-tests/test/com/google/common/cache/NullCacheTest.java @@ -20,6 +20,7 @@ import static com.google.common.cache.TestingCacheLoaders.exceptionLoader; import static com.google.common.cache.TestingRemovalListeners.queuingRemovalListener; import static com.google.common.truth.Truth.assertThat; import static java.util.concurrent.TimeUnit.SECONDS; +import static org.junit.Assert.assertThrows; import com.google.common.cache.CacheLoader.InvalidCacheLoadException; import com.google.common.cache.TestingRemovalListeners.QueuingRemovalListener; @@ -100,12 +101,7 @@ public class NullCacheTest extends TestCase { .removalListener(listener) .build(constantLoader(null)); - try { - cache.getUnchecked(new Object()); - fail(); - } catch (InvalidCacheLoadException e) { - /* expected */ - } + assertThrows(InvalidCacheLoadException.class, () -> cache.getUnchecked(new Object())); assertTrue(listener.isEmpty()); checkEmpty(cache); @@ -119,12 +115,9 @@ public class NullCacheTest extends TestCase { .removalListener(listener) .build(exceptionLoader(e)); - try { - map.getUnchecked(new Object()); - fail(); - } catch (UncheckedExecutionException uee) { - assertThat(uee).hasCauseThat().isSameInstanceAs(e); - } + UncheckedExecutionException uee = + assertThrows(UncheckedExecutionException.class, () -> map.getUnchecked(new Object())); + assertThat(uee).hasCauseThat().isSameInstanceAs(e); assertTrue(listener.isEmpty()); checkEmpty(map); } |