Search in sources :

Example 6 with ExceptionWrapper

use of org.cache2k.core.ExceptionWrapper in project cache2k by cache2k.

the class BasicCacheOperationsTest method getEntryState_Exception.

@Test
public void getEntryState_Exception() {
    if (!(cache instanceof InternalCache)) {
        return;
    }
    ((Cache) cache).put(KEY, new ExceptionWrapper(OUCH));
    InternalCache c = (InternalCache) cache;
    String s = c.getEntryState(KEY);
    assertTrue(s.contains("exception="));
}
Also used : InternalCache(org.cache2k.core.InternalCache) ExceptionWrapper(org.cache2k.core.ExceptionWrapper) InternalCache(org.cache2k.core.InternalCache) Cache(org.cache2k.Cache)

Example 7 with ExceptionWrapper

use of org.cache2k.core.ExceptionWrapper in project cache2k by cache2k.

the class BasicCacheOperationsTest method peekAndPut_Exception.

@Test(expected = CacheLoaderException.class)
public void peekAndPut_Exception() {
    ((Cache) cache).put(KEY, new ExceptionWrapper(OUCH));
    cache.peekAndPut(KEY, VALUE);
}
Also used : ExceptionWrapper(org.cache2k.core.ExceptionWrapper) InternalCache(org.cache2k.core.InternalCache) Cache(org.cache2k.Cache)

Example 8 with ExceptionWrapper

use of org.cache2k.core.ExceptionWrapper in project cache2k by cache2k.

the class BasicCacheOperationsTest method peekEntry_Exception.

@Test
public void peekEntry_Exception() {
    ((Cache) cache).put(KEY, new ExceptionWrapper(OUCH));
    CacheEntry<Integer, Integer> e = cache.peekEntry(KEY);
    assertEquals(KEY, e.getKey());
    entryHasException(e);
    assertEquals(OUCH, e.getException());
}
Also used : ExceptionWrapper(org.cache2k.core.ExceptionWrapper) InternalCache(org.cache2k.core.InternalCache) Cache(org.cache2k.Cache)

Aggregations

Cache (org.cache2k.Cache)8 ExceptionWrapper (org.cache2k.core.ExceptionWrapper)8 InternalCache (org.cache2k.core.InternalCache)7 CacheLoaderException (org.cache2k.integration.CacheLoaderException)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CacheEntry (org.cache2k.CacheEntry)1