Example usage for org.springframework.data.redis SettingsUtils standaloneConfiguration

List of usage examples for org.springframework.data.redis SettingsUtils standaloneConfiguration

Introduction

In this page you can find the example usage for org.springframework.data.redis SettingsUtils standaloneConfiguration.

Prototype

public static RedisStandaloneConfiguration standaloneConfiguration() 

Source Link

Document

Construct a new RedisStandaloneConfiguration initialized with test endpoint settings.

Usage

From source file:org.springframework.data.redis.connection.lettuce.LettuceConnectionFactoryTests.java

@Test // DATAREDIS-580, DATAREDIS-869
public void factoryUsesMasterReplicaConnections() {

    assumeThat(//from ww  w. j  ava  2 s  . co m
            String.format("No replicas connected to %s:%s.", SettingsUtils.getHost(), SettingsUtils.getPort()),
            connection.info("replication").getProperty("connected_slaves", "0").compareTo("0") > 0, is(true));

    LettuceClientConfiguration configuration = LettuceTestClientConfiguration.builder().readFrom(ReadFrom.SLAVE)
            .build();

    LettuceConnectionFactory factory = new LettuceConnectionFactory(SettingsUtils.standaloneConfiguration(),
            configuration);
    factory.afterPropertiesSet();

    RedisConnection connection = factory.getConnection();

    try {
        assertThat(connection.ping(), is(equalTo("PONG")));
        assertThat(connection.info().getProperty("role"), is(equalTo("slave")));
    } finally {
        connection.close();
    }

    factory.destroy();
}