use of org.cache2k.CacheManager 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.CacheManager 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.CacheManager in project cache2k by cache2k.
the class CacheManagerLifeCycleTest method getActiveCaches.
@Test
public void getActiveCaches() {
String _uniqueName = this.getClass().getName() + ".getActiveCaches";
CacheManager cm = CacheManager.getInstance(_uniqueName);
assertFalse(cm.getActiveCaches().iterator().hasNext());
Cache c = Cache2kBuilder.forUnknownTypes().manager(cm).build();
assertTrue(cm.getActiveCaches().iterator().hasNext());
cm.close();
}
use of org.cache2k.CacheManager in project cache2k by cache2k.
the class CacheManagerLifeCycleTest method createCache.
@Test
public void createCache() {
String _uniqueName = this.getClass().getName() + ".createCache";
CacheManager cm = CacheManager.getInstance(_uniqueName);
Cache c = cm.createCache(Cache2kBuilder.forUnknownTypes().name("dummy").toConfiguration());
assertEquals("dummy", c.getName());
assertSame(cm, c.getCacheManager());
cm.close();
}
use of org.cache2k.CacheManager in project cache2k by cache2k.
the class CacheManagerLifeCycleTest method onlyOneCacheForWired.
@Test
public void onlyOneCacheForWired() {
String _uniqueName = this.getClass().getName() + ".onlyOneCacheForWired";
CacheManager cm = CacheManager.getInstance(_uniqueName);
Cache2kBuilder b = Cache2kBuilder.forUnknownTypes().manager(cm);
StaticUtil.enforceWiredCache(b);
Cache c = b.build();
assertEquals("one cache active", 1, StaticUtil.count(cm.getActiveCaches()));
cm.close();
}
Aggregations