Search in sources :

Example 1 with RedisConnectionException

use of io.lettuce.core.RedisConnectionException in project spring-boot by spring-projects.

the class RedisReactiveHealthIndicatorTests method redisConnectionIsDown.

@Test
void redisConnectionIsDown() {
    ReactiveRedisConnectionFactory redisConnectionFactory = mock(ReactiveRedisConnectionFactory.class);
    given(redisConnectionFactory.getReactiveConnection()).willThrow(new RedisConnectionException("Unable to connect to localhost:6379"));
    RedisReactiveHealthIndicator healthIndicator = new RedisReactiveHealthIndicator(redisConnectionFactory);
    Mono<Health> health = healthIndicator.health();
    StepVerifier.create(health).consumeNextWith((h) -> assertThat(h.getStatus()).isEqualTo(Status.DOWN)).verifyComplete();
}
Also used : Status(org.springframework.boot.actuate.health.Status) Properties(java.util.Properties) StepVerifier(reactor.test.StepVerifier) RedisConnectionFailureException(org.springframework.data.redis.RedisConnectionFailureException) ReactiveServerCommands(org.springframework.data.redis.connection.ReactiveServerCommands) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ReactiveRedisClusterConnection(org.springframework.data.redis.connection.ReactiveRedisClusterConnection) BDDMockito.then(org.mockito.BDDMockito.then) Mono(reactor.core.publisher.Mono) Health(org.springframework.boot.actuate.health.Health) Test(org.junit.jupiter.api.Test) RedisConnectionException(io.lettuce.core.RedisConnectionException) BDDMockito.given(org.mockito.BDDMockito.given) ReactiveRedisConnection(org.springframework.data.redis.connection.ReactiveRedisConnection) ReactiveRedisConnectionFactory(org.springframework.data.redis.connection.ReactiveRedisConnectionFactory) ClusterInfo(org.springframework.data.redis.connection.ClusterInfo) Mockito.mock(org.mockito.Mockito.mock) Health(org.springframework.boot.actuate.health.Health) ReactiveRedisConnectionFactory(org.springframework.data.redis.connection.ReactiveRedisConnectionFactory) RedisConnectionException(io.lettuce.core.RedisConnectionException) Test(org.junit.jupiter.api.Test)

Aggregations

RedisConnectionException (io.lettuce.core.RedisConnectionException)1 Properties (java.util.Properties)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Test (org.junit.jupiter.api.Test)1 BDDMockito.given (org.mockito.BDDMockito.given)1 BDDMockito.then (org.mockito.BDDMockito.then)1 Mockito.mock (org.mockito.Mockito.mock)1 Health (org.springframework.boot.actuate.health.Health)1 Status (org.springframework.boot.actuate.health.Status)1 RedisConnectionFailureException (org.springframework.data.redis.RedisConnectionFailureException)1 ClusterInfo (org.springframework.data.redis.connection.ClusterInfo)1 ReactiveRedisClusterConnection (org.springframework.data.redis.connection.ReactiveRedisClusterConnection)1 ReactiveRedisConnection (org.springframework.data.redis.connection.ReactiveRedisConnection)1 ReactiveRedisConnectionFactory (org.springframework.data.redis.connection.ReactiveRedisConnectionFactory)1 ReactiveServerCommands (org.springframework.data.redis.connection.ReactiveServerCommands)1 Mono (reactor.core.publisher.Mono)1 StepVerifier (reactor.test.StepVerifier)1