use of org.cache2k.CacheManager in project cache2k by cache2k.
the class CacheManagerExclusiveTest method closeAll.
@Test
public void closeAll() {
CacheManager cm = CacheManager.getInstance();
ClassLoader cl1 = new URLClassLoader(new URL[0], this.getClass().getClassLoader());
ClassLoader cl2 = new URLClassLoader(new URL[0], this.getClass().getClassLoader());
CacheManager cm1 = CacheManager.getInstance(cl1);
CacheManager cm2 = CacheManager.getInstance(cl2);
CacheManager.closeAll();
assertTrue(cm1.isClosed());
assertTrue(cm2.isClosed());
assertTrue(cm.isClosed());
}
use of org.cache2k.CacheManager in project cache2k by cache2k.
the class CacheManagerLifeCycleTest method differentClassLoaderDifferentManager.
@Test
public void differentClassLoaderDifferentManager() {
ClassLoader cl1 = new URLClassLoader(new URL[0], this.getClass().getClassLoader());
ClassLoader cl2 = new URLClassLoader(new URL[0], this.getClass().getClassLoader());
CacheManager cm1 = CacheManager.getInstance(cl1);
CacheManager cm2 = CacheManager.getInstance(cl2);
assertNotSame(cm1, cm2);
assertFalse(cm1.isClosed());
assertFalse(cm2.isClosed());
CacheManager.closeAll(cl1);
CacheManager.closeAll(cl2);
assertTrue(cm1.isClosed());
assertTrue(cm2.isClosed());
}
use of org.cache2k.CacheManager in project cache2k by cache2k.
the class CacheManagerLifeCycleTest method closeSpecific.
@Test
public void closeSpecific() {
ClassLoader cl1 = new URLClassLoader(new URL[0], this.getClass().getClassLoader());
CacheManager cm1 = CacheManager.getInstance(cl1);
CacheManager.close(cl1, "something");
assertFalse(cm1.isClosed());
CacheManager.close(cl1, "default");
assertTrue(cm1.isClosed());
}
use of org.cache2k.CacheManager in project cache2k by cache2k.
the class CacheManagerLifeCycleTest method openClose.
@Test
public void openClose() {
String _uniqueName = this.getClass().getName() + ".openClose";
CacheManager cm = CacheManager.getInstance(_uniqueName);
cm.close();
CacheManager cm2 = CacheManager.getInstance(_uniqueName);
assertNotSame(cm, cm2);
cm2.close();
}
use of org.cache2k.CacheManager in project cache2k by cache2k.
the class CacheManagerLifeCycleTest method clearAllCaches.
@Test
public void clearAllCaches() {
String _uniqueName = this.getClass().getName() + ".clearAllCaches";
CacheManager cm = CacheManager.getInstance(_uniqueName);
Cache c = Cache2kBuilder.forUnknownTypes().manager(cm).name("dummy").build();
c.put("hello", "paul");
assertTrue("has some data", c.keys().iterator().hasNext());
c.getCacheManager().clear();
assertFalse("no data", c.keys().iterator().hasNext());
cm.close();
}
Aggregations