use of javax.cache.configuration.MutableConfiguration in project tutorials by eugenp.
the class EventListenerTest method setup.
@Before
public void setup() {
CachingProvider cachingProvider = Caching.getCachingProvider();
CacheManager cacheManager = cachingProvider.getCacheManager();
MutableConfiguration<String, String> config = new MutableConfiguration<String, String>();
this.cache = cacheManager.createCache("MyCache", config);
this.listener = new SimpleCacheEntryListener();
}
use of javax.cache.configuration.MutableConfiguration in project cache2k by cache2k.
the class CacheManagerTest method create_cache2k_config_value_type_mismatch.
@Test(expected = IllegalArgumentException.class)
public void create_cache2k_config_value_type_mismatch() {
CachingProvider p = Caching.getCachingProvider();
CacheManager cm = p.getCacheManager();
MutableConfiguration cfg = ExtendedMutableConfiguration.of(new Cache2kBuilder<Long, Double>() {
});
Cache<Integer, Double> cache = cm.createCache("aCache", cfg.setTypes(Long.class, Float.class));
cache.close();
}
use of javax.cache.configuration.MutableConfiguration in project cache2k by cache2k.
the class CacheTest method testGetCacheManager.
@Test
public void testGetCacheManager() throws Exception {
String cacheName = "SampleCache";
URI uri = Caching.getCachingProvider().getDefaultURI();
ClassLoader cl1 = Thread.currentThread().getContextClassLoader();
ClassLoader cl2 = URLClassLoader.newInstance(new URL[] {}, cl1);
CacheManager cacheManager1 = Caching.getCachingProvider().getCacheManager(uri, cl1);
CacheManager cacheManager2 = Caching.getCachingProvider().getCacheManager(uri, cl2);
assertNotSame(cacheManager1, cacheManager2);
cacheManager1.createCache(cacheName, new MutableConfiguration());
Cache cache1 = cacheManager1.getCache(cacheName);
cacheManager2.createCache(cacheName, new MutableConfiguration());
Cache cache2 = cacheManager2.getCache(cacheName);
assertSame(cacheManager1, cache1.getCacheManager());
assertSame(cacheManager2, cache2.getCacheManager());
}
use of javax.cache.configuration.MutableConfiguration in project cache2k by cache2k.
the class CachingTest method cachingProviderGetCache.
@Test
public void cachingProviderGetCache() {
String name = "c1";
Caching.getCachingProvider().getCacheManager().createCache(name, new MutableConfiguration().setTypes(Long.class, String.class));
Cache cache = Caching.getCache(name, Long.class, String.class);
assertEquals(name, cache.getName());
Caching.getCachingProvider().getCacheManager().destroyCache(name);
}
use of javax.cache.configuration.MutableConfiguration in project cache2k by cache2k.
the class CachingTest method getCacheNullValueClass.
@Test(expected = NullPointerException.class)
public void getCacheNullValueClass() {
String name = "c1";
CacheManager manager = Caching.getCachingProvider().getCacheManager();
manager.createCache(name, new MutableConfiguration().setTypes(Long.class, String.class));
try {
Caching.getCache(name, Long.class, null);
} finally {
manager.destroyCache(name);
}
}
Aggregations