use of javax.cache.CacheManager in project cache2k by cache2k.
the class CacheManagerTest method close_twice.
@Test
public void close_twice() {
CacheManager cacheManager = getCacheManager();
cacheManager.close();
cacheManager.close();
}
use of javax.cache.CacheManager in project cache2k by cache2k.
the class CacheManagerTest method getUnsafeTypedCacheRequest.
/**
* https://github.com/jsr107/jsr107spec/issues/340
* in 1.1 we relaxed {@link CacheManager#getCache(String)} to not enforce a check.
*/
@Test
public void getUnsafeTypedCacheRequest() {
CacheManager cacheManager = getCacheManager();
MutableConfiguration<String, Long> config = new MutableConfiguration<String, Long>().setTypes(String.class, Long.class);
cacheManager.createCache("typed-cache", config);
Cache cache = cacheManager.getCache("typed-cache");
assertNotNull("getCache() returns cache reference for typed caches, since 1.1", cache);
}
use of javax.cache.CacheManager in project cache2k by cache2k.
the class CacheManagerTest method testReuseCacheManager.
@Test
public void testReuseCacheManager() throws Exception {
CachingProvider provider = Caching.getCachingProvider();
URI uri = provider.getDefaultURI();
CacheManager cacheManager = provider.getCacheManager(uri, provider.getDefaultClassLoader());
assertFalse(cacheManager.isClosed());
cacheManager.close();
assertTrue(cacheManager.isClosed());
try {
cacheManager.createCache("Dog", new MutableConfiguration());
fail();
} catch (IllegalStateException e) {
// expected
}
CacheManager otherCacheManager = provider.getCacheManager(uri, provider.getDefaultClassLoader());
assertFalse(otherCacheManager.isClosed());
assertNotSame(cacheManager, otherCacheManager);
}
use of javax.cache.CacheManager in project cache2k by cache2k.
the class CacheManagerTest method getCaches_MutateReturn.
@Test
public void getCaches_MutateReturn() {
CacheManager cacheManager = getCacheManager();
cacheManager.createCache("c1", new MutableConfiguration());
Cache cache1 = cacheManager.getCache("c1");
try {
Iterator iterator = cacheManager.getCacheNames().iterator();
iterator.next();
iterator.remove();
fail();
} catch (UnsupportedOperationException e) {
// immutable
}
}
use of javax.cache.CacheManager in project cache2k by cache2k.
the class CacheManagerTest method removeCache_There.
@Test
public void removeCache_There() {
CacheManager cacheManager = getCacheManager();
String name1 = "c1";
cacheManager.createCache(name1, new MutableConfiguration());
cacheManager.destroyCache(name1);
assertFalse(cacheManager.getCacheNames().iterator().hasNext());
}
Aggregations