Search in sources :

Example 21 with LettuceConnectionFactory

use of org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory in project spring-boot by spring-projects.

the class RedisAutoConfigurationTests method testRedisConfigurationWithTimeoutAndConnectTimeout.

@Test
void testRedisConfigurationWithTimeoutAndConnectTimeout() {
    this.contextRunner.withPropertyValues("spring.redis.host:foo", "spring.redis.timeout:250", "spring.redis.connect-timeout:1000").run((context) -> {
        LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
        assertThat(cf.getHostName()).isEqualTo("foo");
        assertThat(cf.getTimeout()).isEqualTo(250);
        assertThat(cf.getClientConfiguration().getClientOptions().get().getSocketOptions().getConnectTimeout().toMillis()).isEqualTo(1000);
    });
}
Also used : LettuceConnectionFactory(org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory) Test(org.junit.jupiter.api.Test)

Example 22 with LettuceConnectionFactory

use of org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory in project spring-boot by spring-projects.

the class RedisAutoConfigurationTests method testPasswordInUrlWithColon.

@Test
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(getUserName(cf)).isEqualTo("");
        assertThat(cf.getPassword()).isEqualTo("pass:word");
    });
}
Also used : LettuceConnectionFactory(org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory) Test(org.junit.jupiter.api.Test)

Example 23 with LettuceConnectionFactory

use of org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory in project spring-boot by spring-projects.

the class RedisAutoConfigurationTests method testRedisUrlConfiguration.

@Test
void testRedisUrlConfiguration() {
    this.contextRunner.withPropertyValues("spring.redis.host:foo", "spring.redis.url:redis://user:password@example:33").run((context) -> {
        LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
        assertThat(cf.getHostName()).isEqualTo("example");
        assertThat(cf.getPort()).isEqualTo(33);
        assertThat(getUserName(cf)).isEqualTo("user");
        assertThat(cf.getPassword()).isEqualTo("password");
        assertThat(cf.isUseSsl()).isFalse();
    });
}
Also used : LettuceConnectionFactory(org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory) Test(org.junit.jupiter.api.Test)

Example 24 with LettuceConnectionFactory

use of org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory in project spring-boot by spring-projects.

the class RedisAutoConfigurationTests method testCustomizeRedisConfiguration.

@Test
void testCustomizeRedisConfiguration() {
    this.contextRunner.withUserConfiguration(CustomConfiguration.class).run((context) -> {
        LettuceConnectionFactory cf = context.getBean(LettuceConnectionFactory.class);
        assertThat(cf.isUseSsl()).isTrue();
    });
}
Also used : LettuceConnectionFactory(org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory) Test(org.junit.jupiter.api.Test)

Example 25 with LettuceConnectionFactory

use of org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory in project jetcache by alibaba.

the class RedisSpringDataCacheTest method lettuceTest.

@Test
public void lettuceTest() throws Exception {
    LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(new RedisStandaloneConfiguration("127.0.0.1", 6379));
    connectionFactory.afterPropertiesSet();
    doTest(connectionFactory);
}
Also used : LettuceConnectionFactory(org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory) RedisStandaloneConfiguration(org.springframework.data.redis.connection.RedisStandaloneConfiguration) LoadingCacheTest(com.alicp.jetcache.LoadingCacheTest) RefreshCacheTest(com.alicp.jetcache.RefreshCacheTest) AbstractExternalCacheTest(com.alicp.jetcache.test.external.AbstractExternalCacheTest) Test(org.junit.Test)

Aggregations

LettuceConnectionFactory (org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory)27 Test (org.junit.jupiter.api.Test)16 JedisConnectionFactory (org.springframework.data.redis.connection.jedis.JedisConnectionFactory)5 Bean (org.springframework.context.annotation.Bean)4 RedisStandaloneConfiguration (org.springframework.data.redis.connection.RedisStandaloneConfiguration)3 Test (org.junit.Test)2 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)2 ServiceConnectorCreationException (org.springframework.cloud.service.ServiceConnectorCreationException)2 LettuceClientConfiguration (org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration)2 LettuceClientConfigurationBuilder (org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceClientConfigurationBuilder)2 LoadingCacheTest (com.alicp.jetcache.LoadingCacheTest)1 RefreshCacheTest (com.alicp.jetcache.RefreshCacheTest)1 AbstractExternalCacheTest (com.alicp.jetcache.test.external.AbstractExternalCacheTest)1 GenericObjectPoolConfig (org.apache.commons.pool2.impl.GenericObjectPoolConfig)1 ConfigurationPropertyFactoryBean (org.hisp.dhis.external.conf.ConfigurationPropertyFactoryBean)1 Pool (org.springframework.boot.autoconfigure.data.redis.RedisProperties.Pool)1 Cloud (org.springframework.cloud.Cloud)1 CloudFactory (org.springframework.cloud.CloudFactory)1 PooledServiceConnectorConfig (org.springframework.cloud.service.PooledServiceConnectorConfig)1 Profile (org.springframework.context.annotation.Profile)1