Harmonize data configuration

Any classes that rely on Spring Data being on the classpath
have been moved under a data package.

Certain configuration properties have also been updated to
accurately reflect whether Spring Data is required for the
auto-configuration to work.

Closes gh-11574
This commit is contained in:
Madhura Bhave
2022-05-05 15:45:42 -07:00
parent 1af5994d8f
commit 0991bd3983
65 changed files with 836 additions and 303 deletions

View File

@@ -33,7 +33,7 @@ import org.springframework.core.io.Resource;
* @author Stephane Nicoll
* @since 1.3.0
*/
@ConfigurationProperties(prefix = "spring.data.cassandra")
@ConfigurationProperties(prefix = "spring.cassandra")
public class CassandraProperties {
/**

View File

@@ -108,7 +108,7 @@ public class CassandraDataAutoConfiguration {
session.setSession(this.session);
session.setConverter(converter);
Binder binder = Binder.get(environment);
binder.bind("spring.data.cassandra.schema-action", SchemaAction.class).ifBound(session::setSchemaAction);
binder.bind("spring.cassandra.schema-action", SchemaAction.class).ifBound(session::setSchemaAction);
return session;
}

View File

@@ -46,7 +46,7 @@ import org.springframework.util.StringUtils;
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass({ GenericObjectPool.class, JedisConnection.class, Jedis.class })
@ConditionalOnMissingBean(RedisConnectionFactory.class)
@ConditionalOnProperty(name = "spring.redis.client-type", havingValue = "jedis", matchIfMissing = true)
@ConditionalOnProperty(name = "spring.data.redis.client-type", havingValue = "jedis", matchIfMissing = true)
class JedisConnectionConfiguration extends RedisConnectionConfiguration {
JedisConnectionConfiguration(RedisProperties properties,

View File

@@ -55,7 +55,7 @@ import org.springframework.util.StringUtils;
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(RedisClient.class)
@ConditionalOnProperty(name = "spring.redis.client-type", havingValue = "lettuce", matchIfMissing = true)
@ConditionalOnProperty(name = "spring.data.redis.client-type", havingValue = "lettuce", matchIfMissing = true)
class LettuceConnectionConfiguration extends RedisConnectionConfiguration {
LettuceConnectionConfiguration(RedisProperties properties,

View File

@@ -32,7 +32,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @author Stephane Nicoll
* @since 1.0.0
*/
@ConfigurationProperties(prefix = "spring.redis")
@ConfigurationProperties(prefix = "spring.data.redis")
public class RedisProperties {
/**

View File

@@ -36,12 +36,12 @@ class RedisUrlSyntaxFailureAnalyzer extends AbstractFailureAnalyzer<RedisUrlSynt
URI uri = new URI(cause.getUrl());
if ("redis-sentinel".equals(uri.getScheme())) {
return new FailureAnalysis(getUnsupportedSchemeDescription(cause.getUrl(), uri.getScheme()),
"Use spring.redis.sentinel properties instead of spring.redis.url to configure Redis sentinel addresses.",
"Use spring.data.redis.sentinel properties instead of spring.data.redis.url to configure Redis sentinel addresses.",
cause);
}
if ("redis-socket".equals(uri.getScheme())) {
return new FailureAnalysis(getUnsupportedSchemeDescription(cause.getUrl(), uri.getScheme()),
"Configure the appropriate Spring Data Redis connection beans directly instead of setting the property 'spring.redis.url'.",
"Configure the appropriate Spring Data Redis connection beans directly instead of setting the property 'spring.data.redis.url'.",
cause);
}
if (!"redis".equals(uri.getScheme()) && !"rediss".equals(uri.getScheme())) {
@@ -54,7 +54,7 @@ class RedisUrlSyntaxFailureAnalyzer extends AbstractFailureAnalyzer<RedisUrlSynt
// fall through to default description and action
}
return new FailureAnalysis(getDefaultDescription(cause.getUrl()),
"Review the value of the property 'spring.redis.url'.", cause);
"Review the value of the property 'spring.data.redis.url'.", cause);
}
private String getDefaultDescription(String url) {

View File

@@ -189,7 +189,6 @@
"description": "Class name of the servlet to use for JSPs. If registered is true and this class\n\t * is on the classpath then it will be registered.",
"defaultValue": "org.apache.jasper.servlet.JspServlet"
},
{
"name": "server.servlet.jsp.init-parameters",
"description": "Init parameters used to configure the JSP servlet."
@@ -497,6 +496,48 @@
"level": "error"
}
},
{
"name": "spring.cassandra.compression",
"defaultValue": "none"
},
{
"name": "spring.cassandra.connection.connect-timeout",
"defaultValue": "5s"
},
{
"name": "spring.cassandra.connection.init-query-timeout",
"defaultValue": "5s"
},
{
"name": "spring.cassandra.contact-points",
"defaultValue": [
"127.0.0.1:9042"
]
},
{
"name": "spring.cassandra.controlconnection.timeout",
"defaultValue": "5s"
},
{
"name": "spring.cassandra.pool.heartbeat-interval",
"defaultValue": "30s"
},
{
"name": "spring.cassandra.pool.idle-timeout",
"defaultValue": "5s"
},
{
"name": "spring.cassandra.request.page-size",
"defaultValue": 5000
},
{
"name": "spring.cassandra.request.throttler.type",
"defaultValue": "none"
},
{
"name": "spring.cassandra.request.timeout",
"defaultValue": "2s"
},
{
"name": "spring.couchbase.bootstrap-hosts",
"type": "java.util.List<java.lang.String>",
@@ -616,25 +657,53 @@
},
{
"name": "spring.data.cassandra.compression",
"defaultValue": "none"
"defaultValue": "none",
"deprecation": {
"replacement": "spring.cassandra.compression",
"level": "error"
}
},
{
"name": "spring.data.cassandra.config",
"type": "org.springframework.core.io.Resource",
"deprecation": {
"replacement": "spring.cassandra.config",
"level": "error"
}
},
{
"name": "spring.data.cassandra.connection.connect-timeout",
"defaultValue": "5s"
"defaultValue": "5s",
"deprecation": {
"replacement": "spring.cassandra.connection.connect-timeout",
"level": "error"
}
},
{
"name": "spring.data.cassandra.connection.init-query-timeout",
"defaultValue": "5s"
"defaultValue": "5s",
"deprecation": {
"replacement": "spring.cassandra.connection.init-query-timeout",
"level": "error"
}
},
{
"name": "spring.data.cassandra.contact-points",
"defaultValue": [
"127.0.0.1:9042"
]
],
"deprecation": {
"replacement": "spring.cassandra.contact-points",
"level": "error"
}
},
{
"name": "spring.data.cassandra.controlconnection.timeout",
"defaultValue": "5s"
"defaultValue": "5s",
"deprecation": {
"replacement": "spring.cassandra.controlconnection.timeout",
"level": "error"
}
},
{
"name": "spring.data.cassandra.jmx-enabled",
@@ -645,6 +714,14 @@
"level": "error"
}
},
{
"name": "spring.data.cassandra.keyspace-name",
"type": "java.lang.String",
"deprecation": {
"replacement": "spring.cassandra.keyspace-name",
"level": "error"
}
},
{
"name": "spring.data.cassandra.load-balancing-policy",
"type": "java.lang.Class",
@@ -653,19 +730,43 @@
"level": "error"
}
},
{
"name": "spring.data.cassandra.local-datacenter",
"type": "java.lang.String",
"deprecation": {
"replacement": "spring.cassandra.local-datacenter",
"level": "error"
}
},
{
"name": "spring.data.cassandra.password",
"type": "java.lang.String",
"deprecation": {
"replacement": "spring.cassandra.password",
"level": "error"
}
},
{
"name": "spring.data.cassandra.pool.heartbeat-interval",
"defaultValue": "30s"
"defaultValue": "30s",
"deprecation": {
"replacement": "spring.cassandra.pool.heartbeat-interval",
"level": "error"
}
},
{
"name": "spring.data.cassandra.pool.idle-timeout",
"defaultValue": "5s"
"defaultValue": "5s",
"deprecation": {
"replacement": "spring.cassandra.pool.idle-timeout",
"level": "error"
}
},
{
"name": "spring.data.cassandra.pool.max-queue-size",
"type": "java.lang.Integer",
"deprecation": {
"replacement": "spring.data.cassandra.request.throttler.max-queue-size",
"replacement": "spring.cassandra.request.throttler.max-queue-size",
"level": "error"
}
},
@@ -678,6 +779,14 @@
"level": "error"
}
},
{
"name": "spring.data.cassandra.port",
"type": "java.lang.Integer",
"deprecation": {
"replacement": "spring.cassandra.port",
"level": "error"
}
},
{
"name": "spring.data.cassandra.reconnection-policy",
"type": "java.lang.Class",
@@ -692,17 +801,77 @@
"description": "Type of Cassandra repositories to enable.",
"defaultValue": "auto"
},
{
"name": "spring.data.cassandra.request.consistency",
"type": "com.datastax.oss.driver.api.core.DefaultConsistencyLevel",
"deprecation": {
"replacement": "spring.cassandra.request.consistency",
"level": "error"
}
},
{
"name": "spring.data.cassandra.request.page-size",
"defaultValue": 5000
"defaultValue": 5000,
"deprecation": {
"replacement": "spring.cassandra.request.page-size",
"level": "error"
}
},
{
"name": "spring.data.cassandra.request.serial-consistency",
"type": "com.datastax.oss.driver.api.core.DefaultConsistencyLevel",
"deprecation": {
"replacement": "spring.cassandra.request.serial-consistency",
"level": "error"
}
},
{
"name": "spring.data.cassandra.request.throttler.drain-interval",
"type": "java.time.Duration",
"deprecation": {
"replacement": "spring.cassandra.request.throttler.drain-interval",
"level": "error"
}
},
{
"name": "spring.data.cassandra.request.throttler.max-concurrent-requests",
"type": "java.lang.Integer",
"deprecation": {
"replacement": "spring.cassandra.request.throttler.max-concurrent-requests",
"level": "error"
}
},
{
"name": "spring.data.cassandra.request.throttler.max-queue-size",
"type": "java.lang.Integer",
"deprecation": {
"replacement": "spring.cassandra.request.throttler.max-queue-size",
"level": "error"
}
},
{
"name": "spring.data.cassandra.request.throttler.max-requests-per-second",
"type": "java.lang.Integer",
"deprecation": {
"replacement": "spring.cassandra.request.throttler.max-requests-per-second",
"level": "error"
}
},
{
"name": "spring.data.cassandra.request.throttler.type",
"defaultValue": "none"
"defaultValue": "none",
"deprecation": {
"replacement": "spring.cassandra.request.throttler.type",
"level": "error"
}
},
{
"name": "spring.data.cassandra.request.timeout",
"defaultValue": "2s"
"defaultValue": "2s",
"deprecation": {
"replacement": "spring.cassandra.request.timeout",
"level": "error"
}
},
{
"name": "spring.data.cassandra.retry-policy",
@@ -712,6 +881,38 @@
"level": "error"
}
},
{
"name": "spring.data.cassandra.schema-action",
"type": "java.lang.String",
"deprecation": {
"replacement": "spring.cassandra.schema-action",
"level": "error"
}
},
{
"name": "spring.data.cassandra.session-name",
"type": "java.lang.String",
"deprecation": {
"replacement": "spring.cassandra.session-name",
"level": "error"
}
},
{
"name": "spring.data.cassandra.ssl",
"type": "java.lang.Boolean",
"deprecation": {
"replacement": "spring.cassandra.ssl",
"level": "error"
}
},
{
"name": "spring.data.cassandra.username",
"type": "java.lang.String",
"deprecation": {
"replacement": "spring.cassandra.username",
"level": "error"
}
},
{
"name": "spring.data.couchbase.consistency",
"type": "org.springframework.data.couchbase.core.query.Consistency",
@@ -1995,6 +2196,258 @@
"replacement": "spring.reactor.debug-agent.enabled"
}
},
{
"name": "spring.redis.client-name",
"type": "java.lang.String",
"deprecation": {
"replacement": "spring.data.redis.client-name",
"level": "error"
}
},
{
"name": "spring.redis.client-type",
"type": "org.springframework.boot.autoconfigure.data.redis.RedisProperties$ClientType",
"deprecation": {
"replacement": "spring.data.redis.client-type",
"level": "error"
}
},
{
"name": "spring.redis.cluster.max-redirects",
"type": "java.lang.Integer",
"deprecation": {
"replacement": "spring.data.redis.cluster.max-redirects",
"level": "error"
}
},
{
"name": "spring.redis.cluster.nodes",
"type": "java.util.List<java.lang.String>",
"deprecation": {
"replacement": "spring.data.redis.cluster.nodes",
"level": "error"
}
},
{
"name": "spring.redis.connect-timeout",
"type": "java.time.Duration",
"deprecation": {
"replacement": "spring.data.redis.connect-timeout",
"level": "error"
}
},
{
"name": "spring.redis.database",
"type": "java.lang.Integer",
"deprecation": {
"replacement": "spring.data.redis.database",
"level": "error"
}
},
{
"name": "spring.redis.host",
"type": "java.lang.String",
"deprecation": {
"replacement": "spring.data.redis.host",
"level": "error"
}
},
{
"name": "spring.redis.jedis.pool.enabled",
"type": "java.lang.Boolean",
"deprecation": {
"level": "error"
}
},
{
"name": "spring.redis.jedis.pool.max-active",
"type": "java.lang.Integer",
"deprecation": {
"level": "error"
}
},
{
"name": "spring.redis.jedis.pool.max-idle",
"type": "java.lang.Integer",
"deprecation": {
"level": "error"
}
},
{
"name": "spring.redis.jedis.pool.max-wait",
"type": "java.time.Duration",
"deprecation": {
"level": "error"
}
},
{
"name": "spring.redis.jedis.pool.min-idle",
"type": "java.lang.Integer",
"deprecation": {
"level": "error"
}
},
{
"name": "spring.redis.jedis.pool.time-between-eviction-runs",
"type": "java.time.Duration",
"deprecation": {
"level": "error"
}
},
{
"name": "spring.redis.lettuce.cluster.refresh.adaptive",
"type": "java.lang.Boolean",
"deprecation": {
"replacement": "spring.data.redis.lettuce.cluster.refresh.adaptive",
"level": "error"
}
},
{
"name": "spring.redis.lettuce.cluster.refresh.dynamic-refresh-sources",
"type": "java.lang.Boolean",
"deprecation": {
"replacement": "spring.data.redis.lettuce.cluster.refresh.dynamic-refresh-sources",
"level": "error"
}
},
{
"name": "spring.redis.lettuce.cluster.refresh.period",
"type": "java.time.Duration",
"deprecation": {
"replacement": "spring.data.redis.lettuce.cluster.refresh.period",
"level": "error"
}
},
{
"name": "spring.redis.lettuce.pool.enabled",
"type": "java.lang.Boolean",
"deprecation": {
"level": "error"
}
},
{
"name": "spring.redis.lettuce.pool.max-active",
"type": "java.lang.Integer",
"deprecation": {
"level": "error"
}
},
{
"name": "spring.redis.lettuce.pool.max-idle",
"type": "java.lang.Integer",
"deprecation": {
"level": "error"
}
},
{
"name": "spring.redis.lettuce.pool.max-wait",
"type": "java.time.Duration",
"deprecation": {
"level": "error"
}
},
{
"name": "spring.redis.lettuce.pool.min-idle",
"type": "java.lang.Integer",
"deprecation": {
"level": "error"
}
},
{
"name": "spring.redis.lettuce.pool.time-between-eviction-runs",
"type": "java.time.Duration",
"deprecation": {
"level": "error"
}
},
{
"name": "spring.redis.lettuce.shutdown-timeout",
"type": "java.time.Duration",
"deprecation": {
"replacement": "spring.data.redis.lettuce.shutdown-timeout",
"level": "error"
}
},
{
"name": "spring.redis.password",
"type": "java.lang.String",
"deprecation": {
"replacement": "spring.data.redis.password",
"level": "error"
}
},
{
"name": "spring.redis.port",
"type": "java.lang.Integer",
"deprecation": {
"replacement": "spring.data.redis.port",
"level": "error"
}
},
{
"name": "spring.redis.sentinel.master",
"type": "java.lang.String",
"deprecation": {
"replacement": "spring.data.redis.sentinel.master",
"level": "error"
}
},
{
"name": "spring.redis.sentinel.nodes",
"type": "java.util.List<java.lang.String>",
"deprecation": {
"replacement": "spring.data.redis.sentinel.nodes",
"level": "error"
}
},
{
"name": "spring.redis.sentinel.password",
"type": "java.lang.String",
"deprecation": {
"replacement": "spring.data.redis.sentinel.password",
"level": "error"
}
},
{
"name": "spring.redis.sentinel.username",
"type": "java.lang.String",
"deprecation": {
"replacement": "spring.data.redis.sentinel.username",
"level": "error"
}
},
{
"name": "spring.redis.ssl",
"type": "java.lang.Boolean",
"deprecation": {
"replacement": "spring.data.redis.ssl",
"level": "error"
}
},
{
"name": "spring.redis.timeout",
"type": "java.time.Duration",
"deprecation": {
"replacement": "spring.data.redis.timeout",
"level": "error"
}
},
{
"name": "spring.redis.url",
"type": "java.lang.String",
"deprecation": {
"replacement": "spring.data.redis.url",
"level": "error"
}
},
{
"name": "spring.redis.username",
"type": "java.lang.String",
"deprecation": {
"replacement": "spring.data.redis.username",
"level": "error"
}
},
{
"name": "spring.resources.add-mappings",
"type": "java.lang.Boolean",
@@ -2509,7 +2962,7 @@
]
},
{
"name": "spring.data.cassandra.schema-action",
"name": "spring.cassandra.schema-action",
"providers": [
{
"name": "handle-as",
@@ -2929,4 +3382,4 @@
]
}
]
}
}

View File

@@ -47,12 +47,9 @@ class CassandraAutoConfigurationIntegrationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(CassandraAutoConfiguration.class)).withPropertyValues(
"spring.data.cassandra.contact-points:" + cassandra.getHost() + ":"
+ cassandra.getFirstMappedPort(),
"spring.data.cassandra.local-datacenter=datacenter1",
"spring.data.cassandra.connection.connect-timeout=60s",
"spring.data.cassandra.connection.init-query-timeout=60s",
"spring.data.cassandra.request.timeout=60s");
"spring.cassandra.contact-points:" + cassandra.getHost() + ":" + cassandra.getFirstMappedPort(),
"spring.cassandra.local-datacenter=datacenter1", "spring.cassandra.connection.connect-timeout=60s",
"spring.cassandra.connection.init-query-timeout=60s", "spring.cassandra.request.timeout=60s");
@Test
void whenTheContextIsClosedThenTheDriverConfigLoaderIsClosed() {

View File

@@ -73,8 +73,8 @@ class CassandraAutoConfigurationTests {
@Test
void driverConfigLoaderWithContactPoints() {
this.contextRunner.withPropertyValues("spring.data.cassandra.contact-points=cluster.example.com:9042",
"spring.data.cassandra.local-datacenter=cassandra-eu1").run((context) -> {
this.contextRunner.withPropertyValues("spring.cassandra.contact-points=cluster.example.com:9042",
"spring.cassandra.local-datacenter=cassandra-eu1").run((context) -> {
assertThat(context).hasSingleBean(DriverConfigLoader.class);
DriverExecutionProfile configuration = context.getBean(DriverConfigLoader.class).getInitialConfig()
.getDefaultProfile();
@@ -88,8 +88,8 @@ class CassandraAutoConfigurationTests {
@Test
void driverConfigLoaderWithContactPointAndNoPort() {
this.contextRunner
.withPropertyValues("spring.data.cassandra.contact-points=cluster.example.com,another.example.com:9041",
"spring.data.cassandra.local-datacenter=cassandra-eu1")
.withPropertyValues("spring.cassandra.contact-points=cluster.example.com,another.example.com:9041",
"spring.cassandra.local-datacenter=cassandra-eu1")
.run((context) -> {
assertThat(context).hasSingleBean(DriverConfigLoader.class);
DriverExecutionProfile configuration = context.getBean(DriverConfigLoader.class).getInitialConfig()
@@ -104,8 +104,8 @@ class CassandraAutoConfigurationTests {
@Test
void driverConfigLoaderWithContactPointAndNoPortAndCustomPort() {
this.contextRunner
.withPropertyValues("spring.data.cassandra.contact-points=cluster.example.com:9041,another.example.com",
"spring.data.cassandra.port=9043", "spring.data.cassandra.local-datacenter=cassandra-eu1")
.withPropertyValues("spring.cassandra.contact-points=cluster.example.com:9041,another.example.com",
"spring.cassandra.port=9043", "spring.cassandra.local-datacenter=cassandra-eu1")
.run((context) -> {
assertThat(context).hasSingleBean(DriverConfigLoader.class);
DriverExecutionProfile configuration = context.getBean(DriverConfigLoader.class).getInitialConfig()
@@ -119,7 +119,7 @@ class CassandraAutoConfigurationTests {
@Test
void driverConfigLoaderWithCustomSessionName() {
this.contextRunner.withPropertyValues("spring.data.cassandra.session-name=testcluster").run((context) -> {
this.contextRunner.withPropertyValues("spring.cassandra.session-name=testcluster").run((context) -> {
assertThat(context).hasSingleBean(DriverConfigLoader.class);
assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile()
.getString(DefaultDriverOption.SESSION_NAME)).isEqualTo("testcluster");
@@ -129,7 +129,7 @@ class CassandraAutoConfigurationTests {
@Test
void driverConfigLoaderWithCustomSessionNameAndCustomizer() {
this.contextRunner.withUserConfiguration(SimpleDriverConfigLoaderBuilderCustomizerConfig.class)
.withPropertyValues("spring.data.cassandra.session-name=testcluster").run((context) -> {
.withPropertyValues("spring.cassandra.session-name=testcluster").run((context) -> {
assertThat(context).hasSingleBean(DriverConfigLoader.class);
assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile()
.getString(DefaultDriverOption.SESSION_NAME)).isEqualTo("overridden-name");
@@ -138,8 +138,8 @@ class CassandraAutoConfigurationTests {
@Test
void driverConfigLoaderCustomizeConnectionOptions() {
this.contextRunner.withPropertyValues("spring.data.cassandra.connection.connect-timeout=200ms",
"spring.data.cassandra.connection.init-query-timeout=10").run((context) -> {
this.contextRunner.withPropertyValues("spring.cassandra.connection.connect-timeout=200ms",
"spring.cassandra.connection.init-query-timeout=10").run((context) -> {
DriverExecutionProfile config = context.getBean(DriverConfigLoader.class).getInitialConfig()
.getDefaultProfile();
assertThat(config.getInt(DefaultDriverOption.CONNECTION_CONNECT_TIMEOUT)).isEqualTo(200);
@@ -149,8 +149,8 @@ class CassandraAutoConfigurationTests {
@Test
void driverConfigLoaderCustomizePoolOptions() {
this.contextRunner.withPropertyValues("spring.data.cassandra.pool.idle-timeout=42",
"spring.data.cassandra.pool.heartbeat-interval=62").run((context) -> {
this.contextRunner.withPropertyValues("spring.cassandra.pool.idle-timeout=42",
"spring.cassandra.pool.heartbeat-interval=62").run((context) -> {
DriverExecutionProfile config = context.getBean(DriverConfigLoader.class).getInitialConfig()
.getDefaultProfile();
assertThat(config.getInt(DefaultDriverOption.HEARTBEAT_TIMEOUT)).isEqualTo(42);
@@ -160,9 +160,9 @@ class CassandraAutoConfigurationTests {
@Test
void driverConfigLoaderCustomizeRequestOptions() {
this.contextRunner.withPropertyValues("spring.data.cassandra.request.timeout=5s",
"spring.data.cassandra.request.consistency=two",
"spring.data.cassandra.request.serial-consistency=quorum", "spring.data.cassandra.request.page-size=42")
this.contextRunner
.withPropertyValues("spring.cassandra.request.timeout=5s", "spring.cassandra.request.consistency=two",
"spring.cassandra.request.serial-consistency=quorum", "spring.cassandra.request.page-size=42")
.run((context) -> {
DriverExecutionProfile config = context.getBean(DriverConfigLoader.class).getInitialConfig()
.getDefaultProfile();
@@ -175,12 +175,11 @@ class CassandraAutoConfigurationTests {
@Test
void driverConfigLoaderCustomizeControlConnectionOptions() {
this.contextRunner.withPropertyValues("spring.data.cassandra.controlconnection.timeout=200ms")
.run((context) -> {
DriverExecutionProfile config = context.getBean(DriverConfigLoader.class).getInitialConfig()
.getDefaultProfile();
assertThat(config.getInt(DefaultDriverOption.CONTROL_CONNECTION_TIMEOUT)).isEqualTo(200);
});
this.contextRunner.withPropertyValues("spring.cassandra.controlconnection.timeout=200ms").run((context) -> {
DriverExecutionProfile config = context.getBean(DriverConfigLoader.class).getInitialConfig()
.getDefaultProfile();
assertThat(config.getInt(DefaultDriverOption.CONTROL_CONNECTION_TIMEOUT)).isEqualTo(200);
});
}
@Test
@@ -195,7 +194,7 @@ class CassandraAutoConfigurationTests {
@Test
void driverConfigLoaderWithRateLimitingRequiresExtraConfiguration() {
this.contextRunner.withPropertyValues("spring.data.cassandra.request.throttler.type=rate-limiting")
this.contextRunner.withPropertyValues("spring.cassandra.request.throttler.type=rate-limiting")
.run((context) -> assertThatThrownBy(() -> context.getBean(CqlSession.class))
.hasMessageContaining("Error instantiating class RateLimitingRequestThrottler")
.hasMessageContaining("No configuration setting found for key"));
@@ -203,9 +202,9 @@ class CassandraAutoConfigurationTests {
@Test
void driverConfigLoaderCustomizeConcurrencyLimitingRequestThrottler() {
this.contextRunner.withPropertyValues("spring.data.cassandra.request.throttler.type=concurrency-limiting",
"spring.data.cassandra.request.throttler.max-concurrent-requests=62",
"spring.data.cassandra.request.throttler.max-queue-size=72").run((context) -> {
this.contextRunner.withPropertyValues("spring.cassandra.request.throttler.type=concurrency-limiting",
"spring.cassandra.request.throttler.max-concurrent-requests=62",
"spring.cassandra.request.throttler.max-queue-size=72").run((context) -> {
DriverExecutionProfile config = context.getBean(DriverConfigLoader.class).getInitialConfig()
.getDefaultProfile();
assertThat(config.getString(DefaultDriverOption.REQUEST_THROTTLER_CLASS))
@@ -218,10 +217,10 @@ class CassandraAutoConfigurationTests {
@Test
void driverConfigLoaderCustomizeRateLimitingRequestThrottler() {
this.contextRunner.withPropertyValues("spring.data.cassandra.request.throttler.type=rate-limiting",
"spring.data.cassandra.request.throttler.max-requests-per-second=62",
"spring.data.cassandra.request.throttler.max-queue-size=72",
"spring.data.cassandra.request.throttler.drain-interval=16ms").run((context) -> {
this.contextRunner.withPropertyValues("spring.cassandra.request.throttler.type=rate-limiting",
"spring.cassandra.request.throttler.max-requests-per-second=62",
"spring.cassandra.request.throttler.max-queue-size=72",
"spring.cassandra.request.throttler.drain-interval=16ms").run((context) -> {
DriverExecutionProfile config = context.getBean(DriverConfigLoader.class).getInitialConfig()
.getDefaultProfile();
assertThat(config.getString(DefaultDriverOption.REQUEST_THROTTLER_CLASS))
@@ -236,8 +235,8 @@ class CassandraAutoConfigurationTests {
@Test
void driverConfigLoaderWithConfigComplementSettings() {
String configLocation = "org/springframework/boot/autoconfigure/cassandra/simple.conf";
this.contextRunner.withPropertyValues("spring.data.cassandra.session-name=testcluster",
"spring.data.cassandra.config=" + configLocation).run((context) -> {
this.contextRunner.withPropertyValues("spring.cassandra.session-name=testcluster",
"spring.cassandra.config=" + configLocation).run((context) -> {
assertThat(context).hasSingleBean(DriverConfigLoader.class);
assertThat(context.getBean(DriverConfigLoader.class).getInitialConfig().getDefaultProfile()
.getString(DefaultDriverOption.SESSION_NAME)).isEqualTo("testcluster");
@@ -249,7 +248,7 @@ class CassandraAutoConfigurationTests {
@Test // gh-31238
void driverConfigLoaderWithConfigOverridesDefaults() {
String configLocation = "org/springframework/boot/autoconfigure/cassandra/override-defaults.conf";
this.contextRunner.withPropertyValues("spring.data.cassandra.config=" + configLocation).run((context) -> {
this.contextRunner.withPropertyValues("spring.cassandra.config=" + configLocation).run((context) -> {
DriverExecutionProfile actual = context.getBean(DriverConfigLoader.class).getInitialConfig()
.getDefaultProfile();
assertThat(actual.getString(DefaultDriverOption.SESSION_NAME)).isEqualTo("advanced session");
@@ -271,7 +270,7 @@ class CassandraAutoConfigurationTests {
@Test
void driverConfigLoaderWithConfigCreateProfiles() {
String configLocation = "org/springframework/boot/autoconfigure/cassandra/profiles.conf";
this.contextRunner.withPropertyValues("spring.data.cassandra.config=" + configLocation).run((context) -> {
this.contextRunner.withPropertyValues("spring.cassandra.config=" + configLocation).run((context) -> {
assertThat(context).hasSingleBean(DriverConfigLoader.class);
DriverConfig driverConfig = context.getBean(DriverConfigLoader.class).getInitialConfig();
assertThat(driverConfig.getProfiles()).containsOnlyKeys("default", "first", "second");

View File

@@ -56,17 +56,15 @@ class CassandraAutoConfigurationWithPasswordAuthenticationIntegrationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(CassandraAutoConfiguration.class)).withPropertyValues(
"spring.data.cassandra.contact-points:" + cassandra.getHost() + ":"
+ cassandra.getFirstMappedPort(),
"spring.data.cassandra.local-datacenter=datacenter1",
"spring.data.cassandra.connection.connect-timeout=60s",
"spring.data.cassandra.connection.init-query-timeout=60s",
"spring.data.cassandra.request.timeout=60s");
"spring.cassandra.contact-points:" + cassandra.getHost() + ":" + cassandra.getFirstMappedPort(),
"spring.cassandra.local-datacenter=datacenter1", "spring.cassandra.connection.connect-timeout=60s",
"spring.cassandra.connection.init-query-timeout=60s", "spring.cassandra.request.timeout=60s");
@Test
void authenticationWithValidUsernameAndPassword() {
this.contextRunner.withPropertyValues("spring.data.cassandra.username=cassandra",
"spring.data.cassandra.password=cassandra").run((context) -> {
this.contextRunner
.withPropertyValues("spring.cassandra.username=cassandra", "spring.cassandra.password=cassandra")
.run((context) -> {
SimpleStatement select = SimpleStatement.newInstance("SELECT release_version FROM system.local")
.setConsistencyLevel(ConsistencyLevel.LOCAL_ONE);
assertThat(context.getBean(CqlSession.class).execute(select).one()).isNotNull();
@@ -76,8 +74,8 @@ class CassandraAutoConfigurationWithPasswordAuthenticationIntegrationTests {
@Test
void authenticationWithInvalidCredentials() {
this.contextRunner
.withPropertyValues("spring.data.cassandra.username=not-a-user",
"spring.data.cassandra.password=invalid-password")
.withPropertyValues("spring.cassandra.username=not-a-user",
"spring.cassandra.password=invalid-password")
.run((context) -> assertThatThrownBy(() -> context.getBean(CqlSession.class))
.hasMessageContaining("Authentication error"));
}

View File

@@ -40,21 +40,21 @@ class CassandraPropertiesTests {
@Test
void defaultValuesInManualMetadataAreConsistent() {
OptionsMap driverDefaults = OptionsMap.driverDefaults();
// spring.data.cassandra.connection.connect-timeout
// spring.cassandra.connection.connect-timeout
assertThat(driverDefaults.get(TypedDriverOption.CONNECTION_CONNECT_TIMEOUT)).isEqualTo(Duration.ofSeconds(5));
// spring.data.cassandra.connection.init-query-timeout
// spring.cassandra.connection.init-query-timeout
assertThat(driverDefaults.get(TypedDriverOption.CONNECTION_INIT_QUERY_TIMEOUT))
.isEqualTo(Duration.ofSeconds(5));
// spring.data.cassandra.request.timeout
// spring.cassandra.request.timeout
assertThat(driverDefaults.get(TypedDriverOption.REQUEST_TIMEOUT)).isEqualTo(Duration.ofSeconds(2));
// spring.data.cassandra.request.page-size
// spring.cassandra.request.page-size
assertThat(driverDefaults.get(TypedDriverOption.REQUEST_PAGE_SIZE)).isEqualTo(5000);
// spring.data.cassandra.request.throttler.type
// spring.cassandra.request.throttler.type
assertThat(driverDefaults.get(TypedDriverOption.REQUEST_THROTTLER_CLASS))
.isEqualTo("PassThroughRequestThrottler"); // "none"
// spring.data.cassandra.pool.heartbeat-interval
// spring.cassandra.pool.heartbeat-interval
assertThat(driverDefaults.get(TypedDriverOption.HEARTBEAT_INTERVAL)).isEqualTo(Duration.ofSeconds(30));
// spring.data.cassandra.pool.idle-timeout
// spring.cassandra.pool.idle-timeout
assertThat(driverDefaults.get(TypedDriverOption.HEARTBEAT_TIMEOUT)).isEqualTo(Duration.ofSeconds(5));
}

View File

@@ -52,12 +52,9 @@ class CassandraDataAutoConfigurationIntegrationTests {
.withConfiguration(
AutoConfigurations.of(CassandraAutoConfiguration.class, CassandraDataAutoConfiguration.class))
.withPropertyValues(
"spring.data.cassandra.contact-points:" + cassandra.getHost() + ":"
+ cassandra.getFirstMappedPort(),
"spring.data.cassandra.local-datacenter=datacenter1",
"spring.data.cassandra.connection.connect-timeout=60s",
"spring.data.cassandra.connection.init-query-timeout=60s",
"spring.data.cassandra.request.timeout=60s")
"spring.cassandra.contact-points:" + cassandra.getHost() + ":" + cassandra.getFirstMappedPort(),
"spring.cassandra.local-datacenter=datacenter1", "spring.cassandra.connection.connect-timeout=60s",
"spring.cassandra.connection.init-query-timeout=60s", "spring.cassandra.request.timeout=60s")
.withInitializer((context) -> AutoConfigurationPackages.register((BeanDefinitionRegistry) context,
City.class.getPackage().getName()));
@@ -70,7 +67,7 @@ class CassandraDataAutoConfigurationIntegrationTests {
@Test
void hasRecreateSchemaActionSet() {
this.contextRunner.withUserConfiguration(KeyspaceTestConfiguration.class)
.withPropertyValues("spring.data.cassandra.schemaAction=recreate_drop_unused")
.withPropertyValues("spring.cassandra.schemaAction=recreate_drop_unused")
.run((context) -> assertThat(context.getBean(SessionFactoryFactoryBean.class))
.hasFieldOrPropertyWithValue("schemaAction", SchemaAction.RECREATE_DROP_UNUSED));
}

View File

@@ -110,7 +110,7 @@ class CassandraDataAutoConfigurationTests {
void load(Class<?>... config) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
TestPropertyValues.of("spring.data.cassandra.keyspaceName:boot_test").applyTo(ctx);
TestPropertyValues.of("spring.cassandra.keyspaceName:boot_test").applyTo(ctx);
if (!ObjectUtils.isEmpty(config)) {
ctx.register(config);
}

View File

@@ -54,13 +54,13 @@ class CassandraReactiveDataAutoConfigurationTests {
@Test
void templateExists() {
load("spring.data.cassandra.keyspaceName:boot_test");
load("spring.cassandra.keyspaceName:boot_test");
assertThat(this.context.getBeanNamesForType(ReactiveCassandraTemplate.class)).hasSize(1);
}
@Test
void entityScanShouldSetManagedTypes() {
load(EntityScanConfig.class, "spring.data.cassandra.keyspaceName:boot_test");
load(EntityScanConfig.class, "spring.cassandra.keyspaceName:boot_test");
CassandraMappingContext mappingContext = this.context.getBean(CassandraMappingContext.class);
ManagedTypes managedTypes = (ManagedTypes) ReflectionTestUtils.getField(mappingContext, "managedTypes");
assertThat(managedTypes.toList()).containsOnly(City.class);
@@ -68,7 +68,7 @@ class CassandraReactiveDataAutoConfigurationTests {
@Test
void userTypeResolverShouldBeSet() {
load("spring.data.cassandra.keyspaceName:boot_test");
load("spring.cassandra.keyspaceName:boot_test");
CassandraConverter cassandraConverter = this.context.getBean(CassandraConverter.class);
assertThat(cassandraConverter).extracting("userTypeResolver").isInstanceOf(SimpleUserTypeResolver.class);
}

View File

@@ -79,14 +79,14 @@ class CassandraRepositoriesAutoConfigurationTests {
@Test
void enablingReactiveRepositoriesDisablesImperativeRepositories() {
this.contextRunner.withUserConfiguration(DefaultConfiguration.class)
.withPropertyValues("spring.data.cassandra.repositories.type=reactive")
.withPropertyValues("spring.cassandra.repositories.type=reactive")
.run((context) -> assertThat(context).doesNotHaveBean(CityCassandraRepository.class));
}
@Test
void enablingNoRepositoriesDisablesImperativeRepositories() {
this.contextRunner.withUserConfiguration(DefaultConfiguration.class)
.withPropertyValues("spring.data.cassandra.repositories.type=none")
.withPropertyValues("spring.cassandra.repositories.type=none")
.run((context) -> assertThat(context).doesNotHaveBean(CityCassandraRepository.class));
}

View File

@@ -54,20 +54,21 @@ class RedisAutoConfigurationJedisTests {
@Test
void connectionFactoryIsNotCreatedWhenLettuceIsSelected() {
this.contextRunner.withPropertyValues("spring.redis.client-type=lettuce")
this.contextRunner.withPropertyValues("spring.data.redis.client-type=lettuce")
.run((context) -> assertThat(context).doesNotHaveBean(RedisConnectionFactory.class));
}
@Test
void testOverrideRedisConfiguration() {
this.contextRunner.withPropertyValues("spring.redis.host:foo", "spring.redis.database:1").run((context) -> {
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo");
assertThat(cf.getDatabase()).isEqualTo(1);
assertThat(getUserName(cf)).isNull();
assertThat(cf.getPassword()).isNull();
assertThat(cf.isUseSsl()).isFalse();
});
this.contextRunner.withPropertyValues("spring.data.redis.host:foo", "spring.data.redis.database:1")
.run((context) -> {
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo");
assertThat(cf.getDatabase()).isEqualTo(1);
assertThat(getUserName(cf)).isNull();
assertThat(cf.getPassword()).isNull();
assertThat(cf.isUseSsl()).isFalse();
});
}
@Test
@@ -80,9 +81,8 @@ class RedisAutoConfigurationJedisTests {
@Test
void testRedisUrlConfiguration() {
this.contextRunner
.withPropertyValues("spring.redis.host:foo", "spring.redis.url:redis://user:password@example:33")
.run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.host:foo",
"spring.data.redis.url:redis://user:password@example:33").run((context) -> {
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("example");
assertThat(cf.getPort()).isEqualTo(33);
@@ -94,10 +94,9 @@ class RedisAutoConfigurationJedisTests {
@Test
void testOverrideUrlRedisConfiguration() {
this.contextRunner
.withPropertyValues("spring.redis.host:foo", "spring.redis.password:xyz", "spring.redis.port:1000",
"spring.redis.ssl:false", "spring.redis.url:rediss://user:password@example:33")
.run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.host:foo", "spring.data.redis.password:xyz",
"spring.data.redis.port:1000", "spring.data.redis.ssl:false",
"spring.data.redis.url:rediss://user:password@example:33").run((context) -> {
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("example");
assertThat(cf.getPort()).isEqualTo(33);
@@ -109,7 +108,7 @@ class RedisAutoConfigurationJedisTests {
@Test
void testPasswordInUrlWithColon() {
this.contextRunner.withPropertyValues("spring.redis.url:redis://:pass:word@example:33").run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.url:redis://:pass:word@example:33").run((context) -> {
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("example");
assertThat(cf.getPort()).isEqualTo(33);
@@ -120,21 +119,22 @@ class RedisAutoConfigurationJedisTests {
@Test
void testPasswordInUrlStartsWithColon() {
this.contextRunner.withPropertyValues("spring.redis.url:redis://user::pass:word@example:33").run((context) -> {
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("example");
assertThat(cf.getPort()).isEqualTo(33);
assertThat(getUserName(cf)).isEqualTo("user");
assertThat(cf.getPassword()).isEqualTo(":pass:word");
});
this.contextRunner.withPropertyValues("spring.data.redis.url:redis://user::pass:word@example:33")
.run((context) -> {
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("example");
assertThat(cf.getPort()).isEqualTo(33);
assertThat(getUserName(cf)).isEqualTo("user");
assertThat(cf.getPassword()).isEqualTo(":pass:word");
});
}
@Test
void testRedisConfigurationWithPool() {
this.contextRunner.withPropertyValues("spring.redis.host:foo", "spring.redis.jedis.pool.min-idle:1",
"spring.redis.jedis.pool.max-idle:4", "spring.redis.jedis.pool.max-active:16",
"spring.redis.jedis.pool.max-wait:2000", "spring.redis.jedis.pool.time-between-eviction-runs:30000")
.run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.host:foo", "spring.data.redis.jedis.pool.min-idle:1",
"spring.data.redis.jedis.pool.max-idle:4", "spring.data.redis.jedis.pool.max-active:16",
"spring.data.redis.jedis.pool.max-wait:2000",
"spring.data.redis.jedis.pool.time-between-eviction-runs:30000").run((context) -> {
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo");
assertThat(cf.getPoolConfig().getMinIdle()).isEqualTo(1);
@@ -147,7 +147,8 @@ class RedisAutoConfigurationJedisTests {
@Test
void testRedisConfigurationDisabledPool() {
this.contextRunner.withPropertyValues("spring.redis.host:foo", "spring.redis.jedis.pool.enabled:false")
this.contextRunner
.withPropertyValues("spring.data.redis.host:foo", "spring.data.redis.jedis.pool.enabled:false")
.run((context) -> {
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo");
@@ -157,8 +158,8 @@ class RedisAutoConfigurationJedisTests {
@Test
void testRedisConfigurationWithTimeoutAndConnectTimeout() {
this.contextRunner.withPropertyValues("spring.redis.host:foo", "spring.redis.timeout:250",
"spring.redis.connect-timeout:1000").run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.host:foo", "spring.data.redis.timeout:250",
"spring.data.redis.connect-timeout:1000").run((context) -> {
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo");
assertThat(cf.getTimeout()).isEqualTo(250);
@@ -168,7 +169,7 @@ class RedisAutoConfigurationJedisTests {
@Test
void testRedisConfigurationWithDefaultTimeouts() {
this.contextRunner.withPropertyValues("spring.redis.host:foo").run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.host:foo").run((context) -> {
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo");
assertThat(cf.getTimeout()).isEqualTo(2000);
@@ -178,7 +179,7 @@ class RedisAutoConfigurationJedisTests {
@Test
void testRedisConfigurationWithClientName() {
this.contextRunner.withPropertyValues("spring.redis.host:foo", "spring.redis.client-name:spring-boot")
this.contextRunner.withPropertyValues("spring.data.redis.host:foo", "spring.data.redis.client-name:spring-boot")
.run((context) -> {
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo");
@@ -189,8 +190,8 @@ class RedisAutoConfigurationJedisTests {
@Test
void testRedisConfigurationWithSentinel() {
this.contextRunner
.withPropertyValues("spring.redis.sentinel.master:mymaster",
"spring.redis.sentinel.nodes:127.0.0.1:26379,127.0.0.1:26380")
.withPropertyValues("spring.data.redis.sentinel.master:mymaster",
"spring.data.redis.sentinel.nodes:127.0.0.1:26379,127.0.0.1:26380")
.withUserConfiguration(JedisConnectionFactoryCaptorConfiguration.class)
.run((context) -> assertThat(JedisConnectionFactoryCaptor.connectionFactory.isRedisSentinelAware())
.isTrue());
@@ -198,8 +199,10 @@ class RedisAutoConfigurationJedisTests {
@Test
void testRedisConfigurationWithSentinelAndAuthentication() {
this.contextRunner.withPropertyValues("spring.redis.username=user", "spring.redis.password=password",
"spring.redis.sentinel.master:mymaster", "spring.redis.sentinel.nodes:127.0.0.1:26379,127.0.0.1:26380")
this.contextRunner
.withPropertyValues("spring.data.redis.username=user", "spring.data.redis.password=password",
"spring.data.redis.sentinel.master:mymaster",
"spring.data.redis.sentinel.nodes:127.0.0.1:26379,127.0.0.1:26380")
.withUserConfiguration(JedisConnectionFactoryCaptorConfiguration.class).run((context) -> {
assertThat(JedisConnectionFactoryCaptor.connectionFactory.isRedisSentinelAware()).isTrue();
assertThat(getUserName(JedisConnectionFactoryCaptor.connectionFactory)).isEqualTo("user");
@@ -209,7 +212,7 @@ class RedisAutoConfigurationJedisTests {
@Test
void testRedisConfigurationWithCluster() {
this.contextRunner.withPropertyValues("spring.redis.cluster.nodes=127.0.0.1:27379,127.0.0.1:27380")
this.contextRunner.withPropertyValues("spring.data.redis.cluster.nodes=127.0.0.1:27379,127.0.0.1:27380")
.withUserConfiguration(JedisConnectionFactoryCaptorConfiguration.class)
.run((context) -> assertThat(JedisConnectionFactoryCaptor.connectionFactory.isRedisClusterAware())
.isTrue());

View File

@@ -39,7 +39,7 @@ class RedisAutoConfigurationLettuceWithoutCommonsPool2Tests {
@Test
void poolWithoutCommonsPool2IsDisabledByDefault() {
this.contextRunner.withPropertyValues("spring.redis.host:foo").run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.host:foo").run((context) -> {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo");
assertThat(cf.getClientConfiguration()).isNotInstanceOf(LettucePoolingClientConfiguration.class);

View File

@@ -90,8 +90,8 @@ class RedisAutoConfigurationTests {
@Test
void testOverrideRedisConfiguration() {
this.contextRunner.withPropertyValues("spring.redis.host:foo", "spring.redis.database:1",
"spring.redis.lettuce.shutdown-timeout:500").run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.host:foo", "spring.data.redis.database:1",
"spring.data.redis.lettuce.shutdown-timeout:500").run((context) -> {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo");
assertThat(cf.getDatabase()).isEqualTo(1);
@@ -122,9 +122,8 @@ class RedisAutoConfigurationTests {
@Test
void testRedisUrlConfiguration() {
this.contextRunner
.withPropertyValues("spring.redis.host:foo", "spring.redis.url:redis://user:password@example:33")
.run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.host:foo",
"spring.data.redis.url:redis://user:password@example:33").run((context) -> {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("example");
assertThat(cf.getPort()).isEqualTo(33);
@@ -136,10 +135,9 @@ class RedisAutoConfigurationTests {
@Test
void testOverrideUrlRedisConfiguration() {
this.contextRunner
.withPropertyValues("spring.redis.host:foo", "spring.redis.password:xyz", "spring.redis.port:1000",
"spring.redis.ssl:false", "spring.redis.url:rediss://user:password@example:33")
.run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.host:foo", "spring.data.redis.password:xyz",
"spring.data.redis.port:1000", "spring.data.redis.ssl:false",
"spring.data.redis.url:rediss://user:password@example:33").run((context) -> {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("example");
assertThat(cf.getPort()).isEqualTo(33);
@@ -151,7 +149,7 @@ class RedisAutoConfigurationTests {
@Test
void testPasswordInUrlWithColon() {
this.contextRunner.withPropertyValues("spring.redis.url:redis://:pass:word@example:33").run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.url:redis://:pass:word@example:33").run((context) -> {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("example");
assertThat(cf.getPort()).isEqualTo(33);
@@ -162,19 +160,20 @@ class RedisAutoConfigurationTests {
@Test
void testPasswordInUrlStartsWithColon() {
this.contextRunner.withPropertyValues("spring.redis.url:redis://user::pass:word@example:33").run((context) -> {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("example");
assertThat(cf.getPort()).isEqualTo(33);
assertThat(getUserName(cf)).isEqualTo("user");
assertThat(cf.getPassword()).isEqualTo(":pass:word");
});
this.contextRunner.withPropertyValues("spring.data.redis.url:redis://user::pass:word@example:33")
.run((context) -> {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("example");
assertThat(cf.getPort()).isEqualTo(33);
assertThat(getUserName(cf)).isEqualTo("user");
assertThat(cf.getPassword()).isEqualTo(":pass:word");
});
}
@Test
void testRedisConfigurationUsePoolByDefault() {
Pool defaultPool = new RedisProperties().getLettuce().getPool();
this.contextRunner.withPropertyValues("spring.redis.host:foo").run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.host:foo").run((context) -> {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo");
GenericObjectPoolConfig<?> poolConfig = getPoolingClientConfiguration(cf).getPoolConfig();
@@ -187,10 +186,11 @@ class RedisAutoConfigurationTests {
@Test
void testRedisConfigurationWithCustomPoolSettings() {
this.contextRunner.withPropertyValues("spring.redis.host:foo", "spring.redis.lettuce.pool.min-idle:1",
"spring.redis.lettuce.pool.max-idle:4", "spring.redis.lettuce.pool.max-active:16",
"spring.redis.lettuce.pool.max-wait:2000", "spring.redis.lettuce.pool.time-between-eviction-runs:30000",
"spring.redis.lettuce.shutdown-timeout:1000").run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.host:foo", "spring.data.redis.lettuce.pool.min-idle:1",
"spring.data.redis.lettuce.pool.max-idle:4", "spring.data.redis.lettuce.pool.max-active:16",
"spring.data.redis.lettuce.pool.max-wait:2000",
"spring.data.redis.lettuce.pool.time-between-eviction-runs:30000",
"spring.data.redis.lettuce.shutdown-timeout:1000").run((context) -> {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo");
GenericObjectPoolConfig<?> poolConfig = getPoolingClientConfiguration(cf).getPoolConfig();
@@ -205,7 +205,8 @@ class RedisAutoConfigurationTests {
@Test
void testRedisConfigurationDisabledPool() {
this.contextRunner.withPropertyValues("spring.redis.host:foo", "spring.redis.lettuce.pool.enabled:false")
this.contextRunner
.withPropertyValues("spring.data.redis.host:foo", "spring.data.redis.lettuce.pool.enabled:false")
.run((context) -> {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo");
@@ -215,8 +216,8 @@ class RedisAutoConfigurationTests {
@Test
void testRedisConfigurationWithTimeoutAndConnectTimeout() {
this.contextRunner.withPropertyValues("spring.redis.host:foo", "spring.redis.timeout:250",
"spring.redis.connect-timeout:1000").run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.host:foo", "spring.data.redis.timeout:250",
"spring.data.redis.connect-timeout:1000").run((context) -> {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo");
assertThat(cf.getTimeout()).isEqualTo(250);
@@ -227,7 +228,7 @@ class RedisAutoConfigurationTests {
@Test
void testRedisConfigurationWithDefaultTimeouts() {
this.contextRunner.withPropertyValues("spring.redis.host:foo").run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.host:foo").run((context) -> {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo");
assertThat(cf.getTimeout()).isEqualTo(60000);
@@ -246,7 +247,7 @@ class RedisAutoConfigurationTests {
@Test
void testRedisConfigurationWithClientName() {
this.contextRunner.withPropertyValues("spring.redis.host:foo", "spring.redis.client-name:spring-boot")
this.contextRunner.withPropertyValues("spring.data.redis.host:foo", "spring.data.redis.client-name:spring-boot")
.run((context) -> {
LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
assertThat(cf.getHostName()).isEqualTo("foo");
@@ -256,7 +257,7 @@ class RedisAutoConfigurationTests {
@Test
void connectionFactoryWithJedisClientType() {
this.contextRunner.withPropertyValues("spring.redis.client-type:jedis").run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.client-type:jedis").run((context) -> {
assertThat(context).hasSingleBean(RedisConnectionFactory.class);
assertThat(context.getBean(RedisConnectionFactory.class)).isInstanceOf(JedisConnectionFactory.class);
});
@@ -264,7 +265,7 @@ class RedisAutoConfigurationTests {
@Test
void connectionFactoryWithLettuceClientType() {
this.contextRunner.withPropertyValues("spring.redis.client-type:lettuce").run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.client-type:lettuce").run((context) -> {
assertThat(context).hasSingleBean(RedisConnectionFactory.class);
assertThat(context.getBean(RedisConnectionFactory.class)).isInstanceOf(LettuceConnectionFactory.class);
});
@@ -274,16 +275,18 @@ class RedisAutoConfigurationTests {
void testRedisConfigurationWithSentinel() {
List<String> sentinels = Arrays.asList("127.0.0.1:26379", "127.0.0.1:26380");
this.contextRunner
.withPropertyValues("spring.redis.sentinel.master:mymaster",
"spring.redis.sentinel.nodes:" + StringUtils.collectionToCommaDelimitedString(sentinels))
.withPropertyValues("spring.data.redis.sentinel.master:mymaster",
"spring.data.redis.sentinel.nodes:" + StringUtils.collectionToCommaDelimitedString(sentinels))
.run((context) -> assertThat(context.getBean(LettuceConnectionFactory.class).isRedisSentinelAware())
.isTrue());
}
@Test
void testRedisConfigurationWithSentinelAndDatabase() {
this.contextRunner.withPropertyValues("spring.redis.database:1", "spring.redis.sentinel.master:mymaster",
"spring.redis.sentinel.nodes:127.0.0.1:26379, 127.0.0.1:26380").run((context) -> {
this.contextRunner
.withPropertyValues("spring.data.redis.database:1", "spring.data.redis.sentinel.master:mymaster",
"spring.data.redis.sentinel.nodes:127.0.0.1:26379, 127.0.0.1:26380")
.run((context) -> {
LettuceConnectionFactory connectionFactory = context.getBean(LettuceConnectionFactory.class);
assertThat(connectionFactory.getDatabase()).isEqualTo(1);
assertThat(connectionFactory.isRedisSentinelAware()).isTrue();
@@ -293,9 +296,9 @@ class RedisAutoConfigurationTests {
@Test
void testRedisConfigurationWithSentinelAndAuthentication() {
this.contextRunner
.withPropertyValues("spring.redis.username=user", "spring.redis.password=password",
"spring.redis.sentinel.master:mymaster",
"spring.redis.sentinel.nodes:127.0.0.1:26379, 127.0.0.1:26380")
.withPropertyValues("spring.data.redis.username=user", "spring.data.redis.password=password",
"spring.data.redis.sentinel.master:mymaster",
"spring.data.redis.sentinel.nodes:127.0.0.1:26379, 127.0.0.1:26380")
.run(assertSentinelConfiguration("user", "password", (sentinelConfiguration) -> {
assertThat(sentinelConfiguration.getSentinelPassword().isPresent()).isFalse();
Set<RedisNode> sentinels = sentinelConfiguration.getSentinels();
@@ -307,9 +310,9 @@ class RedisAutoConfigurationTests {
@Test
void testRedisConfigurationWithSentinelPasswordAndDataNodePassword() {
this.contextRunner
.withPropertyValues("spring.redis.password=password", "spring.redis.sentinel.password=secret",
"spring.redis.sentinel.master:mymaster",
"spring.redis.sentinel.nodes:127.0.0.1:26379, 127.0.0.1:26380")
.withPropertyValues("spring.data.redis.password=password", "spring.data.redis.sentinel.password=secret",
"spring.data.redis.sentinel.master:mymaster",
"spring.data.redis.sentinel.nodes:127.0.0.1:26379, 127.0.0.1:26380")
.run(assertSentinelConfiguration(null, "password", (sentinelConfiguration) -> {
assertThat(sentinelConfiguration.getSentinelUsername()).isNull();
assertThat(new String(sentinelConfiguration.getSentinelPassword().get())).isEqualTo("secret");
@@ -322,10 +325,10 @@ class RedisAutoConfigurationTests {
@Test
void testRedisConfigurationWithSentinelAuthenticationAndDataNodeAuthentication() {
this.contextRunner
.withPropertyValues("spring.redis.username=username", "spring.redis.password=password",
"spring.redis.sentinel.username=sentinel", "spring.redis.sentinel.password=secret",
"spring.redis.sentinel.master:mymaster",
"spring.redis.sentinel.nodes:127.0.0.1:26379, 127.0.0.1:26380")
.withPropertyValues("spring.data.redis.username=username", "spring.data.redis.password=password",
"spring.data.redis.sentinel.username=sentinel", "spring.data.redis.sentinel.password=secret",
"spring.data.redis.sentinel.master:mymaster",
"spring.data.redis.sentinel.nodes:127.0.0.1:26379, 127.0.0.1:26380")
.run(assertSentinelConfiguration("username", "password", (sentinelConfiguration) -> {
assertThat(sentinelConfiguration.getSentinelUsername()).isEqualTo("sentinel");
assertThat(new String(sentinelConfiguration.getSentinelPassword().get())).isEqualTo("secret");
@@ -347,9 +350,8 @@ class RedisAutoConfigurationTests {
@Test
void testRedisSentinelUrlConfiguration() {
this.contextRunner
.withPropertyValues(
"spring.redis.url=redis-sentinel://username:password@127.0.0.1:26379,127.0.0.1:26380/mymaster")
this.contextRunner.withPropertyValues(
"spring.data.redis.url=redis-sentinel://username:password@127.0.0.1:26379,127.0.0.1:26380/mymaster")
.run((context) -> assertThatIllegalStateException()
.isThrownBy(() -> context.getBean(LettuceConnectionFactory.class))
.withRootCauseInstanceOf(RedisUrlSyntaxException.class).havingRootCause().withMessageContaining(
@@ -359,8 +361,8 @@ class RedisAutoConfigurationTests {
@Test
void testRedisConfigurationWithCluster() {
List<String> clusterNodes = Arrays.asList("127.0.0.1:27379", "127.0.0.1:27380");
this.contextRunner.withPropertyValues("spring.redis.cluster.nodes[0]:" + clusterNodes.get(0),
"spring.redis.cluster.nodes[1]:" + clusterNodes.get(1)).run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.cluster.nodes[0]:" + clusterNodes.get(0),
"spring.data.redis.cluster.nodes[1]:" + clusterNodes.get(1)).run((context) -> {
RedisClusterConfiguration clusterConfiguration = context.getBean(LettuceConnectionFactory.class)
.getClusterConfiguration();
assertThat(clusterConfiguration.getClusterNodes()).hasSize(2);
@@ -374,9 +376,9 @@ class RedisAutoConfigurationTests {
@Test
void testRedisConfigurationWithClusterAndAuthentication() {
List<String> clusterNodes = Arrays.asList("127.0.0.1:27379", "127.0.0.1:27380");
this.contextRunner.withPropertyValues("spring.redis.username=user", "spring.redis.password=password",
"spring.redis.cluster.nodes[0]:" + clusterNodes.get(0),
"spring.redis.cluster.nodes[1]:" + clusterNodes.get(1)).run((context) -> {
this.contextRunner.withPropertyValues("spring.data.redis.username=user", "spring.data.redis.password=password",
"spring.data.redis.cluster.nodes[0]:" + clusterNodes.get(0),
"spring.data.redis.cluster.nodes[1]:" + clusterNodes.get(1)).run((context) -> {
LettuceConnectionFactory connectionFactory = context.getBean(LettuceConnectionFactory.class);
assertThat(getUserName(connectionFactory)).isEqualTo("user");
assertThat(connectionFactory.getPassword()).isEqualTo("password");
@@ -395,7 +397,7 @@ class RedisAutoConfigurationTests {
@Test
void testRedisConfigurationWithClusterCreateClusterClientOptions() {
this.contextRunner.withPropertyValues("spring.redis.cluster.nodes=127.0.0.1:27379,127.0.0.1:27380")
this.contextRunner.withPropertyValues("spring.data.redis.cluster.nodes=127.0.0.1:27379,127.0.0.1:27380")
.run(assertClientOptions(ClusterClientOptions.class, (options) -> {
assertThat(options.getTimeoutOptions().isApplyConnectionTimeout()).isTrue();
assertThat(options.getTimeoutOptions().isTimeoutCommands()).isTrue();
@@ -405,8 +407,8 @@ class RedisAutoConfigurationTests {
@Test
void testRedisConfigurationWithClusterRefreshPeriod() {
this.contextRunner
.withPropertyValues("spring.redis.cluster.nodes=127.0.0.1:27379,127.0.0.1:27380",
"spring.redis.lettuce.cluster.refresh.period=30s")
.withPropertyValues("spring.data.redis.cluster.nodes=127.0.0.1:27379,127.0.0.1:27380",
"spring.data.redis.lettuce.cluster.refresh.period=30s")
.run(assertClientOptions(ClusterClientOptions.class,
(options) -> assertThat(options.getTopologyRefreshOptions().getRefreshPeriod())
.hasSeconds(30)));
@@ -415,8 +417,8 @@ class RedisAutoConfigurationTests {
@Test
void testRedisConfigurationWithClusterAdaptiveRefresh() {
this.contextRunner
.withPropertyValues("spring.redis.cluster.nodes=127.0.0.1:27379,127.0.0.1:27380",
"spring.redis.lettuce.cluster.refresh.adaptive=true")
.withPropertyValues("spring.data.redis.cluster.nodes=127.0.0.1:27379,127.0.0.1:27380",
"spring.data.redis.lettuce.cluster.refresh.adaptive=true")
.run(assertClientOptions(ClusterClientOptions.class,
(options) -> assertThat(options.getTopologyRefreshOptions().getAdaptiveRefreshTriggers())
.isEqualTo(EnumSet.allOf(RefreshTrigger.class))));
@@ -424,15 +426,15 @@ class RedisAutoConfigurationTests {
@Test
void testRedisConfigurationWithClusterRefreshPeriodHasNoEffectWithNonClusteredConfiguration() {
this.contextRunner.withPropertyValues("spring.redis.cluster.refresh.period=30s").run(assertClientOptions(
this.contextRunner.withPropertyValues("spring.data.redis.cluster.refresh.period=30s").run(assertClientOptions(
ClientOptions.class, (options) -> assertThat(options.getClass()).isEqualTo(ClientOptions.class)));
}
@Test
void testRedisConfigurationWithClusterDynamicRefreshSourcesEnabled() {
this.contextRunner
.withPropertyValues("spring.redis.cluster.nodes=127.0.0.1:27379,127.0.0.1:27380",
"spring.redis.lettuce.cluster.refresh.dynamic-refresh-sources=true")
.withPropertyValues("spring.data.redis.cluster.nodes=127.0.0.1:27379,127.0.0.1:27380",
"spring.data.redis.lettuce.cluster.refresh.dynamic-refresh-sources=true")
.run(assertClientOptions(ClusterClientOptions.class,
(options) -> assertThat(options.getTopologyRefreshOptions().useDynamicRefreshSources())
.isTrue()));
@@ -441,8 +443,8 @@ class RedisAutoConfigurationTests {
@Test
void testRedisConfigurationWithClusterDynamicRefreshSourcesDisabled() {
this.contextRunner
.withPropertyValues("spring.redis.cluster.nodes=127.0.0.1:27379,127.0.0.1:27380",
"spring.redis.lettuce.cluster.refresh.dynamic-refresh-sources=false")
.withPropertyValues("spring.data.redis.cluster.nodes=127.0.0.1:27379,127.0.0.1:27380",
"spring.data.redis.lettuce.cluster.refresh.dynamic-refresh-sources=false")
.run(assertClientOptions(ClusterClientOptions.class,
(options) -> assertThat(options.getTopologyRefreshOptions().useDynamicRefreshSources())
.isFalse()));
@@ -451,8 +453,8 @@ class RedisAutoConfigurationTests {
@Test
void testRedisConfigurationWithClusterDynamicSourcesUnspecifiedUsesDefault() {
this.contextRunner
.withPropertyValues("spring.redis.cluster.nodes=127.0.0.1:27379,127.0.0.1:27380",
"spring.redis.lettuce.cluster.refresh.dynamic-sources=")
.withPropertyValues("spring.data.redis.cluster.nodes=127.0.0.1:27379,127.0.0.1:27380",
"spring.data.redis.lettuce.cluster.refresh.dynamic-sources=")
.run(assertClientOptions(ClusterClientOptions.class,
(options) -> assertThat(options.getTopologyRefreshOptions().useDynamicRefreshSources())
.isEqualTo(ClusterTopologyRefreshOptions.DEFAULT_DYNAMIC_REFRESH_SOURCES)));

View File

@@ -54,7 +54,8 @@ class RedisRepositoriesAutoConfigurationTests {
@BeforeEach
void setUp() {
TestPropertyValues.of("spring.redis.host=" + redis.getHost(), "spring.redis.port=" + redis.getFirstMappedPort())
TestPropertyValues
.of("spring.data.redis.host=" + redis.getHost(), "spring.data.redis.port=" + redis.getFirstMappedPort())
.applyTo(this.context.getEnvironment());
}

View File

@@ -34,7 +34,7 @@ class RedisUrlSyntaxFailureAnalyzerTests {
RedisUrlSyntaxException exception = new RedisUrlSyntaxException("redis://invalid");
FailureAnalysis analysis = new RedisUrlSyntaxFailureAnalyzer().analyze(exception);
assertThat(analysis.getDescription()).contains("The URL 'redis://invalid' is not valid");
assertThat(analysis.getAction()).contains("Review the value of the property 'spring.redis.url'");
assertThat(analysis.getAction()).contains("Review the value of the property 'spring.data.redis.url'");
}
@Test
@@ -54,7 +54,7 @@ class RedisUrlSyntaxFailureAnalyzerTests {
assertThat(analysis.getDescription()).contains(
"The URL 'redis-sentinel://username:password@127.0.0.1:26379,127.0.0.1:26380/mymaster' is not valid")
.contains("The scheme 'redis-sentinel' is not supported");
assertThat(analysis.getAction()).contains("Use spring.redis.sentinel properties");
assertThat(analysis.getAction()).contains("Use spring.data.redis.sentinel properties");
}
@Test

View File

@@ -102,7 +102,7 @@ class ReactiveSessionAutoConfigurationRedisTests extends AbstractSessionAutoConf
@Test
void sessionCookieConfigurationIsAppliedToAutoConfiguredWebSessionIdResolver() {
this.contextRunner.withUserConfiguration(Config.class).withPropertyValues(
"spring.redis.host=" + redis.getHost(), "spring.redis.port=" + redis.getFirstMappedPort(),
"spring.data.redis.host=" + redis.getHost(), "spring.data.redis.port=" + redis.getFirstMappedPort(),
"server.reactive.session.cookie.name:JSESSIONID", "server.reactive.session.cookie.domain:.example.com",
"server.reactive.session.cookie.path:/example", "server.reactive.session.cookie.max-age:60",
"server.reactive.session.cookie.http-only:false", "server.reactive.session.cookie.secure:false",

View File

@@ -67,8 +67,8 @@ class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfiguratio
@Test
void defaultConfig() {
this.contextRunner
.withPropertyValues("spring.redis.host=" + redis.getHost(),
"spring.redis.port=" + redis.getFirstMappedPort())
.withPropertyValues("spring.data.redis.host=" + redis.getHost(),
"spring.data.redis.port=" + redis.getFirstMappedPort())
.withConfiguration(AutoConfigurations.of(RedisAutoConfiguration.class))
.run(validateSpringSessionUsesRedis("spring:session:event:0:created:", FlushMode.ON_SAVE,
SaveMode.ON_SET_ATTRIBUTE, "0 * * * * *"));
@@ -77,8 +77,8 @@ class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfiguratio
@Test
void redisTakesPrecedenceMultipleImplementations() {
this.contextRunner.withConfiguration(AutoConfigurations.of(RedisAutoConfiguration.class))
.withPropertyValues("spring.redis.host=" + redis.getHost(),
"spring.redis.port=" + redis.getFirstMappedPort())
.withPropertyValues("spring.data.redis.host=" + redis.getHost(),
"spring.data.redis.port=" + redis.getFirstMappedPort())
.run(validateSpringSessionUsesRedis("spring:session:event:0:created:", FlushMode.ON_SAVE,
SaveMode.ON_SET_ATTRIBUTE, "0 * * * * *"));
}
@@ -86,8 +86,8 @@ class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfiguratio
@Test
void defaultConfigWithCustomTimeout() {
this.contextRunner
.withPropertyValues("spring.redis.host=" + redis.getHost(),
"spring.redis.port=" + redis.getFirstMappedPort(), "spring.session.timeout=1m")
.withPropertyValues("spring.data.redis.host=" + redis.getHost(),
"spring.data.redis.port=" + redis.getFirstMappedPort(), "spring.session.timeout=1m")
.withConfiguration(AutoConfigurations.of(RedisAutoConfiguration.class)).run((context) -> {
RedisIndexedSessionRepository repository = validateSessionRepository(context,
RedisIndexedSessionRepository.class);
@@ -100,8 +100,8 @@ class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfiguratio
this.contextRunner.withConfiguration(AutoConfigurations.of(RedisAutoConfiguration.class))
.withPropertyValues("spring.session.redis.namespace=foo", "spring.session.redis.flush-mode=immediate",
"spring.session.redis.save-mode=on-get-attribute",
"spring.session.redis.cleanup-cron=0 0 12 * * *", "spring.redis.host=" + redis.getHost(),
"spring.redis.port=" + redis.getFirstMappedPort())
"spring.session.redis.cleanup-cron=0 0 12 * * *", "spring.data.redis.host=" + redis.getHost(),
"spring.data.redis.port=" + redis.getFirstMappedPort())
.run(validateSpringSessionUsesRedis("foo:event:0:created:", FlushMode.IMMEDIATE,
SaveMode.ON_GET_ATTRIBUTE, "0 0 12 * * *"));
}
@@ -110,15 +110,16 @@ class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfiguratio
void redisSessionWithConfigureActionNone() {
this.contextRunner.withConfiguration(AutoConfigurations.of(RedisAutoConfiguration.class))
.withPropertyValues("spring.session.redis.configure-action=none",
"spring.redis.host=" + redis.getHost(), "spring.redis.port=" + redis.getFirstMappedPort())
"spring.data.redis.host=" + redis.getHost(),
"spring.data.redis.port=" + redis.getFirstMappedPort())
.run(validateStrategy(ConfigureRedisAction.NO_OP.getClass()));
}
@Test
void redisSessionWithDefaultConfigureActionNone() {
this.contextRunner.withConfiguration(AutoConfigurations.of(RedisAutoConfiguration.class))
.withPropertyValues("spring.redis.host=" + redis.getHost(),
"spring.redis.port=" + redis.getFirstMappedPort())
.withPropertyValues("spring.data.redis.host=" + redis.getHost(),
"spring.data.redis.port=" + redis.getFirstMappedPort())
.run(validateStrategy(ConfigureNotifyKeyspaceEventsAction.class,
entry("notify-keyspace-events", "gxE")));
}
@@ -127,8 +128,8 @@ class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfiguratio
void redisSessionWithCustomConfigureRedisActionBean() {
this.contextRunner.withConfiguration(AutoConfigurations.of(RedisAutoConfiguration.class))
.withUserConfiguration(MaxEntriesRedisAction.class)
.withPropertyValues("spring.redis.host=" + redis.getHost(),
"spring.redis.port=" + redis.getFirstMappedPort())
.withPropertyValues("spring.data.redis.host=" + redis.getHost(),
"spring.data.redis.port=" + redis.getFirstMappedPort())
.run(validateStrategy(MaxEntriesRedisAction.class, entry("set-max-intset-entries", "1024")));
}