use of org.springframework.data.redis.connection.ReactiveServerCommands in project spring-boot by spring-projects.
the class RedisReactiveHealthIndicatorTests method redisCommandIsDown.
@Test
void redisCommandIsDown() {
ReactiveServerCommands commands = mock(ReactiveServerCommands.class);
given(commands.info("server")).willReturn(Mono.error(new RedisConnectionFailureException("Connection failed")));
ReactiveRedisConnection redisConnection = mock(ReactiveRedisConnection.class);
given(redisConnection.closeLater()).willReturn(Mono.empty());
RedisReactiveHealthIndicator healthIndicator = createHealthIndicator(redisConnection, commands);
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health).consumeNextWith((h) -> assertThat(h.getStatus()).isEqualTo(Status.DOWN)).verifyComplete();
then(redisConnection).should().closeLater();
}
use of org.springframework.data.redis.connection.ReactiveServerCommands in project spring-boot by spring-projects.
the class RedisReactiveHealthIndicatorTests method redisIsUp.
@Test
void redisIsUp() {
Properties info = new Properties();
info.put("redis_version", "2.8.9");
ReactiveRedisConnection redisConnection = mock(ReactiveRedisConnection.class);
given(redisConnection.closeLater()).willReturn(Mono.empty());
ReactiveServerCommands commands = mock(ReactiveServerCommands.class);
given(commands.info("server")).willReturn(Mono.just(info));
RedisReactiveHealthIndicator healthIndicator = createHealthIndicator(redisConnection, commands);
Mono<Health> health = healthIndicator.health();
StepVerifier.create(health).consumeNextWith((h) -> {
assertThat(h.getStatus()).isEqualTo(Status.UP);
assertThat(h.getDetails()).containsOnlyKeys("version");
assertThat(h.getDetails().get("version")).isEqualTo("2.8.9");
}).verifyComplete();
then(redisConnection).should().closeLater();
}
Aggregations