Search in sources :

Example 31 with CachingProvider

use of javax.cache.spi.CachingProvider in project hazelcast by hazelcast.

the class CacheListenerTest method testSyncListener_shouldNotHang_whenCacheDestroyed.

@Test
public void testSyncListener_shouldNotHang_whenCacheDestroyed() {
    final CachingProvider provider = getCachingProvider();
    final String cacheName = randomMapName();
    testSyncListener_shouldNotHang_AfterAction(cacheName, provider, new Runnable() {

        @Override
        public void run() {
            provider.getCacheManager().destroyCache(cacheName);
        }
    });
}
Also used : HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 32 with CachingProvider

use of javax.cache.spi.CachingProvider in project hazelcast by hazelcast.

the class CacheListenerTest method testReplaceWithSyncListener_whenEntryNotExists.

@Test(timeout = 30000)
public void testReplaceWithSyncListener_whenEntryNotExists() {
    CachingProvider cachingProvider = getCachingProvider();
    CacheManager cacheManager = cachingProvider.getCacheManager();
    CompleteConfiguration<String, String> config = new MutableConfiguration<String, String>().setTypes(String.class, String.class).addCacheEntryListenerConfiguration(new MutableCacheEntryListenerConfiguration<String, String>(FactoryBuilder.factoryOf(new TestListener(new AtomicInteger())), null, true, true));
    Cache<String, String> cache = cacheManager.createCache(randomString(), config);
    // there should not be any hanging due to sync listener
    cache.replace(randomString(), randomString());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CacheManager(javax.cache.CacheManager) MutableConfiguration(javax.cache.configuration.MutableConfiguration) HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 33 with CachingProvider

use of javax.cache.spi.CachingProvider in project hazelcast by hazelcast.

the class CacheListenerTest method testReplaceIfSameWithSyncListener_whenValueIsNotSame.

@Test(timeout = 30000)
public void testReplaceIfSameWithSyncListener_whenValueIsNotSame() {
    CachingProvider cachingProvider = getCachingProvider();
    CacheManager cacheManager = cachingProvider.getCacheManager();
    CompleteConfiguration<String, String> config = new MutableConfiguration<String, String>().setTypes(String.class, String.class).addCacheEntryListenerConfiguration(new MutableCacheEntryListenerConfiguration<String, String>(FactoryBuilder.factoryOf(new TestListener(new AtomicInteger())), null, true, true));
    Cache<String, String> cache = cacheManager.createCache(randomString(), config);
    String key = randomString();
    cache.put(key, randomString());
    // there should not be any hanging due to sync listener
    cache.replace(key, randomString(), randomString());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CacheManager(javax.cache.CacheManager) MutableConfiguration(javax.cache.configuration.MutableConfiguration) HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 34 with CachingProvider

use of javax.cache.spi.CachingProvider in project hazelcast by hazelcast.

the class CacheListenerTest method testPutIfAbsentWithSyncListener_whenEntryExists.

@Test(timeout = 30000)
public void testPutIfAbsentWithSyncListener_whenEntryExists() {
    CachingProvider cachingProvider = getCachingProvider();
    CacheManager cacheManager = cachingProvider.getCacheManager();
    CompleteConfiguration<String, String> config = new MutableConfiguration<String, String>().setTypes(String.class, String.class).addCacheEntryListenerConfiguration(new MutableCacheEntryListenerConfiguration<String, String>(FactoryBuilder.factoryOf(new TestListener(new AtomicInteger())), null, true, true));
    Cache<String, String> cache = cacheManager.createCache(randomString(), config);
    String key = randomString();
    cache.put(key, randomString());
    // there should not be any hanging due to sync listener
    cache.putIfAbsent(key, randomString());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CacheManager(javax.cache.CacheManager) MutableConfiguration(javax.cache.configuration.MutableConfiguration) HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 35 with CachingProvider

use of javax.cache.spi.CachingProvider in project hazelcast by hazelcast.

the class CacheThroughHazelcastInstanceTest method whenThereIsCacheConfigWithSameNameButDifferentFullNameAndCreatedByInstance_thenReturnDifferentCache.

private void whenThereIsCacheConfigWithSameNameButDifferentFullNameAndCreatedByInstance_thenReturnDifferentCache(boolean getCache) throws Exception {
    Config config = createConfig();
    config.addCacheConfig(createCacheSimpleConfig(CACHE_NAME));
    HazelcastInstance instance = createInstance(config);
    Cache cache1 = retrieveCache(instance, getCache);
    assertNotNull(cache1);
    CachingProvider cachingProvider = createCachingProvider(instance);
    Properties properties = HazelcastCachingProvider.propertiesByInstanceItself(instance);
    CacheManager cacheManager = cachingProvider.getCacheManager(new URI("MY-URI"), null, properties);
    Cache cache2 = cacheManager.getCache(CACHE_NAME);
    assertNotNull(cache2);
    assertNotEquals(cache1, cache2);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) Config(com.hazelcast.config.Config) CacheConfig(com.hazelcast.config.CacheConfig) HazelcastInstanceCacheManager(com.hazelcast.instance.HazelcastInstanceCacheManager) ICacheManager(com.hazelcast.core.ICacheManager) HazelcastCacheManager(com.hazelcast.cache.HazelcastCacheManager) CacheManager(javax.cache.CacheManager) Properties(java.util.Properties) URI(java.net.URI) Cache(javax.cache.Cache) ICache(com.hazelcast.cache.ICache) HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider) HazelcastCachingProvider(com.hazelcast.cache.HazelcastCachingProvider) CachingProvider(javax.cache.spi.CachingProvider)

Aggregations

CachingProvider (javax.cache.spi.CachingProvider)66 CacheManager (javax.cache.CacheManager)48 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)42 Test (org.junit.Test)33 QuickTest (com.hazelcast.test.annotation.QuickTest)28 HazelcastInstance (com.hazelcast.core.HazelcastInstance)24 ParallelTest (com.hazelcast.test.annotation.ParallelTest)24 CacheConfig (com.hazelcast.config.CacheConfig)21 HazelcastClientCachingProvider (com.hazelcast.client.cache.impl.HazelcastClientCachingProvider)18 ClientConfig (com.hazelcast.client.config.ClientConfig)14 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)12 MutableConfiguration (javax.cache.configuration.MutableConfiguration)12 ICache (com.hazelcast.cache.ICache)10 HazelcastClientProxy (com.hazelcast.client.impl.HazelcastClientProxy)10 Cache (javax.cache.Cache)10 HazelcastCachingProvider (com.hazelcast.cache.HazelcastCachingProvider)9 Config (com.hazelcast.config.Config)8 Data (com.hazelcast.nio.serialization.Data)8 Before (org.junit.Before)8 HazelcastCacheManager (com.hazelcast.cache.HazelcastCacheManager)7