use of javax.cache.CacheManager in project hibernate-orm by hibernate.
the class JCacheRegionFactoryTest method testStopsCacheManagerOnShutdown.
@Test
public void testStopsCacheManagerOnShutdown() {
factory.start(null, EMPTY_MAP);
final CacheManager cacheManager = factory.getCacheManager();
assertThat(cacheManager.isClosed(), is(false));
factory.stop();
assertThat(cacheManager.isClosed(), is(true));
}
use of javax.cache.CacheManager in project hibernate-orm by hibernate.
the class JCacheRegionTest method testDestroyCallsDestroyCacheOnCacheManager.
@Test
public void testDestroyCallsDestroyCacheOnCacheManager() {
final Cache<Object, Object> cache = region.getCache();
CacheManager cacheManager = Mockito.mock(CacheManager.class);
when(cache.getCacheManager()).thenReturn(cacheManager);
when(cacheManager.getCache(CACHE_NAME)).thenReturn(cache);
region.destroy();
verify(cacheManager).destroyCache(CACHE_NAME);
}
use of javax.cache.CacheManager in project caffeine by ben-manes.
the class CaffeineCachingProvider method close.
@Override
public void close(URI uri, ClassLoader classLoader) {
synchronized (cacheManagers) {
ClassLoader managerClassLoader = getManagerClassLoader(classLoader);
Map<URI, CacheManager> cacheManagersByURI = cacheManagers.get(managerClassLoader);
if (cacheManagersByURI != null) {
CacheManager cacheManager = cacheManagersByURI.remove(getManagerUri(uri));
if (cacheManager != null) {
cacheManager.close();
}
if (cacheManagersByURI.isEmpty()) {
cacheManagers.remove(managerClassLoader);
}
}
}
}
use of javax.cache.CacheManager in project hazelcast by hazelcast.
the class BaseCacheEvictionPolicyComparatorTest method do_test_evictionPolicyComparator.
void do_test_evictionPolicyComparator(EvictionConfig evictionConfig, int iterationCount) {
HazelcastInstance instance = createInstance(createConfig());
CachingProvider cachingProvider = createCachingProvider(instance);
CacheManager cacheManager = cachingProvider.getCacheManager();
CacheConfig cacheConfig = createCacheConfig(CACHE_NAME);
cacheConfig.setEvictionConfig(evictionConfig);
Cache cache = cacheManager.createCache(CACHE_NAME, cacheConfig);
for (int i = 0; i < iterationCount; i++) {
cache.put(i, "Value-" + i);
}
AtomicLong callCounter = (AtomicLong) getUserContext(instance).get("callCounter");
assertTrue(callCounter.get() > 0);
}
use of javax.cache.CacheManager in project hazelcast by hazelcast.
the class CacheHazelcastInstanceAwareTest method test_inject_hazelcastInstance_to_cacheWriter_if_itIs_hazelcastInstanceAware.
@Test
public void test_inject_hazelcastInstance_to_cacheWriter_if_itIs_hazelcastInstanceAware() {
long id1 = generateUniqueHazelcastInjectionId();
long id2 = generateUniqueHazelcastInjectionId();
CacheConfig<Integer, Integer> cacheConfig = createCacheConfig(CACHE_NAME);
cacheConfig.setCacheWriterFactory(new HazelcastInstanceAwareCacheWriterFactory(id1, id2));
HazelcastInstance hazelcastInstance = createInstance();
CacheManager cacheManager = createCachingProvider(hazelcastInstance).getCacheManager();
Cache<Integer, Integer> cache = cacheManager.createCache(CACHE_NAME, cacheConfig);
cache.put(1, 1);
assertEquals("Hazelcast instance has not been injected into cache writer factory!", Boolean.TRUE, HAZELCAST_INSTANCE_INJECTION_RESULT_MAP.get(id1));
assertEquals("Hazelcast instance has not been injected into cache writer!", Boolean.TRUE, HAZELCAST_INSTANCE_INJECTION_RESULT_MAP.get(id2));
}
Aggregations