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);
}
});
}
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());
}
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());
}
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());
}
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);
}
Aggregations