parent
7b24941d67
commit
1f80079c49
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue