use of org.springframework.cache.jcache.JCacheCacheManager in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method jCacheCacheWithConfig.
@Test
public void jCacheCacheWithConfig() throws IOException {
String cachingProviderFqn = MockCachingProvider.class.getName();
String configLocation = "org/springframework/boot/autoconfigure/hazelcast/hazelcast-specific.xml";
load(JCacheCustomConfiguration.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());
}
use of org.springframework.cache.jcache.JCacheCacheManager in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method ehcache3AsJCacheWithConfig.
@Test
public void ehcache3AsJCacheWithConfig() throws IOException {
String cachingProviderFqn = EhcacheCachingProvider.class.getName();
String configLocation = "ehcache3.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(cacheManager.getCacheNames()).containsOnly("foo", "bar");
}
use of org.springframework.cache.jcache.JCacheCacheManager in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method infinispanAsJCacheWithCaches.
@Test
public void infinispanAsJCacheWithCaches() {
String cachingProviderFqn = JCachingProvider.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");
}
use of org.springframework.cache.jcache.JCacheCacheManager in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method jCacheCacheWithCachesAndCustomConfig.
@Test
public void jCacheCacheWithCachesAndCustomConfig() {
String cachingProviderFqn = MockCachingProvider.class.getName();
load(JCacheCustomConfiguration.class, "spring.cache.type=jcache", "spring.cache.jcache.provider=" + cachingProviderFqn, "spring.cache.cacheNames[0]=one", "spring.cache.cacheNames[1]=two");
JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class);
assertThat(cacheManager.getCacheNames()).containsOnly("one", "two");
CompleteConfiguration<?, ?> defaultCacheConfiguration = this.context.getBean(CompleteConfiguration.class);
verify(cacheManager.getCacheManager()).createCache("one", defaultCacheConfiguration);
verify(cacheManager.getCacheManager()).createCache("two", defaultCacheConfiguration);
}
use of org.springframework.cache.jcache.JCacheCacheManager in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method hazelcastAsJCacheWithCaches.
@Test
public void hazelcastAsJCacheWithCaches() {
String cachingProviderFqn = HazelcastCachingProvider.class.getName();
try {
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");
assertThat(Hazelcast.getAllHazelcastInstances()).hasSize(1);
} finally {
Caching.getCachingProvider(cachingProviderFqn).close();
}
}
Aggregations