use of javax.cache.CacheManager in project cache2k by cache2k.
the class CacheManagerTest method testReuseCacheManagerGetCache.
/**
* https://github.com/jsr107/jsr107tck/issues/104
* Changed in 1.1, don't do getCache(..., null, null)
*/
@Test
public void testReuseCacheManagerGetCache() 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.getCache("nonExistent", Integer.class, Integer.class);
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 getIncorrectCacheValueType.
@Test(expected = ClassCastException.class)
public void getIncorrectCacheValueType() {
CacheManager cacheManager = getCacheManager();
MutableConfiguration<String, Long> config = new MutableConfiguration<String, Long>().setTypes(String.class, Long.class);
cacheManager.createCache("typed-cache", config);
Cache<String, String> cache = cacheManager.getCache("typed-cache", String.class, String.class);
}
use of javax.cache.CacheManager in project cache2k by cache2k.
the class CacheManagerTest method enableStatistics_nullCacheName.
@Test(expected = NullPointerException.class)
public void enableStatistics_nullCacheName() {
CacheManager cacheManager = getCacheManager();
final String NULL_CACHE_NAME = null;
cacheManager.enableStatistics(NULL_CACHE_NAME, true);
fail();
}
use of javax.cache.CacheManager in project cache2k by cache2k.
the class CacheManagerTest method getCache_There.
@Test
public void getCache_There() {
String name = this.toString();
CacheManager cacheManager = getCacheManager();
cacheManager.createCache(name, new MutableConfiguration());
Cache cache = cacheManager.getCache(name);
assertSame(cache, cacheManager.getCache(name));
}
use of javax.cache.CacheManager in project cache2k by cache2k.
the class CacheManagerTest method getUntypedCache.
@Test
public void getUntypedCache() {
CacheManager cacheManager = getCacheManager();
// configure an un-typed Cache
MutableConfiguration config = new MutableConfiguration();
cacheManager.createCache("untyped-cache", config);
Cache cache = cacheManager.getCache("untyped-cache");
assertNotNull(cache);
assertEquals(Object.class, cache.getConfiguration(CompleteConfiguration.class).getKeyType());
assertEquals(Object.class, cache.getConfiguration(CompleteConfiguration.class).getValueType());
}
Aggregations