use of org.springframework.cache.jcache.JCacheCacheManager in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method jCacheCacheWithProvider.
@Test
public void jCacheCacheWithProvider() {
String cachingProviderFqn = MockCachingProvider.class.getName();
load(DefaultCacheConfiguration.class, "spring.cache.type=jcache", "spring.cache.jcache.provider=" + cachingProviderFqn);
JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class);
assertThat(cacheManager.getCacheNames()).isEmpty();
assertThat(this.context.getBean(javax.cache.CacheManager.class)).isEqualTo(cacheManager.getCacheManager());
}
use of org.springframework.cache.jcache.JCacheCacheManager in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method hazelcastAsJCacheWithExistingHazelcastInstance.
@Test
public void hazelcastAsJCacheWithExistingHazelcastInstance() throws IOException {
String cachingProviderFqn = HazelcastCachingProvider.class.getName();
load(new Class[] { HazelcastAutoConfiguration.class, DefaultCacheConfiguration.class }, "spring.cache.type=jcache", "spring.cache.jcache.provider=" + cachingProviderFqn);
JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class);
javax.cache.CacheManager jCacheManager = cacheManager.getCacheManager();
assertThat(jCacheManager).isInstanceOf(com.hazelcast.cache.HazelcastCacheManager.class);
assertThat(this.context.getBeansOfType(HazelcastInstance.class)).hasSize(1);
HazelcastInstance hazelcastInstance = this.context.getBean(HazelcastInstance.class);
assertThat(((com.hazelcast.cache.HazelcastCacheManager) jCacheManager).getHazelcastInstance()).isSameAs(hazelcastInstance);
assertThat(hazelcastInstance.getName()).isEqualTo("default-instance");
assertThat(Hazelcast.getAllHazelcastInstances()).hasSize(1);
}
use of org.springframework.cache.jcache.JCacheCacheManager in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method jCacheCacheWithCachesAndCustomizer.
@Test
public void jCacheCacheWithCachesAndCustomizer() {
String cachingProviderFqn = HazelcastCachingProvider.class.getName();
try {
load(JCacheWithCustomizerConfiguration.class, "spring.cache.type=jcache", "spring.cache.jcache.provider=" + cachingProviderFqn, "spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar");
JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class);
// see customizer
assertThat(cacheManager.getCacheNames()).containsOnly("foo", "custom1");
} finally {
Caching.getCachingProvider(cachingProviderFqn).close();
}
}
use of org.springframework.cache.jcache.JCacheCacheManager in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method hazelcastAsJCacheWithConfig.
@Test
public void hazelcastAsJCacheWithConfig() throws IOException {
String cachingProviderFqn = HazelcastCachingProvider.class.getName();
try {
String configLocation = "org/springframework/boot/autoconfigure/hazelcast/hazelcast-specific.xml";
load(DefaultCacheConfiguration.class, "spring.cache.type=jcache", "spring.cache.jcache.provider=" + cachingProviderFqn, "spring.cache.jcache.config=" + configLocation);
JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class);
Resource configResource = new ClassPathResource(configLocation);
assertThat(cacheManager.getCacheManager().getURI()).isEqualTo(configResource.getURI());
assertThat(Hazelcast.getAllHazelcastInstances()).hasSize(1);
} finally {
Caching.getCachingProvider(cachingProviderFqn).close();
}
}
use of org.springframework.cache.jcache.JCacheCacheManager in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method jCacheCacheWithCaches.
@Test
public void jCacheCacheWithCaches() {
String cachingProviderFqn = MockCachingProvider.class.getName();
load(DefaultCacheConfiguration.class, "spring.cache.type=jcache", "spring.cache.jcache.provider=" + cachingProviderFqn, "spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar");
JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class);
assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
}
Aggregations