@ -127,12 +127,19 @@ public class CacheAutoConfigurationTests {
}
}
@Test
@Test
public void cacheResolver BackOff( ) throws Exception {
public void cacheResolver FromSupport BackOff( ) throws Exception {
load ( CustomCacheResolver Configuration. class ) ;
load ( CustomCacheResolver FromSupport Configuration. class ) ;
this . thrown . expect ( NoSuchBeanDefinitionException . class ) ;
this . thrown . expect ( NoSuchBeanDefinitionException . class ) ;
this . context . getBean ( CacheManager . class ) ;
this . context . getBean ( CacheManager . class ) ;
}
}
@Test
public void customCacheResolverCanBeDefined ( ) throws Exception {
load ( SpecificCacheResolverConfiguration . class , "spring.cache.type=simple" ) ;
validateCacheManager ( ConcurrentMapCacheManager . class ) ;
assertThat ( this . context . getBeansOfType ( CacheResolver . class ) ) . hasSize ( 1 ) ;
}
@Test
@Test
public void notSupportedCachingMode ( ) {
public void notSupportedCachingMode ( ) {
this . thrown . expect ( BeanCreationException . class ) ;
this . thrown . expect ( BeanCreationException . class ) ;
@ -833,7 +840,7 @@ public class CacheAutoConfigurationTests {
}
}
@Configuration
@Configuration
@ Import( { GenericCacheConfiguration . class , RedisCacheConfiguration . class } )
@ EnableCaching
static class CustomCacheManagerConfiguration {
static class CustomCacheManagerConfiguration {
@Bean
@Bean
@ -844,7 +851,7 @@ public class CacheAutoConfigurationTests {
}
}
@Configuration
@Configuration
@ Import( { GenericCacheConfiguration . class , RedisCacheConfiguration . class } )
@ EnableCaching
static class CustomCacheManagerFromSupportConfiguration
static class CustomCacheManagerFromSupportConfiguration
extends CachingConfigurerSupport {
extends CachingConfigurerSupport {
@ -859,18 +866,7 @@ public class CacheAutoConfigurationTests {
@Configuration
@Configuration
@EnableCaching
@EnableCaching
static class GuavaCacheBuilderConfiguration {
static class CustomCacheResolverFromSupportConfiguration extends CachingConfigurerSupport {
@Bean
CacheBuilder < Object , Object > cacheBuilder ( ) {
return CacheBuilder . newBuilder ( ) . recordStats ( ) ;
}
}
@Configuration
@Import ( { GenericCacheConfiguration . class , RedisCacheConfiguration . class } )
static class CustomCacheResolverConfiguration extends CachingConfigurerSupport {
@Override
@Override
@Bean
@Bean
@ -890,6 +886,28 @@ public class CacheAutoConfigurationTests {
}
}
@Configuration
@EnableCaching
static class SpecificCacheResolverConfiguration {
@Bean
public CacheResolver myCacheResolver ( ) {
return mock ( CacheResolver . class ) ;
}
}
@Configuration
@EnableCaching
static class GuavaCacheBuilderConfiguration {
@Bean
CacheBuilder < Object , Object > cacheBuilder ( ) {
return CacheBuilder . newBuilder ( ) . recordStats ( ) ;
}
}
@Configuration
@Configuration
@EnableCaching
@EnableCaching
static class CaffeineCacheBuilderConfiguration {
static class CaffeineCacheBuilderConfiguration {