@ -373,8 +373,10 @@ public class CacheAutoConfigurationTests {
@@ -373,8 +373,10 @@ public class CacheAutoConfigurationTests {
HazelcastCacheManager . class ) ;
HazelcastInstance actual = getHazelcastInstance ( cacheManager ) ;
assertThat ( actual ) . isSameAs ( hazelcastInstance ) ;
assertThat ( actual . getConfig ( ) . getConfigurationUrl ( ) ) . isEqualTo ( new ClassPathResource (
"org/springframework/boot/autoconfigure/cache/hazelcast-specific.xml" ) . getURL ( ) ) ;
assertThat ( actual . getConfig ( ) . getConfigurationUrl ( ) )
. isEqualTo ( new ClassPathResource (
"org/springframework/boot/autoconfigure/cache/hazelcast-specific.xml" )
. getURL ( ) ) ;
cacheManager . getCache ( "foobar" ) ;
assertThat ( cacheManager . getCacheNames ( ) ) . containsOnly ( "foobar" ) ;
}
@ -583,13 +585,15 @@ public class CacheAutoConfigurationTests {
@@ -583,13 +585,15 @@ public class CacheAutoConfigurationTests {
return type . cast ( cacheManager ) ;
}
private void testCustomizers ( Class < ? > config , String cacheType , String . . . expectedCustomizerNames ) {
@SuppressWarnings ( "rawtypes" )
private void testCustomizers ( Class < ? > config , String cacheType ,
String . . . expectedCustomizerNames ) {
load ( config , "spring.cache.type=" + cacheType ) ;
CacheManager cacheManager = validateCacheManager ( CacheManager . class ) ;
List < String > expected = new ArrayList < String > ( ) ;
expected . addAll ( Arrays . asList ( expectedCustomizerNames ) ) ;
Map < String , CacheManagerTestCustomizer > map =
this . context . getBeansOfType ( CacheManagerTestCustomizer . class ) ;
Map < String , CacheManagerTestCustomizer > map = this . context
. getBeansOfType ( CacheManagerTestCustomizer . class ) ;
for ( Map . Entry < String , CacheManagerTestCustomizer > entry : map . entrySet ( ) ) {
if ( expected . contains ( entry . getKey ( ) ) ) {
expected . remove ( entry . getKey ( ) ) ;
@ -611,7 +615,8 @@ public class CacheAutoConfigurationTests {
@@ -611,7 +615,8 @@ public class CacheAutoConfigurationTests {
this . context = applicationContext ;
}
private static HazelcastInstance getHazelcastInstance ( HazelcastCacheManager cacheManager ) {
private static HazelcastInstance getHazelcastInstance (
HazelcastCacheManager cacheManager ) {
return ( HazelcastInstance ) new DirectFieldAccessor ( cacheManager )
. getPropertyValue ( "hazelcastInstance" ) ;
}
@ -651,7 +656,8 @@ public class CacheAutoConfigurationTests {
@@ -651,7 +656,8 @@ public class CacheAutoConfigurationTests {
}
@Configuration
@Import ( { GenericCacheConfiguration . class , CacheManagerCustomizersConfiguration . class } )
@Import ( { GenericCacheConfiguration . class ,
CacheManagerCustomizersConfiguration . class } )
static class GenericCacheAndCustomizersConfiguration {
}
@ -667,7 +673,7 @@ public class CacheAutoConfigurationTests {
@@ -667,7 +673,7 @@ public class CacheAutoConfigurationTests {
}
@Configuration
@Import ( { RedisCacheConfiguration . class , CacheManagerCustomizersConfiguration . class } )
@Import ( { RedisCacheConfiguration . class , CacheManagerCustomizersConfiguration . class } )
static class RedisCacheAndCustomizersConfiguration {
}
@ -745,8 +751,8 @@ public class CacheAutoConfigurationTests {
@@ -745,8 +751,8 @@ public class CacheAutoConfigurationTests {
}
@Configuration
@ImportAutoConfiguration ( { CacheAutoConfiguration . class ,
HazelcastAutoConfiguration . class } )
@ImportAutoConfiguration ( { CacheAutoConfiguration . class ,
HazelcastAutoConfiguration . class } )
static class HazelcastAndCacheConfiguration {
}
@ -765,7 +771,7 @@ public class CacheAutoConfigurationTests {
@@ -765,7 +771,7 @@ public class CacheAutoConfigurationTests {
}
@Configuration
@Import ( { GenericCacheConfiguration . class , RedisCacheConfiguration . class } )
@Import ( { GenericCacheConfiguration . class , RedisCacheConfiguration . class } )
static class CustomCacheManagerConfiguration {
@Bean
@ -776,7 +782,7 @@ public class CacheAutoConfigurationTests {
@@ -776,7 +782,7 @@ public class CacheAutoConfigurationTests {
}
@Configuration
@Import ( { GenericCacheConfiguration . class , RedisCacheConfiguration . class } )
@Import ( { GenericCacheConfiguration . class , RedisCacheConfiguration . class } )
static class CustomCacheManagerFromSupportConfiguration
extends CachingConfigurerSupport {
@ -801,7 +807,7 @@ public class CacheAutoConfigurationTests {
@@ -801,7 +807,7 @@ public class CacheAutoConfigurationTests {
}
@Configuration
@Import ( { GenericCacheConfiguration . class , RedisCacheConfiguration . class } )
@Import ( { GenericCacheConfiguration . class , RedisCacheConfiguration . class } )
static class CustomCacheResolverConfiguration extends CachingConfigurerSupport {
@Override
@ -839,37 +845,44 @@ public class CacheAutoConfigurationTests {
@@ -839,37 +845,44 @@ public class CacheAutoConfigurationTests {
@Bean
public CacheManagerCustomizer < SimpleCacheManager > genericCacheManagerCustomizer ( ) {
return new CacheManagerTestCustomizer < SimpleCacheManager > ( ) { } ;
return new CacheManagerTestCustomizer < SimpleCacheManager > ( ) {
} ;
}
@Bean
public CacheManagerCustomizer < RedisCacheManager > redisCacheManagerCustomizer ( ) {
return new CacheManagerTestCustomizer < RedisCacheManager > ( ) { } ;
return new CacheManagerTestCustomizer < RedisCacheManager > ( ) {
} ;
}
@Bean
public CacheManagerCustomizer < EhCacheCacheManager > ehCacheCacheManagerCustomizer ( ) {
return new CacheManagerTestCustomizer < EhCacheCacheManager > ( ) { } ;
return new CacheManagerTestCustomizer < EhCacheCacheManager > ( ) {
} ;
}
@Bean
public CacheManagerCustomizer < HazelcastCacheManager > hazelcastCacheManagerCustomizer ( ) {
return new CacheManagerTestCustomizer < HazelcastCacheManager > ( ) { } ;
return new CacheManagerTestCustomizer < HazelcastCacheManager > ( ) {
} ;
}
@Bean
public CacheManagerCustomizer < SpringEmbeddedCacheManager > infinispanCacheManagerCustomizer ( ) {
return new CacheManagerTestCustomizer < SpringEmbeddedCacheManager > ( ) { } ;
return new CacheManagerTestCustomizer < SpringEmbeddedCacheManager > ( ) {
} ;
}
@Bean
public CacheManagerCustomizer < GuavaCacheManager > guavaCacheManagerCustomizer ( ) {
return new CacheManagerTestCustomizer < GuavaCacheManager > ( ) { } ;
return new CacheManagerTestCustomizer < GuavaCacheManager > ( ) {
} ;
}
}
static abstract class CacheManagerTestCustomizer < C extends CacheManager > implements CacheManagerCustomizer < C > {
static abstract class CacheManagerTestCustomizer < C extends CacheManager >
implements CacheManagerCustomizer < C > {
private C cacheManager ;