use of javax.cache.configuration.MutableConfiguration in project cache2k by cache2k.
the class CacheManagerTest method getCaches_NotEmpty.
@Test
public void getCaches_NotEmpty() {
CacheManager cacheManager = getCacheManager();
ArrayList<String> caches1 = new ArrayList<String>();
cacheManager.createCache("c1", new MutableConfiguration());
cacheManager.createCache("c2", new MutableConfiguration());
cacheManager.createCache("c3", new MutableConfiguration());
caches1.add(cacheManager.getCache("c1").getName());
caches1.add(cacheManager.getCache("c2").getName());
caches1.add(cacheManager.getCache("c3").getName());
checkCollections(caches1, cacheManager.getCacheNames());
}
use of javax.cache.configuration.MutableConfiguration in project cache2k by cache2k.
the class CacheManagerTest method createCache_NullCacheName.
@Test
public void createCache_NullCacheName() {
CacheManager cacheManager = getCacheManager();
try {
cacheManager.createCache(null, new MutableConfiguration());
fail("should have thrown an exception - null cache name not allowed");
} catch (NullPointerException e) {
// good
}
}
use of javax.cache.configuration.MutableConfiguration in project cache2k by cache2k.
the class CacheManagerTest method createCacheSameName.
@Test
public void createCacheSameName() {
CacheManager cacheManager = getCacheManager();
String name1 = "c1";
cacheManager.createCache(name1, new MutableConfiguration());
Cache cache1 = cacheManager.getCache(name1);
assertEquals(cache1, cacheManager.getCache(name1));
ensureOpen(cache1);
try {
cacheManager.createCache(name1, new MutableConfiguration());
} catch (CacheException e) {
// expected
}
Cache cache2 = cacheManager.getCache(name1);
}
use of javax.cache.configuration.MutableConfiguration in project cache2k by cache2k.
the class CacheManagerTest method getCaches_MutateCacheManager.
@Test
public void getCaches_MutateCacheManager() {
CacheManager cacheManager = getCacheManager();
String removeName = "c2";
ArrayList<String> cacheNames1 = new ArrayList<String>();
cacheManager.createCache("c1", new MutableConfiguration());
Cache c1 = cacheManager.getCache("c1");
cacheNames1.add(c1.getName());
cacheManager.createCache(removeName, new MutableConfiguration());
cacheManager.createCache("c3", new MutableConfiguration());
Cache c3 = cacheManager.getCache("c3");
cacheNames1.add(c3.getName());
Iterable<String> cacheNames;
int size;
cacheNames = cacheManager.getCacheNames();
size = 0;
for (String cacheName : cacheNames) {
size++;
}
assertEquals(3, size);
cacheManager.destroyCache(removeName);
size = 0;
for (String cacheName : cacheNames) {
size++;
}
assertEquals(3, size);
cacheNames = cacheManager.getCacheNames();
size = 0;
for (String cacheName : cacheNames) {
size++;
}
assertEquals(2, size);
checkCollections(cacheNames1, cacheNames);
}
use of javax.cache.configuration.MutableConfiguration in project cache2k by cache2k.
the class CacheManagerTest method getOrCreateCache_Different.
@Test
public void getOrCreateCache_Different() {
String name1 = "c1";
CacheManager cacheManager = getCacheManager();
cacheManager.createCache(name1, new MutableConfiguration());
Cache cache1 = cacheManager.getCache(name1);
String name2 = "c2";
cacheManager.createCache(name2, new MutableConfiguration());
Cache cache2 = cacheManager.getCache(name2);
assertEquals(cache1, cacheManager.getCache(name1));
assertEquals(cache2, cacheManager.getCache(name2));
}
Aggregations