Example usage for org.springframework.data.redis.connection.lettuce LettuceConnectionFactory getPassword

List of usage examples for org.springframework.data.redis.connection.lettuce LettuceConnectionFactory getPassword

Introduction

In this page you can find the example usage for org.springframework.data.redis.connection.lettuce LettuceConnectionFactory getPassword.

Prototype

@Nullable
public String getPassword() 

Source Link

Document

Returns the password used for authenticating with the Redis server.

Usage

From source file:org.springframework.boot.autoconfigure.data.redis.RedisAutoConfigurationTests.java

@Test
public void testOverrideRedisConfiguration() {
    this.contextRunner.withPropertyValues("spring.redis.host:foo", "spring.redis.database:1",
            "spring.redis.lettuce.shutdown-timeout:500").run((context) -> {
                LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
                assertThat(cf.getHostName()).isEqualTo("foo");
                assertThat(cf.getDatabase()).isEqualTo(1);
                assertThat(cf.getPassword()).isNull();
                assertThat(cf.isUseSsl()).isFalse();
                assertThat(cf.getShutdownTimeout()).isEqualTo(500);
            });/*from  w w w .j  a  va 2s.c  o m*/
}

From source file:org.springframework.boot.autoconfigure.data.redis.RedisAutoConfigurationTests.java

@Test
public void testRedisUrlConfiguration() {
    this.contextRunner
            .withPropertyValues("spring.redis.host:foo", "spring.redis.url:redis://user:password@example:33")
            .run((context) -> {/*  w  ww.  j a va  2s.  c  o m*/
                LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
                assertThat(cf.getHostName()).isEqualTo("example");
                assertThat(cf.getPort()).isEqualTo(33);
                assertThat(cf.getPassword()).isEqualTo("password");
                assertThat(cf.isUseSsl()).isFalse();
            });
}

From source file:org.springframework.boot.autoconfigure.data.redis.RedisAutoConfigurationTests.java

@Test
public 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) -> {/*from   ww  w.  ja v a  2 s. c  o m*/
                LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
                assertThat(cf.getHostName()).isEqualTo("example");
                assertThat(cf.getPort()).isEqualTo(33);
                assertThat(cf.getPassword()).isEqualTo("password");
                assertThat(cf.isUseSsl()).isTrue();
            });
}

From source file:org.springframework.boot.autoconfigure.data.redis.RedisAutoConfigurationTests.java

@Test
public void testPasswordInUrlWithColon() {
    this.contextRunner.withPropertyValues("spring.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);
        assertThat(cf.getPassword()).isEqualTo("pass:word");
    });//from  w ww  . j  ava2 s  .  com
}

From source file:org.springframework.boot.autoconfigure.data.redis.RedisAutoConfigurationTests.java

@Test
public void testPasswordInUrlStartsWithColon() {
    this.contextRunner.withPropertyValues("spring.redis.url:redis://user::pass:word@example:33")
            .run((context) -> {//w ww  .  j a va 2  s .  c o  m
                LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
                assertThat(cf.getHostName()).isEqualTo("example");
                assertThat(cf.getPort()).isEqualTo(33);
                assertThat(cf.getPassword()).isEqualTo(":pass:word");
            });
}

From source file:org.springframework.boot.autoconfigure.data.redis.RedisAutoConfigurationTests.java

@Test
public void testRedisConfigurationWithSentinelAndPassword() {
    this.contextRunner
            .withPropertyValues("spring.redis.password=password", "spring.redis.sentinel.master:mymaster",
                    "spring.redis.sentinel.nodes:127.0.0.1:26379,  127.0.0.1:26380")
            .run((context) -> {/*from ww  w . j  a  v  a  2  s  . c  o  m*/
                LettuceConnectionFactory connectionFactory = context.getBean(LettuceConnectionFactory.class);
                assertThat(connectionFactory.getPassword()).isEqualTo("password");
                Set<RedisNode> sentinels = connectionFactory.getSentinelConfiguration().getSentinels();
                assertThat(sentinels.stream().map(Object::toString).collect(Collectors.toSet()))
                        .contains("127.0.0.1:26379", "127.0.0.1:26380");
            });
}