Merge pull request #17278 from vpavic

* gh-17278:
  Start building against Spring Session Corn-M3 snapshots

Closes gh-17278
See gh-17348
pull/17411/head
Andy Wilkinson 5 years ago
commit 4f47b397e7

@ -58,7 +58,7 @@ class HazelcastSessionConfiguration {
setMaxInactiveIntervalInSeconds((int) timeout.getSeconds()); setMaxInactiveIntervalInSeconds((int) timeout.getSeconds());
} }
setSessionMapName(hazelcastSessionProperties.getMapName()); setSessionMapName(hazelcastSessionProperties.getMapName());
setHazelcastFlushMode(hazelcastSessionProperties.getFlushMode()); setFlushMode(hazelcastSessionProperties.getFlushMode());
} }
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2019 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.
@ -17,7 +17,7 @@
package org.springframework.boot.autoconfigure.session; package org.springframework.boot.autoconfigure.session;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.session.hazelcast.HazelcastFlushMode; import org.springframework.session.FlushMode;
/** /**
* Configuration properties for Hazelcast backed Spring Session. * Configuration properties for Hazelcast backed Spring Session.
@ -36,7 +36,7 @@ public class HazelcastSessionProperties {
/** /**
* Sessions flush mode. * Sessions flush mode.
*/ */
private HazelcastFlushMode flushMode = HazelcastFlushMode.ON_SAVE; private FlushMode flushMode = FlushMode.ON_SAVE;
public String getMapName() { public String getMapName() {
return this.mapName; return this.mapName;
@ -46,11 +46,11 @@ public class HazelcastSessionProperties {
this.mapName = mapName; this.mapName = mapName;
} }
public HazelcastFlushMode getFlushMode() { public FlushMode getFlushMode() {
return this.flushMode; return this.flushMode;
} }
public void setFlushMode(HazelcastFlushMode flushMode) { public void setFlushMode(FlushMode flushMode) {
this.flushMode = flushMode; this.flushMode = flushMode;
} }

@ -53,7 +53,6 @@ class RedisReactiveSessionConfiguration {
setMaxInactiveIntervalInSeconds((int) timeout.getSeconds()); setMaxInactiveIntervalInSeconds((int) timeout.getSeconds());
} }
setRedisNamespace(redisSessionProperties.getNamespace()); setRedisNamespace(redisSessionProperties.getNamespace());
setRedisFlushMode(redisSessionProperties.getFlushMode());
} }
} }

@ -74,7 +74,7 @@ class RedisSessionConfiguration {
setMaxInactiveIntervalInSeconds((int) timeout.getSeconds()); setMaxInactiveIntervalInSeconds((int) timeout.getSeconds());
} }
setRedisNamespace(redisSessionProperties.getNamespace()); setRedisNamespace(redisSessionProperties.getNamespace());
setRedisFlushMode(redisSessionProperties.getFlushMode()); setFlushMode(redisSessionProperties.getFlushMode());
setCleanupCron(redisSessionProperties.getCleanupCron()); setCleanupCron(redisSessionProperties.getCleanupCron());
} }

@ -17,7 +17,7 @@
package org.springframework.boot.autoconfigure.session; package org.springframework.boot.autoconfigure.session;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.session.data.redis.RedisFlushMode; import org.springframework.session.FlushMode;
/** /**
* Configuration properties for Redis backed Spring Session. * Configuration properties for Redis backed Spring Session.
@ -38,7 +38,7 @@ public class RedisSessionProperties {
/** /**
* Sessions flush mode. * Sessions flush mode.
*/ */
private RedisFlushMode flushMode = RedisFlushMode.ON_SAVE; private FlushMode flushMode = FlushMode.ON_SAVE;
/** /**
* The configure action to apply when no user defined ConfigureRedisAction bean is * The configure action to apply when no user defined ConfigureRedisAction bean is
@ -59,11 +59,11 @@ public class RedisSessionProperties {
this.namespace = namespace; this.namespace = namespace;
} }
public RedisFlushMode getFlushMode() { public FlushMode getFlushMode() {
return this.flushMode; return this.flushMode;
} }
public void setFlushMode(RedisFlushMode flushMode) { public void setFlushMode(FlushMode flushMode) {
this.flushMode = flushMode; this.flushMode = flushMode;
} }

@ -27,7 +27,6 @@ import org.springframework.boot.test.context.runner.ContextConsumer;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner; import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
import org.springframework.session.data.mongo.ReactiveMongoOperationsSessionRepository; import org.springframework.session.data.mongo.ReactiveMongoOperationsSessionRepository;
import org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository; import org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository;
import org.springframework.session.data.redis.RedisFlushMode;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -48,7 +47,7 @@ class ReactiveSessionAutoConfigurationRedisTests extends AbstractSessionAutoConf
this.contextRunner.withPropertyValues("spring.session.store-type=redis") this.contextRunner.withPropertyValues("spring.session.store-type=redis")
.withConfiguration( .withConfiguration(
AutoConfigurations.of(RedisAutoConfiguration.class, RedisReactiveAutoConfiguration.class)) AutoConfigurations.of(RedisAutoConfiguration.class, RedisReactiveAutoConfiguration.class))
.run(validateSpringSessionUsesRedis("spring:session:", RedisFlushMode.ON_SAVE)); .run(validateSpringSessionUsesRedis("spring:session:"));
} }
@Test @Test
@ -56,7 +55,7 @@ class ReactiveSessionAutoConfigurationRedisTests extends AbstractSessionAutoConf
this.contextRunner.withClassLoader(new FilteredClassLoader(ReactiveMongoOperationsSessionRepository.class)) this.contextRunner.withClassLoader(new FilteredClassLoader(ReactiveMongoOperationsSessionRepository.class))
.withConfiguration( .withConfiguration(
AutoConfigurations.of(RedisAutoConfiguration.class, RedisReactiveAutoConfiguration.class)) AutoConfigurations.of(RedisAutoConfiguration.class, RedisReactiveAutoConfiguration.class))
.run(validateSpringSessionUsesRedis("spring:session:", RedisFlushMode.ON_SAVE)); .run(validateSpringSessionUsesRedis("spring:session:"));
} }
@Test @Test
@ -64,18 +63,15 @@ class ReactiveSessionAutoConfigurationRedisTests extends AbstractSessionAutoConf
this.contextRunner this.contextRunner
.withConfiguration( .withConfiguration(
AutoConfigurations.of(RedisAutoConfiguration.class, RedisReactiveAutoConfiguration.class)) AutoConfigurations.of(RedisAutoConfiguration.class, RedisReactiveAutoConfiguration.class))
.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") .run(validateSpringSessionUsesRedis("foo:"));
.run(validateSpringSessionUsesRedis("foo:", RedisFlushMode.IMMEDIATE));
} }
private ContextConsumer<AssertableReactiveWebApplicationContext> validateSpringSessionUsesRedis(String namespace, private ContextConsumer<AssertableReactiveWebApplicationContext> validateSpringSessionUsesRedis(String namespace) {
RedisFlushMode flushMode) {
return (context) -> { return (context) -> {
ReactiveRedisOperationsSessionRepository repository = validateSessionRepository(context, ReactiveRedisOperationsSessionRepository repository = validateSessionRepository(context,
ReactiveRedisOperationsSessionRepository.class); ReactiveRedisOperationsSessionRepository.class);
assertThat(repository).hasFieldOrPropertyWithValue("namespace", namespace); assertThat(repository).hasFieldOrPropertyWithValue("namespace", namespace);
assertThat(repository).hasFieldOrPropertyWithValue("redisFlushMode", flushMode);
}; };
} }

@ -26,9 +26,9 @@ import org.springframework.boot.test.context.assertj.AssertableWebApplicationCon
import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.session.FlushMode;
import org.springframework.session.data.mongo.MongoOperationsSessionRepository; import org.springframework.session.data.mongo.MongoOperationsSessionRepository;
import org.springframework.session.data.redis.RedisOperationsSessionRepository; import org.springframework.session.data.redis.RedisOperationsSessionRepository;
import org.springframework.session.hazelcast.HazelcastFlushMode;
import org.springframework.session.hazelcast.HazelcastSessionRepository; import org.springframework.session.hazelcast.HazelcastSessionRepository;
import org.springframework.session.jdbc.JdbcOperationsSessionRepository; import org.springframework.session.jdbc.JdbcOperationsSessionRepository;
@ -84,8 +84,7 @@ class SessionAutoConfigurationHazelcastTests extends AbstractSessionAutoConfigur
"spring.session.hazelcast.flush-mode=immediate").run((context) -> { "spring.session.hazelcast.flush-mode=immediate").run((context) -> {
HazelcastSessionRepository repository = validateSessionRepository(context, HazelcastSessionRepository repository = validateSessionRepository(context,
HazelcastSessionRepository.class); HazelcastSessionRepository.class);
assertThat(repository).hasFieldOrPropertyWithValue("hazelcastFlushMode", assertThat(repository).hasFieldOrPropertyWithValue("flushMode", FlushMode.IMMEDIATE);
HazelcastFlushMode.IMMEDIATE);
}); });
} }

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

@ -191,7 +191,7 @@
<spring-restdocs.version>2.0.3.RELEASE</spring-restdocs.version> <spring-restdocs.version>2.0.3.RELEASE</spring-restdocs.version>
<spring-retry.version>1.2.4.RELEASE</spring-retry.version> <spring-retry.version>1.2.4.RELEASE</spring-retry.version>
<spring-security.version>5.2.0.BUILD-SNAPSHOT</spring-security.version> <spring-security.version>5.2.0.BUILD-SNAPSHOT</spring-security.version>
<spring-session-bom.version>Corn-M2</spring-session-bom.version> <spring-session-bom.version>Corn-BUILD-SNAPSHOT</spring-session-bom.version>
<spring-ws.version>3.0.7.RELEASE</spring-ws.version> <spring-ws.version>3.0.7.RELEASE</spring-ws.version>
<sqlite-jdbc.version>3.27.2</sqlite-jdbc.version> <sqlite-jdbc.version>3.27.2</sqlite-jdbc.version>
<statsd-client.version>3.1.0</statsd-client.version> <statsd-client.version>3.1.0</statsd-client.version>

Loading…
Cancel
Save