Search in sources :

Example 6 with MutableConfiguration

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

the class CacheFromDifferentNodesTest method testCachesDestroy.

@Test
public void testCachesDestroy() {
    CacheManager cacheManager = cachingProvider1.getCacheManager();
    CacheManager cacheManager2 = cachingProvider2.getCacheManager();
    MutableConfiguration configuration = new MutableConfiguration();
    final Cache c1 = cacheManager.createCache("c1", configuration);
    final Cache c2 = cacheManager2.getCache("c1");
    c1.put("key", "value");
    cacheManager.destroyCache("c1");
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            try {
                c2.get("key");
                throw new AssertionError("get should throw IllegalStateException");
            } catch (IllegalStateException e) {
            //ignored as expected
            }
        }
    });
}
Also used : CacheManager(javax.cache.CacheManager) AssertTask(com.hazelcast.test.AssertTask) MutableConfiguration(javax.cache.configuration.MutableConfiguration) CacheEntryListenerException(javax.cache.event.CacheEntryListenerException) Cache(javax.cache.Cache) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 7 with MutableConfiguration

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

the class CacheListenerTest method testGetAndReplaceWithSyncListener_whenEntryNotExists.

@Test(timeout = 30000)
public void testGetAndReplaceWithSyncListener_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.getAndReplace(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 8 with MutableConfiguration

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

the class CacheListenerTest method testRemoveIfSameWithSyncListener_whenValueIsNotSame.

@Test(timeout = 30000)
public void testRemoveIfSameWithSyncListener_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.remove(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 9 with MutableConfiguration

use of javax.cache.configuration.MutableConfiguration 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 10 with MutableConfiguration

use of javax.cache.configuration.MutableConfiguration 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)

Aggregations

MutableConfiguration (javax.cache.configuration.MutableConfiguration)20 CacheManager (javax.cache.CacheManager)17 Test (org.junit.Test)17 ParallelTest (com.hazelcast.test.annotation.ParallelTest)15 QuickTest (com.hazelcast.test.annotation.QuickTest)15 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)12 CachingProvider (javax.cache.spi.CachingProvider)12 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)11 AssertTask (com.hazelcast.test.AssertTask)5 Cache (javax.cache.Cache)5 CacheEntryListenerException (javax.cache.event.CacheEntryListenerException)5 CacheService (com.hazelcast.cache.impl.CacheService)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 MutableCacheEntryListenerConfiguration (javax.cache.configuration.MutableCacheEntryListenerConfiguration)2 CacheContext (com.hazelcast.cache.impl.CacheContext)1 CachePartitionEventData (com.hazelcast.cache.impl.CachePartitionEventData)1 CachePartitionSegment (com.hazelcast.cache.impl.CachePartitionSegment)1 CacheReplicationOperation (com.hazelcast.cache.impl.operation.CacheReplicationOperation)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 HazelcastInstanceImpl (com.hazelcast.instance.HazelcastInstanceImpl)1