Search in sources :

Example 1 with MutableConfiguration

use of javax.cache.configuration.MutableConfiguration in project Payara by payara.

the class PayaraCacheResolverFactory method getExceptionCacheResolver.

@Override
public CacheResolver getExceptionCacheResolver(CacheMethodDetails<CacheResult> cmd) {
    CacheResult result = cmd.getCacheAnnotation();
    String cacheName = result.exceptionCacheName();
    Cache cache = cacheManager.getCache(cacheName);
    if ((cache == null)) {
        cache = cacheManager.createCache(cacheName, new MutableConfiguration<Object, Object>());
    }
    return new PayaraCacheResolver(cache);
}
Also used : CacheResult(javax.cache.annotation.CacheResult) MutableConfiguration(javax.cache.configuration.MutableConfiguration) Cache(javax.cache.Cache)

Example 2 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 3 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)

Example 4 with MutableConfiguration

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

the class CacheManagerTest method getOrCreateCache_NameOK.

@Test
public void getOrCreateCache_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 5 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)

Aggregations

MutableConfiguration (javax.cache.configuration.MutableConfiguration)94 Test (org.junit.Test)71 CacheManager (javax.cache.CacheManager)56 Cache (javax.cache.Cache)29 CachingProvider (javax.cache.spi.CachingProvider)21 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)20 QuickTest (com.hazelcast.test.annotation.QuickTest)16 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)15 CacheTestSupport.createServerCachingProvider (com.hazelcast.cache.CacheTestSupport.createServerCachingProvider)11 URI (java.net.URI)9 CountDownLatch (java.util.concurrent.CountDownLatch)8 Duration (javax.cache.expiry.Duration)8 MutableCacheEntryListenerConfiguration (javax.cache.configuration.MutableCacheEntryListenerConfiguration)7 AssertTask (com.hazelcast.test.AssertTask)6 Test (org.junit.jupiter.api.Test)6 BaseTest (org.redisson.BaseTest)6 RedisRunner (org.redisson.RedisRunner)6 RedisProcess (org.redisson.RedisRunner.RedisProcess)6 ExtendedMutableConfiguration (org.cache2k.jcache.ExtendedMutableConfiguration)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4