use of javax.cache.spi.CachingProvider 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.spi.CachingProvider 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.spi.CachingProvider 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);
}
use of javax.cache.spi.CachingProvider in project hazelcast by hazelcast.
the class CacheSplitBrainTest method createCache.
private static Cache createCache(HazelcastInstance hazelcastInstance, CacheConfig cacheConfig) {
CachingProvider cachingProvider1 = HazelcastServerCachingProvider.createCachingProvider(hazelcastInstance);
CacheManager cacheManager1 = cachingProvider1.getCacheManager();
return cacheManager1.createCache(cacheConfig.getName(), cacheConfig);
}
use of javax.cache.spi.CachingProvider in project hazelcast by hazelcast.
the class CacheConfigTest method testGetPreConfiguredCache.
@Test
public void testGetPreConfiguredCache() {
Config config = new Config();
config.addCacheConfig(new CacheSimpleConfig().setName("test"));
int count = 4;
TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(count);
for (int i = 0; i < count; i++) {
HazelcastInstance instance = factory.newHazelcastInstance(config);
CachingProvider provider = HazelcastServerCachingProvider.createCachingProvider(instance);
CacheManager cacheManager = provider.getCacheManager();
Cache<Object, Object> cache = cacheManager.getCache("test");
assertNotNull("Pre-configured cache cannot be retrieved on instance: " + i, cache);
}
}
Aggregations