use of javax.cache.Cache in project hazelcast by hazelcast.
the class BasicCacheLiteMemberTest method testCachesDestroyFromOtherManagers.
@Test
public void testCachesDestroyFromOtherManagers() {
CacheManager cacheManager = instanceCachingProvider.getCacheManager();
CacheManager cacheManager2 = liteCachingProvider.getCacheManager();
MutableConfiguration configuration = new MutableConfiguration();
final Cache c1 = cacheManager.createCache("c1", configuration);
final Cache c2 = cacheManager2.createCache("c2", configuration);
c1.put("key", "value");
c2.put("key", "value");
cacheManager.close();
assertTrueAllTheTime(new AssertTask() {
@Override
public void run() throws Exception {
c2.get("key");
}
}, 10);
}
use of javax.cache.Cache 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
}
}
});
}
use of javax.cache.Cache in project hazelcast by hazelcast.
the class CacheListenerTest method testSyncListener_shouldNotHang_whenCacheClosed.
@Test
public void testSyncListener_shouldNotHang_whenCacheClosed() {
final CachingProvider provider = getCachingProvider();
final String cacheName = randomMapName();
testSyncListener_shouldNotHang_AfterAction(cacheName, provider, new Runnable() {
@Override
public void run() {
Cache cache = provider.getCacheManager().getCache(cacheName);
cache.close();
}
});
}
use of javax.cache.Cache 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);
}
use of javax.cache.Cache in project hazelcast by hazelcast.
the class CacheThroughHazelcastInstanceTest method whenThereIsCacheConfigAndCreatedByInstance_thenReturnSameCache.
private void whenThereIsCacheConfigAndCreatedByInstance_thenReturnSameCache(boolean getCache) {
Config config = createConfig();
config.addCacheConfig(createCacheSimpleConfig(CACHE_NAME));
HazelcastInstance instance = createInstance(config);
Cache cache1 = retrieveCache(instance, getCache);
assertNotNull(cache1);
CachingProvider cachingProvider = createCachingProvider(instance);
CacheManager cacheManager = cachingProvider.getCacheManager();
Cache cache2 = cacheManager.getCache(CACHE_NAME);
assertNotNull(cache2);
// verify that they are same cache instance
assertTrue(cache1 == cache2);
}
Aggregations