@ -1,5 +1,5 @@
/ *
/ *
* Copyright 2012 - 20 19 the original author or authors .
* Copyright 2012 - 20 20 the original author or authors .
*
*
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* you may not use this file except in compliance with the License .
@ -63,9 +63,8 @@ class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfiguratio
@Test
@Test
void defaultConfig ( ) {
void defaultConfig ( ) {
this . contextRunner
this . contextRunner . withPropertyValues ( "spring.session.store-type=redis" ,
. withPropertyValues ( "spring.session.store-type=redis" ,
"spring.redis.host=" + redis . getContainerIpAddress ( ) , "spring.redis.port=" + redis . getFirstMappedPort ( ) )
"spring.redis.port=" + redis . getFirstMappedPort ( ) )
. withConfiguration ( AutoConfigurations . of ( RedisAutoConfiguration . class ) )
. withConfiguration ( AutoConfigurations . of ( RedisAutoConfiguration . class ) )
. run ( validateSpringSessionUsesRedis ( "spring:session:event:0:created:" , FlushMode . ON_SAVE ,
. run ( validateSpringSessionUsesRedis ( "spring:session:event:0:created:" , FlushMode . ON_SAVE ,
SaveMode . ON_SET_ATTRIBUTE , "0 * * * * *" ) ) ;
SaveMode . ON_SET_ATTRIBUTE , "0 * * * * *" ) ) ;
@ -77,7 +76,8 @@ class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfiguratio
. withClassLoader ( new FilteredClassLoader ( HazelcastIndexedSessionRepository . class ,
. withClassLoader ( new FilteredClassLoader ( HazelcastIndexedSessionRepository . class ,
JdbcIndexedSessionRepository . class , MongoIndexedSessionRepository . class ) )
JdbcIndexedSessionRepository . class , MongoIndexedSessionRepository . class ) )
. withConfiguration ( AutoConfigurations . of ( RedisAutoConfiguration . class ) )
. withConfiguration ( AutoConfigurations . of ( RedisAutoConfiguration . class ) )
. withPropertyValues ( "spring.redis.port=" + redis . getFirstMappedPort ( ) )
. withPropertyValues ( "spring.redis.host=" + redis . getContainerIpAddress ( ) ,
"spring.redis.port=" + redis . getFirstMappedPort ( ) )
. run ( validateSpringSessionUsesRedis ( "spring:session:event:0:created:" , FlushMode . ON_SAVE ,
. run ( validateSpringSessionUsesRedis ( "spring:session:event:0:created:" , FlushMode . ON_SAVE ,
SaveMode . ON_SET_ATTRIBUTE , "0 * * * * *" ) ) ;
SaveMode . ON_SET_ATTRIBUTE , "0 * * * * *" ) ) ;
}
}
@ -88,6 +88,7 @@ class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfiguratio
. withPropertyValues ( "spring.session.store-type=redis" , "spring.session.redis.namespace=foo" ,
. withPropertyValues ( "spring.session.store-type=redis" , "spring.session.redis.namespace=foo" ,
"spring.session.redis.flush-mode=immediate" , "spring.session.redis.save-mode=on-get-attribute" ,
"spring.session.redis.flush-mode=immediate" , "spring.session.redis.save-mode=on-get-attribute" ,
"spring.session.redis.cleanup-cron=0 0 12 * * *" ,
"spring.session.redis.cleanup-cron=0 0 12 * * *" ,
"spring.redis.host=" + redis . getContainerIpAddress ( ) ,
"spring.redis.port=" + redis . getFirstMappedPort ( ) )
"spring.redis.port=" + redis . getFirstMappedPort ( ) )
. run ( validateSpringSessionUsesRedis ( "foo:event:0:created:" , FlushMode . IMMEDIATE ,
. run ( validateSpringSessionUsesRedis ( "foo:event:0:created:" , FlushMode . IMMEDIATE ,
SaveMode . ON_GET_ATTRIBUTE , "0 0 12 * * *" ) ) ;
SaveMode . ON_GET_ATTRIBUTE , "0 0 12 * * *" ) ) ;
@ -97,6 +98,7 @@ class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfiguratio
void redisSessionWithConfigureActionNone ( ) {
void redisSessionWithConfigureActionNone ( ) {
this . contextRunner . withConfiguration ( AutoConfigurations . of ( RedisAutoConfiguration . class ) )
this . contextRunner . withConfiguration ( AutoConfigurations . of ( RedisAutoConfiguration . class ) )
. withPropertyValues ( "spring.session.store-type=redis" , "spring.session.redis.configure-action=none" ,
. withPropertyValues ( "spring.session.store-type=redis" , "spring.session.redis.configure-action=none" ,
"spring.redis.host=" + redis . getContainerIpAddress ( ) ,
"spring.redis.port=" + redis . getFirstMappedPort ( ) )
"spring.redis.port=" + redis . getFirstMappedPort ( ) )
. run ( validateStrategy ( ConfigureRedisAction . NO_OP . getClass ( ) ) ) ;
. run ( validateStrategy ( ConfigureRedisAction . NO_OP . getClass ( ) ) ) ;
}
}
@ -105,6 +107,7 @@ class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfiguratio
void redisSessionWithDefaultConfigureActionNone ( ) {
void redisSessionWithDefaultConfigureActionNone ( ) {
this . contextRunner . withConfiguration ( AutoConfigurations . of ( RedisAutoConfiguration . class ) )
this . contextRunner . withConfiguration ( AutoConfigurations . of ( RedisAutoConfiguration . class ) )
. withPropertyValues ( "spring.session.store-type=redis" ,
. withPropertyValues ( "spring.session.store-type=redis" ,
"spring.redis.host=" + redis . getContainerIpAddress ( ) ,
"spring.redis.port=" + redis . getFirstMappedPort ( ) )
"spring.redis.port=" + redis . getFirstMappedPort ( ) )
. run ( validateStrategy ( ConfigureNotifyKeyspaceEventsAction . class ,
. run ( validateStrategy ( ConfigureNotifyKeyspaceEventsAction . class ,
entry ( "notify-keyspace-events" , "gxE" ) ) ) ;
entry ( "notify-keyspace-events" , "gxE" ) ) ) ;
@ -115,6 +118,7 @@ class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfiguratio
this . contextRunner . withConfiguration ( AutoConfigurations . of ( RedisAutoConfiguration . class ) )
this . contextRunner . withConfiguration ( AutoConfigurations . of ( RedisAutoConfiguration . class ) )
. withUserConfiguration ( MaxEntriesRedisAction . class )
. withUserConfiguration ( MaxEntriesRedisAction . class )
. withPropertyValues ( "spring.session.store-type=redis" ,
. withPropertyValues ( "spring.session.store-type=redis" ,
"spring.redis.host=" + redis . getContainerIpAddress ( ) ,
"spring.redis.port=" + redis . getFirstMappedPort ( ) )
"spring.redis.port=" + redis . getFirstMappedPort ( ) )
. run ( validateStrategy ( MaxEntriesRedisAction . class , entry ( "set-max-intset-entries" , "1024" ) ) ) ;
. run ( validateStrategy ( MaxEntriesRedisAction . class , entry ( "set-max-intset-entries" , "1024" ) ) ) ;