use of org.cache2k.Cache 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);
}
use of org.cache2k.Cache 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());
}
use of org.cache2k.Cache in project cache2k by cache2k.
the class Cache2kBuilderTest method cacheNameInClassConstructor0.
@Test
public void cacheNameInClassConstructor0() {
Cache c = BuildCacheInClassConstructor0.cache;
assertThat(c.getName(), startsWith("_" + CLASSNAME + "$BuildCacheInClassConstructor0.CLINIT"));
c.close();
}
use of org.cache2k.Cache in project cache2k by cache2k.
the class Cache2kBuilderTest method cacheCapacityDefault1234.
@Test
public void cacheCapacityDefault1234() {
Cache c0 = Cache2kBuilder.forUnknownTypes().build();
assertEquals(1234, latestInfo(c0).getHeapCapacity());
c0.close();
}
use of org.cache2k.Cache in project cache2k by cache2k.
the class Cache2kBuilderTest method illegalCharacterInCacheName_unsafeSet.
@Test
public void illegalCharacterInCacheName_unsafeSet() {
for (char c : ILLEGAL_CHARACTERS_IN_NAME.toCharArray()) {
try {
Cache _cache = Cache2kBuilder.forUnknownTypes().name("illegalCharName" + c).build();
_cache.close();
fail("Expect exception for illegal name in character '" + c + "', code " + ((int) c));
} catch (IllegalArgumentException ex) {
}
}
}
Aggregations