use of org.springframework.data.redis.RedisConnectionFailureException in project spring-boot by spring-projects.
the class RedisHealthIndicatorTests method redisIsDown.
@Test
public void redisIsDown() throws Exception {
RedisConnection redisConnection = mock(RedisConnection.class);
RedisConnectionFactory redisConnectionFactory = mock(RedisConnectionFactory.class);
given(redisConnectionFactory.getConnection()).willReturn(redisConnection);
given(redisConnection.info()).willThrow(new RedisConnectionFailureException("Connection failed"));
RedisHealthIndicator healthIndicator = new RedisHealthIndicator(redisConnectionFactory);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(((String) health.getDetails().get("error")).contains("Connection failed"));
verify(redisConnectionFactory).getConnection();
verify(redisConnection).info();
}
Aggregations