use of org.cache2k.core.ExceptionWrapper in project cache2k by cache2k.
the class BasicCacheOperationsTest method getEntry_Exception.
@Test
public void getEntry_Exception() {
((Cache) cache).put(KEY, new ExceptionWrapper(OUCH));
CacheEntry<Integer, Integer> e = cache.getEntry(KEY);
assertEquals(KEY, e.getKey());
entryHasException(e);
assertEquals(OUCH, e.getException());
}
use of org.cache2k.core.ExceptionWrapper in project cache2k by cache2k.
the class BasicCacheOperationsTest method peekAll_Exception.
@Test
public void peekAll_Exception() {
((Cache) cache).put(KEY, new ExceptionWrapper(OUCH));
Map<Integer, Integer> m = cache.peekAll(toIterable(KEY, OTHER_KEY));
assertEquals(1, m.size());
assertEquals(1, m.values().size());
assertEquals(1, m.keySet().size());
assertEquals(1, m.entrySet().size());
try {
m.get(KEY);
fail("Exception expected");
} catch (CacheLoaderException ex) {
}
Iterator<Integer> it = m.keySet().iterator();
assertTrue(it.hasNext());
assertEquals(KEY, it.next());
assertFalse("one entry", it.hasNext());
it = m.values().iterator();
assertTrue(it.hasNext());
try {
assertEquals(KEY, it.next());
fail("Exception expected");
} catch (CacheLoaderException ex) {
}
Iterator<Map.Entry<Integer, Integer>> ei = m.entrySet().iterator();
assertTrue(ei.hasNext());
Map.Entry<Integer, Integer> e = ei.next();
assertEquals(KEY, e.getKey());
try {
e.getValue();
fail("Exception expected");
} catch (CacheLoaderException ex) {
}
}
use of org.cache2k.core.ExceptionWrapper in project cache2k by cache2k.
the class BasicCacheOperationsTest method peekAndReplace_Exception.
@Test(expected = CacheLoaderException.class)
public void peekAndReplace_Exception() {
((Cache) cache).put(KEY, new ExceptionWrapper(OUCH));
cache.peekAndReplace(KEY, VALUE);
}
use of org.cache2k.core.ExceptionWrapper in project cache2k by cache2k.
the class ExceptionPropagatorTest method prepCache.
Cache<Integer, Integer> prepCache() {
Cache c = target.cache();
c.put(KEY, new ExceptionWrapper(new IllegalArgumentException("Test")));
assertTrue(c.containsKey(KEY));
return c;
}
use of org.cache2k.core.ExceptionWrapper in project cache2k by cache2k.
the class BasicCacheOperationsTest method peekAndRemove_Exception.
@Test
public void peekAndRemove_Exception() {
((Cache) cache).put(KEY, new ExceptionWrapper(OUCH));
try {
cache.peekAndRemove(KEY);
fail("exception expected");
} catch (CacheLoaderException ex) {
}
}
Aggregations