Search in sources :

Example 26 with MutableConfiguration

use of javax.cache.configuration.MutableConfiguration in project cache2k by cache2k.

the class CacheManagerTest method createCache_NameOK.

@Test
public void createCache_NameOK() {
    String name = "c1";
    getCacheManager().createCache(name, new MutableConfiguration());
    Cache cache = getCacheManager().getCache(name);
    assertEquals(name, cache.getName());
}
Also used : MutableConfiguration(javax.cache.configuration.MutableConfiguration) Cache(javax.cache.Cache) Test(org.junit.Test)

Example 27 with MutableConfiguration

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

Example 28 with MutableConfiguration

use of javax.cache.configuration.MutableConfiguration in project cache2k by cache2k.

the class CacheManagerTest method close_cachesClosed.

@Test
public void close_cachesClosed() {
    CacheManager cacheManager = getCacheManager();
    cacheManager.createCache("c1", new MutableConfiguration());
    Cache cache1 = cacheManager.getCache("c1");
    cacheManager.createCache("c2", new MutableConfiguration());
    Cache cache2 = cacheManager.getCache("c2");
    cacheManager.close();
    ensureClosed(cache1);
    ensureClosed(cache2);
}
Also used : CacheManager(javax.cache.CacheManager) MutableConfiguration(javax.cache.configuration.MutableConfiguration) Cache(javax.cache.Cache) Test(org.junit.Test)

Example 29 with MutableConfiguration

use of javax.cache.configuration.MutableConfiguration 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);
}
Also used : CacheManager(javax.cache.CacheManager) URI(java.net.URI) MutableConfiguration(javax.cache.configuration.MutableConfiguration) CachingProvider(javax.cache.spi.CachingProvider) Test(org.junit.Test)

Example 30 with MutableConfiguration

use of javax.cache.configuration.MutableConfiguration 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));
}
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)151 Test (org.junit.Test)101 CacheManager (javax.cache.CacheManager)81 CachingProvider (javax.cache.spi.CachingProvider)39 Cache (javax.cache.Cache)35 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)21 QuickTest (com.hazelcast.test.annotation.QuickTest)16 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)15 Duration (javax.cache.expiry.Duration)15 CreatedExpiryPolicy (javax.cache.expiry.CreatedExpiryPolicy)14 Test (org.junit.jupiter.api.Test)14 CacheTestSupport.createServerCachingProvider (com.hazelcast.cache.CacheTestSupport.createServerCachingProvider)11 URI (java.net.URI)11 MutableCacheEntryListenerConfiguration (javax.cache.configuration.MutableCacheEntryListenerConfiguration)10 ExpiryPolicy (javax.cache.expiry.ExpiryPolicy)10 CountDownLatch (java.util.concurrent.CountDownLatch)8 ExtendedMutableConfiguration (org.cache2k.jcache.ExtendedMutableConfiguration)7 AssertTask (com.hazelcast.test.AssertTask)6 BaseTest (org.redisson.BaseTest)6 RedisRunner (org.redisson.RedisRunner)6