Search in sources :

Example 96 with MutableConfiguration

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());
}
Also used : ArrayList(java.util.ArrayList) CacheManager(javax.cache.CacheManager) MutableConfiguration(javax.cache.configuration.MutableConfiguration) Test(org.junit.Test)

Example 97 with MutableConfiguration

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
    }
}
Also used : CacheManager(javax.cache.CacheManager) MutableConfiguration(javax.cache.configuration.MutableConfiguration) Test(org.junit.Test)

Example 98 with MutableConfiguration

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);
}
Also used : CacheException(javax.cache.CacheException) CacheManager(javax.cache.CacheManager) MutableConfiguration(javax.cache.configuration.MutableConfiguration) Cache(javax.cache.Cache) Test(org.junit.Test)

Example 99 with MutableConfiguration

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);
}
Also used : ArrayList(java.util.ArrayList) CacheManager(javax.cache.CacheManager) MutableConfiguration(javax.cache.configuration.MutableConfiguration) Cache(javax.cache.Cache) Test(org.junit.Test)

Example 100 with MutableConfiguration

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));
}
Also used : CacheManager(javax.cache.CacheManager) MutableConfiguration(javax.cache.configuration.MutableConfiguration) Cache(javax.cache.Cache) Test(org.junit.Test)

Aggregations

MutableConfiguration (javax.cache.configuration.MutableConfiguration)146 Test (org.junit.Test)97 CacheManager (javax.cache.CacheManager)76 CachingProvider (javax.cache.spi.CachingProvider)35 Cache (javax.cache.Cache)32 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)21 QuickTest (com.hazelcast.test.annotation.QuickTest)16 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)15 Test (org.junit.jupiter.api.Test)12 CacheTestSupport.createServerCachingProvider (com.hazelcast.cache.CacheTestSupport.createServerCachingProvider)11 URI (java.net.URI)11 CreatedExpiryPolicy (javax.cache.expiry.CreatedExpiryPolicy)11 MutableCacheEntryListenerConfiguration (javax.cache.configuration.MutableCacheEntryListenerConfiguration)10 Duration (javax.cache.expiry.Duration)10 CountDownLatch (java.util.concurrent.CountDownLatch)8 ExpiryPolicy (javax.cache.expiry.ExpiryPolicy)7 ExtendedMutableConfiguration (org.cache2k.jcache.ExtendedMutableConfiguration)7 AssertTask (com.hazelcast.test.AssertTask)6 BaseTest (org.redisson.BaseTest)6 RedisRunner (org.redisson.RedisRunner)6