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

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

Introduction

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

Prototype

public int getDatabase() 

Source Link

Document

Returns the index of the database.

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);
            });// ww  w  . j  a  v  a 2s.c  o  m
}

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

@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();
            });/*from ww  w  . j av  a2 s .co  m*/
}