Search in sources :

Example 36 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) CacheTestSupport.createServerCachingProvider(com.hazelcast.cache.CacheTestSupport.createServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 37 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) CacheTestSupport.createServerCachingProvider(com.hazelcast.cache.CacheTestSupport.createServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 38 with MutableConfiguration

use of javax.cache.configuration.MutableConfiguration 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) CacheTestSupport.createServerCachingProvider(com.hazelcast.cache.CacheTestSupport.createServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 39 with MutableConfiguration

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

the class CacheManagerManagementTest method testMBeansLeftoversAreDetected.

@Test
public void testMBeansLeftoversAreDetected() throws Exception {
    CacheManager cacheManager = getCacheManager();
    MutableConfiguration<Integer, Integer> cacheConfig = new MutableConfiguration<>();
    cacheConfig.setManagementEnabled(true);
    Cache<Integer, Integer> cache = cacheManager.createCache("int-cache", cacheConfig);
    assertThrows(AssertionError.class, JsrTestUtil::assertNoMBeanLeftovers);
    cache.close();
}
Also used : CacheManager(javax.cache.CacheManager) MutableConfiguration(javax.cache.configuration.MutableConfiguration) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 40 with MutableConfiguration

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

the class ClientCacheCreationTest method createSingleCache_whenMemberDown_throwsOperationTimeoutException.

@Test(expected = OperationTimeoutException.class)
public void createSingleCache_whenMemberDown_throwsOperationTimeoutException() {
    HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance();
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.getConnectionStrategyConfig().getConnectionRetryConfig().setClusterConnectTimeoutMillis(Long.MAX_VALUE);
    clientConfig.setProperty(ClientProperty.INVOCATION_TIMEOUT_SECONDS.getName(), "2");
    HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
    HazelcastClientCachingProvider cachingProvider = createClientCachingProvider(client);
    CacheManager cacheManager = cachingProvider.getCacheManager();
    hazelcastInstance.shutdown();
    MutableConfiguration configuration = new MutableConfiguration();
    cacheManager.createCache("xmlCache", configuration);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastClientCachingProvider(com.hazelcast.client.cache.impl.HazelcastClientCachingProvider) CacheManager(javax.cache.CacheManager) ClientConfig(com.hazelcast.client.config.ClientConfig) MutableConfiguration(javax.cache.configuration.MutableConfiguration) CacheCreationTest(com.hazelcast.cache.CacheCreationTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

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