Search in sources :

Example 11 with RedisConnectionConfig

use of com.alibaba.csp.sentinel.datasource.redis.config.RedisConnectionConfig in project Sentinel by alibaba.

the class RedisConnectionConfigTest method testRedisDefaultPropertySuccess.

@Test
public void testRedisDefaultPropertySuccess() {
    String host = "localhost";
    RedisConnectionConfig redisConnectionConfig = RedisConnectionConfig.Builder.redis(host).build();
    Assert.assertEquals(host, redisConnectionConfig.getHost());
    Assert.assertEquals(RedisConnectionConfig.DEFAULT_REDIS_PORT, redisConnectionConfig.getPort());
    Assert.assertEquals(RedisConnectionConfig.DEFAULT_TIMEOUT_MILLISECONDS, redisConnectionConfig.getTimeout());
}
Also used : RedisConnectionConfig(com.alibaba.csp.sentinel.datasource.redis.config.RedisConnectionConfig) Test(org.junit.Test)

Example 12 with RedisConnectionConfig

use of com.alibaba.csp.sentinel.datasource.redis.config.RedisConnectionConfig in project Sentinel by alibaba.

the class RedisConnectionConfigTest method testRedisClusterMoreThanOneDuplicateServerSuccess.

@Test
public void testRedisClusterMoreThanOneDuplicateServerSuccess() {
    String host = "localhost";
    String host2 = "server2";
    int port2 = 1879;
    RedisConnectionConfig redisConnectionConfig = RedisConnectionConfig.Builder.redisCluster(host).withRedisCluster(host2, port2).withRedisCluster(host2, port2).withPassword("211233").build();
    Assert.assertNull(redisConnectionConfig.getHost());
    Assert.assertEquals(3, redisConnectionConfig.getRedisClusters().size());
}
Also used : RedisConnectionConfig(com.alibaba.csp.sentinel.datasource.redis.config.RedisConnectionConfig) Test(org.junit.Test)

Example 13 with RedisConnectionConfig

use of com.alibaba.csp.sentinel.datasource.redis.config.RedisConnectionConfig in project Sentinel by alibaba.

the class RedisConnectionConfigTest method testRedisSentinelDefaultPortSuccess.

@Test
public void testRedisSentinelDefaultPortSuccess() {
    String host = "localhost";
    RedisConnectionConfig redisConnectionConfig = RedisConnectionConfig.Builder.redisSentinel(host).withPassword("211233").build();
    Assert.assertNull(redisConnectionConfig.getHost());
    Assert.assertEquals(1, redisConnectionConfig.getRedisSentinels().size());
    Assert.assertEquals(RedisConnectionConfig.DEFAULT_SENTINEL_PORT, redisConnectionConfig.getRedisSentinels().get(0).getPort());
}
Also used : RedisConnectionConfig(com.alibaba.csp.sentinel.datasource.redis.config.RedisConnectionConfig) Test(org.junit.Test)

Example 14 with RedisConnectionConfig

use of com.alibaba.csp.sentinel.datasource.redis.config.RedisConnectionConfig in project Sentinel by alibaba.

the class RedisConnectionConfigTest method testRedisSentinelMoreThanOneServerSuccess.

@Test
public void testRedisSentinelMoreThanOneServerSuccess() {
    String host = "localhost";
    String host2 = "server2";
    int port2 = 1879;
    RedisConnectionConfig redisConnectionConfig = RedisConnectionConfig.Builder.redisSentinel(host).withRedisSentinel(host2, port2).build();
    Assert.assertNull(redisConnectionConfig.getHost());
    Assert.assertEquals(2, redisConnectionConfig.getRedisSentinels().size());
}
Also used : RedisConnectionConfig(com.alibaba.csp.sentinel.datasource.redis.config.RedisConnectionConfig) Test(org.junit.Test)

Aggregations

RedisConnectionConfig (com.alibaba.csp.sentinel.datasource.redis.config.RedisConnectionConfig)14 Test (org.junit.Test)9 List (java.util.List)3 RedisURI (io.lettuce.core.RedisURI)2 FlowRule (com.alibaba.csp.sentinel.slots.block.flow.FlowRule)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1