use of org.cache2k.Cache in project cache2k by cache2k.
the class Cache2kBuilderTest method cacheRemovedAfterClose.
@Test
public void cacheRemovedAfterClose() {
final String _NAME = this.getClass().getSimpleName() + "-cacheRemovedAfterClose";
CacheManager cm = CacheManager.getInstance(_NAME);
Cache c = Cache2kBuilder.forUnknownTypes().manager(cm).name(_NAME).build();
assertEquals(c, cm.getActiveCaches().iterator().next());
c.close();
assertFalse(cm.getActiveCaches().iterator().hasNext());
}
use of org.cache2k.Cache in project cache2k by cache2k.
the class Cache2kBuilderTest method cacheCapacity10.
@Test
public void cacheCapacity10() {
Cache c0 = Cache2kBuilder.forUnknownTypes().entryCapacity(10).build();
assertEquals(10, latestInfo(c0).getHeapCapacity());
c0.close();
}
use of org.cache2k.Cache in project cache2k by cache2k.
the class Cache2kBuilderTest method cacheClosedEventFired.
private void cacheClosedEventFired(boolean _wiredCache) {
final AtomicBoolean _FIRED = new AtomicBoolean();
Cache2kBuilder _builder = Cache2kBuilder.forUnknownTypes();
_builder.addCacheClosedListener(new CacheClosedListener() {
@Override
public void onCacheClosed(final Cache cache) {
_FIRED.set(true);
}
});
if (_wiredCache) {
StaticUtil.enforceWiredCache(_builder);
}
Cache c = _builder.build();
c.close();
assertTrue(_FIRED.get());
}
use of org.cache2k.Cache in project cache2k by cache2k.
the class Cache2kBuilderTest method cacheRemovedAfterClose_WiredCache.
@Test
public void cacheRemovedAfterClose_WiredCache() {
final String _NAME = this.getClass().getSimpleName() + "-cacheRemovedAfterCloseWiredCache";
CacheManager cm = CacheManager.getInstance(_NAME);
Cache2kBuilder _builder = Cache2kBuilder.forUnknownTypes().manager(cm).name(_NAME);
StaticUtil.enforceWiredCache(_builder);
Cache c = _builder.build();
assertEquals(c, cm.getActiveCaches().iterator().next());
c.close();
assertFalse(cm.getActiveCaches().iterator().hasNext());
}
use of org.cache2k.Cache in project cache2k by cache2k.
the class Cache2kBuilderTest method anonymousWithObjectObject.
@Test(expected = IllegalArgumentException.class)
public void anonymousWithObjectObject() {
Cache c = new Cache2kBuilder<Object, Object>() {
}.eternal(true).build();
c.clear();
}
Aggregations