Commit 6e01a96b authored by Stephane Nicoll's avatar Stephane Nicoll

Merge pull request #12556 from aturkovic:master

* pr/12556:
  Polish "Add Redis Sentinel database support"
  Add Redis Sentinel database support
parents 7b24941d 9cac45d5
......@@ -35,6 +35,7 @@ import org.springframework.util.StringUtils;
*
* @author Mark Paluch
* @author Stephane Nicoll
* @author Alen Turkovic
*/
abstract class RedisConnectionConfiguration {
......@@ -81,6 +82,7 @@ abstract class RedisConnectionConfiguration {
if (this.properties.getPassword() != null) {
config.setPassword(RedisPassword.of(this.properties.getPassword()));
}
config.setDatabase(this.properties.getDatabase());
return config;
}
return null;
......
......@@ -49,6 +49,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Marco Aust
* @author Mark Paluch
* @author Stephane Nicoll
* @author Alen Turkovic
*/
public class RedisAutoConfigurationTests {
......@@ -191,6 +192,20 @@ public class RedisAutoConfigurationTests {
.isTrue());
}
@Test
public 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) -> {
LettuceConnectionFactory connectionFactory = context
.getBean(LettuceConnectionFactory.class);
assertThat(connectionFactory.getDatabase()).isEqualTo(1);
assertThat(connectionFactory.isRedisSentinelAware()).isTrue();
});
}
@Test
public void testRedisConfigurationWithSentinelAndPassword() {
this.contextRunner
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment