use of com.github.benmanes.caffeine.cache.testing.CacheSpec.Loader in project caffeine by ben-manes.
the class LoadingCacheTest method asyncLoad_exception.
@Test
public void asyncLoad_exception() throws Exception {
Exception e = new Exception();
CacheLoader<Integer, Integer> loader = key -> {
throw e;
};
try {
loader.asyncLoad(1, Runnable::run).join();
} catch (CompletionException ex) {
assertThat(ex.getCause(), is(sameInstance(e)));
}
}
use of com.github.benmanes.caffeine.cache.testing.CacheSpec.Loader in project caffeine by ben-manes.
the class LoadingCacheTest method asyncReload_exception.
@Test
public void asyncReload_exception() throws Exception {
for (Exception e : Arrays.asList(new Exception(), new RuntimeException())) {
CacheLoader<Integer, Integer> loader = key -> {
throw e;
};
try {
loader.asyncReload(1, 1, Runnable::run).join();
Assert.fail();
} catch (CompletionException ex) {
assertThat(ex.getCause(), is(sameInstance(e)));
}
}
}
Aggregations