use of javax.cache.CacheManager in project hazelcast by hazelcast.
the class CacheHazelcastInstanceAwareTest method test_inject_hazelcastInstance_to_entryListener_if_itIs_hazelcastInstanceAware.
@Test
public void test_inject_hazelcastInstance_to_entryListener_if_itIs_hazelcastInstanceAware() {
long id1 = generateUniqueHazelcastInjectionId();
long id2 = generateUniqueHazelcastInjectionId();
CacheConfig<Integer, Integer> cacheConfig = createCacheConfig(CACHE_NAME);
cacheConfig.addCacheEntryListenerConfiguration(new HazelcastInstanceAwareCacheEntryListenerConfiguration(id1, id2));
HazelcastInstance hazelcastInstance = createInstance();
CacheManager cacheManager = createCachingProvider(hazelcastInstance).getCacheManager();
cacheManager.createCache(CACHE_NAME, cacheConfig);
assertEquals("Hazelcast instance has not been injected into entry listener factory!", Boolean.TRUE, HAZELCAST_INSTANCE_INJECTION_RESULT_MAP.get(id1));
assertEquals("Hazelcast instance has not been injected into entry listener!", Boolean.TRUE, HAZELCAST_INSTANCE_INJECTION_RESULT_MAP.get(id2));
}
use of javax.cache.CacheManager 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.CacheManager 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);
}
use of javax.cache.CacheManager in project hazelcast by hazelcast.
the class CacheThroughHazelcastInstanceTest method whenThereIsCacheConfigWithURIandCreatedByCacheManager_thenReturnsSameCache.
private void whenThereIsCacheConfigWithURIandCreatedByCacheManager_thenReturnsSameCache(boolean getCache) throws Exception {
HazelcastInstance instance = createInstance();
CachingProvider cachingProvider = createCachingProvider(instance);
Properties properties = HazelcastCachingProvider.propertiesByInstanceItself(instance);
CacheManager cacheManager = cachingProvider.getCacheManager(new URI("MY-URI"), null, properties);
Cache cache1 = cacheManager.createCache(CACHE_NAME, createCacheConfig(CACHE_NAME));
assertNotNull(cache1);
Cache cache2 = retrieveCache(instance, "MY-URI/" + CACHE_NAME, getCache);
assertNotNull(cache2);
// verify that they are same cache instance
assertTrue(cache1 == cache2);
}
use of javax.cache.CacheManager in project hazelcast by hazelcast.
the class CacheThroughHazelcastInstanceTest method whenThereIsCacheConfigWithSameNameButDifferentFullNameAndCreatedByCacheManager_thenFail.
private void whenThereIsCacheConfigWithSameNameButDifferentFullNameAndCreatedByCacheManager_thenFail(boolean getCache) throws Exception {
HazelcastInstance instance = createInstance();
CachingProvider cachingProvider = createCachingProvider(instance);
Properties properties = HazelcastCachingProvider.propertiesByInstanceItself(instance);
CacheManager cacheManager = cachingProvider.getCacheManager(new URI("MY-URI"), null, properties);
Cache cache1 = cacheManager.createCache(CACHE_NAME, createCacheConfig(CACHE_NAME));
assertNotNull(cache1);
retrieveCache(instance, getCache);
}
Aggregations