use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-cloud-connectors by spring-cloud.
the class RedisConnectionFactoryXmlConfigTest method cloudRedisConnectionFactoryWithMinMaxPool.
@Test
public void cloudRedisConnectionFactoryWithMinMaxPool() {
ApplicationContext testContext = getTestApplicationContext("cloud-redis-with-config.xml", createService("my-service"));
RedisConnectionFactory connector = testContext.getBean("service-pool5-30-wait3000", getConnectorType());
RedisConnectionFactoryCloudConfigTestHelper.assertPoolProperties(connector, 30, 5, 3000);
}
use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-boot by spring-projects.
the class RedisHealthIndicatorTests method healthWhenClusterStateIsAbsentShouldBeUp.
@Test
void healthWhenClusterStateIsAbsentShouldBeUp() {
RedisConnectionFactory redisConnectionFactory = createClusterConnectionFactory(null);
RedisHealthIndicator healthIndicator = new RedisHealthIndicator(redisConnectionFactory);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("cluster_size")).isEqualTo(4L);
assertThat(health.getDetails().get("slots_up")).isEqualTo(4L);
assertThat(health.getDetails().get("slots_fail")).isEqualTo(0L);
then(redisConnectionFactory).should(atLeastOnce()).getConnection();
}
use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-boot by spring-projects.
the class RedisHealthIndicatorTests method createClusterConnectionFactory.
private RedisConnectionFactory createClusterConnectionFactory(String state) {
Properties clusterProperties = new Properties();
if (state != null) {
clusterProperties.setProperty("cluster_state", state);
}
clusterProperties.setProperty("cluster_size", "4");
boolean failure = "fail".equals(state);
clusterProperties.setProperty("cluster_slots_ok", failure ? "3" : "4");
clusterProperties.setProperty("cluster_slots_fail", failure ? "1" : "0");
List<RedisClusterNode> redisMasterNodes = Arrays.asList(new RedisClusterNode("127.0.0.1", 7001), new RedisClusterNode("127.0.0.2", 7001));
RedisClusterConnection redisConnection = mock(RedisClusterConnection.class);
given(redisConnection.clusterGetNodes()).willReturn(redisMasterNodes);
given(redisConnection.clusterGetClusterInfo()).willReturn(new ClusterInfo(clusterProperties));
RedisConnectionFactory redisConnectionFactory = mock(RedisConnectionFactory.class);
given(redisConnectionFactory.getConnection()).willReturn(redisConnection);
return redisConnectionFactory;
}
use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-boot by spring-projects.
the class RedisHealthIndicatorTests method healthWhenClusterStateIsFailShouldBeDown.
@Test
void healthWhenClusterStateIsFailShouldBeDown() {
RedisConnectionFactory redisConnectionFactory = createClusterConnectionFactory("fail");
RedisHealthIndicator healthIndicator = new RedisHealthIndicator(redisConnectionFactory);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails().get("cluster_size")).isEqualTo(4L);
assertThat(health.getDetails().get("slots_up")).isEqualTo(3L);
assertThat(health.getDetails().get("slots_fail")).isEqualTo(1L);
then(redisConnectionFactory).should(atLeastOnce()).getConnection();
}
use of org.springframework.data.redis.connection.RedisConnectionFactory in project redisson by redisson.
the class RedissonClusterConnectionTest method testConnectionFactoryReturnsClusterConnection.
@Test
public void testConnectionFactoryReturnsClusterConnection() {
RedisConnectionFactory connectionFactory = new RedissonConnectionFactory(redisson);
assertThat(connectionFactory.getConnection()).isInstanceOf(RedissonClusterConnection.class);
}
Aggregations