Search in sources :

Example 61 with MutableConfiguration

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

Example 62 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)

Example 63 with MutableConfiguration

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

the class CacheManagerTest method createCache_Same.

@Test
public void createCache_Same() {
    String name = "c1";
    CacheManager cacheManager = getCacheManager();
    try {
        cacheManager.createCache(name, new MutableConfiguration());
        Cache cache1 = cacheManager.getCache(name);
        cacheManager.createCache(name, new MutableConfiguration());
        Cache cache2 = cacheManager.getCache(name);
        fail();
    } catch (CacheException exception) {
    // expected
    }
}
Also used : CacheException(javax.cache.CacheException) CacheManager(javax.cache.CacheManager) MutableConfiguration(javax.cache.configuration.MutableConfiguration) Cache(javax.cache.Cache) Test(org.junit.Test)

Example 64 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 65 with MutableConfiguration

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

the class CacheManagerTest method getNullTypeCacheRequest.

@Test(expected = NullPointerException.class)
public void getNullTypeCacheRequest() {
    CacheManager cacheManager = getCacheManager();
    MutableConfiguration config = new MutableConfiguration();
    cacheManager.createCache("untyped-cache", config);
    Cache cache = cacheManager.getCache("untyped-cache", null, null);
}
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