mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Polish "Reduce redis health indicator info command result size"
See gh-24208
This commit is contained in:
parent
99cc3f4bfc
commit
d506f0c73e
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -32,7 +32,6 @@ import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@ -62,7 +61,7 @@ class RedisHealthIndicatorTests {
|
||||
@Test
|
||||
void redisIsDown() {
|
||||
RedisConnection redisConnection = mock(RedisConnection.class);
|
||||
given(redisConnection.info(anyString())).willThrow(new RedisConnectionFailureException("Connection failed"));
|
||||
given(redisConnection.info("server")).willThrow(new RedisConnectionFailureException("Connection failed"));
|
||||
RedisHealthIndicator healthIndicator = createHealthIndicator(redisConnection);
|
||||
Health health = healthIndicator.health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
||||
|
@ -33,7 +33,6 @@ import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.ReactiveServerCommands;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@ -74,7 +73,7 @@ class RedisReactiveHealthIndicatorTests {
|
||||
ReactiveRedisConnection redisConnection = mock(ReactiveRedisClusterConnection.class);
|
||||
given(redisConnection.closeLater()).willReturn(Mono.empty());
|
||||
ReactiveClusterServerCommands commands = mock(ReactiveClusterServerCommands.class);
|
||||
given(commands.info()).willReturn(Mono.just(info));
|
||||
given(commands.info("server")).willReturn(Mono.just(info));
|
||||
RedisReactiveHealthIndicator healthIndicator = createHealthIndicator(redisConnection, commands);
|
||||
Mono<Health> health = healthIndicator.health();
|
||||
StepVerifier.create(health).consumeNextWith((h) -> {
|
||||
@ -88,7 +87,7 @@ class RedisReactiveHealthIndicatorTests {
|
||||
@Test
|
||||
void redisCommandIsDown() {
|
||||
ReactiveServerCommands commands = mock(ReactiveServerCommands.class);
|
||||
given(commands.info(anyString())).willReturn(Mono.error(new RedisConnectionFailureException("Connection failed")));
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user