use of org.springframework.cache.jcache.JCacheCacheManager in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method ehcache3AsJCacheWithCaches.
@Test
public void ehcache3AsJCacheWithCaches() {
String cachingProviderFqn = EhcacheCachingProvider.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 jCacheCacheWithExistingJCacheManager.
@Test
public void jCacheCacheWithExistingJCacheManager() {
load(JCacheCustomCacheManager.class, "spring.cache.type=jcache");
JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class);
assertThat(cacheManager.getCacheManager()).isEqualTo(this.context.getBean("customJCacheCacheManager"));
}
use of org.springframework.cache.jcache.JCacheCacheManager in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method infinispanAsJCacheWithConfig.
@Test
public void infinispanAsJCacheWithConfig() throws IOException {
String cachingProviderFqn = JCachingProvider.class.getName();
String configLocation = "infinispan.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());
}
use of org.springframework.cache.jcache.JCacheCacheManager in project spring-boot by spring-projects.
the class JCacheCacheConfiguration method jCacheCacheManager.
@Bean
@ConditionalOnMissingBean
public CacheManager jCacheCacheManager() throws IOException {
CacheManager jCacheCacheManager = createCacheManager();
List<String> cacheNames = this.cacheProperties.getCacheNames();
if (!CollectionUtils.isEmpty(cacheNames)) {
for (String cacheName : cacheNames) {
jCacheCacheManager.createCache(cacheName, getDefaultCacheConfiguration());
}
}
customize(jCacheCacheManager);
return jCacheCacheManager;
}
Aggregations