|
|
|
@ -32,8 +32,8 @@ import org.springframework.boot.testsupport.testcontainers.DisabledWithoutDocker
|
|
|
|
|
import org.springframework.boot.testsupport.testcontainers.RedisContainer;
|
|
|
|
|
import org.springframework.data.redis.connection.RedisConnection;
|
|
|
|
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|
|
|
|
import org.springframework.session.FlushMode;
|
|
|
|
|
import org.springframework.session.data.mongo.MongoOperationsSessionRepository;
|
|
|
|
|
import org.springframework.session.data.redis.RedisFlushMode;
|
|
|
|
|
import org.springframework.session.data.redis.RedisOperationsSessionRepository;
|
|
|
|
|
import org.springframework.session.data.redis.config.ConfigureNotifyKeyspaceEventsAction;
|
|
|
|
|
import org.springframework.session.data.redis.config.ConfigureRedisAction;
|
|
|
|
@ -64,7 +64,7 @@ class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfiguratio
|
|
|
|
|
.withPropertyValues("spring.session.store-type=redis",
|
|
|
|
|
"spring.redis.port=" + redis.getFirstMappedPort())
|
|
|
|
|
.withConfiguration(AutoConfigurations.of(RedisAutoConfiguration.class))
|
|
|
|
|
.run(validateSpringSessionUsesRedis("spring:session:event:0:created:", RedisFlushMode.ON_SAVE,
|
|
|
|
|
.run(validateSpringSessionUsesRedis("spring:session:event:0:created:", FlushMode.ON_SAVE,
|
|
|
|
|
"0 * * * * *"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -75,7 +75,7 @@ class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfiguratio
|
|
|
|
|
JdbcOperationsSessionRepository.class, MongoOperationsSessionRepository.class))
|
|
|
|
|
.withConfiguration(AutoConfigurations.of(RedisAutoConfiguration.class))
|
|
|
|
|
.withPropertyValues("spring.redis.port=" + redis.getFirstMappedPort())
|
|
|
|
|
.run(validateSpringSessionUsesRedis("spring:session:event:0:created:", RedisFlushMode.ON_SAVE,
|
|
|
|
|
.run(validateSpringSessionUsesRedis("spring:session:event:0:created:", FlushMode.ON_SAVE,
|
|
|
|
|
"0 * * * * *"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -85,7 +85,7 @@ class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfiguratio
|
|
|
|
|
.withPropertyValues("spring.session.store-type=redis", "spring.session.redis.namespace=foo",
|
|
|
|
|
"spring.session.redis.flush-mode=immediate", "spring.session.redis.cleanup-cron=0 0 12 * * *",
|
|
|
|
|
"spring.redis.port=" + redis.getFirstMappedPort())
|
|
|
|
|
.run(validateSpringSessionUsesRedis("foo:event:0:created:", RedisFlushMode.IMMEDIATE, "0 0 12 * * *"));
|
|
|
|
|
.run(validateSpringSessionUsesRedis("foo:event:0:created:", FlushMode.IMMEDIATE, "0 0 12 * * *"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@ -116,12 +116,12 @@ class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfiguratio
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ContextConsumer<AssertableWebApplicationContext> validateSpringSessionUsesRedis(
|
|
|
|
|
String sessionCreatedChannelPrefix, RedisFlushMode flushMode, String cleanupCron) {
|
|
|
|
|
String sessionCreatedChannelPrefix, FlushMode flushMode, String cleanupCron) {
|
|
|
|
|
return (context) -> {
|
|
|
|
|
RedisOperationsSessionRepository repository = validateSessionRepository(context,
|
|
|
|
|
RedisOperationsSessionRepository.class);
|
|
|
|
|
assertThat(repository.getSessionCreatedChannelPrefix()).isEqualTo(sessionCreatedChannelPrefix);
|
|
|
|
|
assertThat(repository).hasFieldOrPropertyWithValue("redisFlushMode", flushMode);
|
|
|
|
|
assertThat(repository).hasFieldOrPropertyWithValue("flushMode", flushMode);
|
|
|
|
|
SpringBootRedisHttpSessionConfiguration configuration = context
|
|
|
|
|
.getBean(SpringBootRedisHttpSessionConfiguration.class);
|
|
|
|
|
assertThat(configuration).hasFieldOrPropertyWithValue("cleanupCron", cleanupCron);
|
|
|
|
|