|
|
@ -26,8 +26,6 @@ import org.springframework.boot.actuate.health.ReactiveHealthIndicator;
|
|
|
|
import org.springframework.boot.actuate.health.Status;
|
|
|
|
import org.springframework.boot.actuate.health.Status;
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
|
|
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
|
|
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
import static org.mockito.BDDMockito.given;
|
|
|
|
import static org.mockito.BDDMockito.given;
|
|
|
@ -52,7 +50,7 @@ public class HealthEndpointAutoConfigurationTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void healthEndpointShowDetailsDefault() {
|
|
|
|
public void healthEndpointShowDetailsDefault() {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withUserConfiguration(ReactiveHealthIndicatorConfiguration.class)
|
|
|
|
.withBean(ReactiveHealthIndicator.class, this::reactiveHealthIndicator)
|
|
|
|
.run((context) -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ReactiveHealthIndicator indicator = context.getBean(
|
|
|
|
ReactiveHealthIndicator indicator = context.getBean(
|
|
|
|
"reactiveHealthIndicator", ReactiveHealthIndicator.class);
|
|
|
|
"reactiveHealthIndicator", ReactiveHealthIndicator.class);
|
|
|
@ -68,7 +66,7 @@ public class HealthEndpointAutoConfigurationTests {
|
|
|
|
public void healthEndpointAdaptReactiveHealthIndicator() {
|
|
|
|
public void healthEndpointAdaptReactiveHealthIndicator() {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues("management.endpoint.health.show-details=always")
|
|
|
|
.withPropertyValues("management.endpoint.health.show-details=always")
|
|
|
|
.withUserConfiguration(ReactiveHealthIndicatorConfiguration.class)
|
|
|
|
.withBean(ReactiveHealthIndicator.class, this::reactiveHealthIndicator)
|
|
|
|
.run((context) -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ReactiveHealthIndicator indicator = context.getBean(
|
|
|
|
ReactiveHealthIndicator indicator = context.getBean(
|
|
|
|
"reactiveHealthIndicator", ReactiveHealthIndicator.class);
|
|
|
|
"reactiveHealthIndicator", ReactiveHealthIndicator.class);
|
|
|
@ -84,8 +82,10 @@ public class HealthEndpointAutoConfigurationTests {
|
|
|
|
public void healthEndpointMergeRegularAndReactive() {
|
|
|
|
public void healthEndpointMergeRegularAndReactive() {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues("management.endpoint.health.show-details=always")
|
|
|
|
.withPropertyValues("management.endpoint.health.show-details=always")
|
|
|
|
.withUserConfiguration(HealthIndicatorConfiguration.class,
|
|
|
|
.withBean("simpleHealthIndicator", HealthIndicator.class,
|
|
|
|
ReactiveHealthIndicatorConfiguration.class)
|
|
|
|
this::simpleHealthIndicator)
|
|
|
|
|
|
|
|
.withBean("reactiveHealthIndicator", ReactiveHealthIndicator.class,
|
|
|
|
|
|
|
|
this::reactiveHealthIndicator)
|
|
|
|
.run((context) -> {
|
|
|
|
.run((context) -> {
|
|
|
|
HealthIndicator indicator = context.getBean("simpleHealthIndicator",
|
|
|
|
HealthIndicator indicator = context.getBean("simpleHealthIndicator",
|
|
|
|
HealthIndicator.class);
|
|
|
|
HealthIndicator.class);
|
|
|
@ -102,28 +102,16 @@ public class HealthEndpointAutoConfigurationTests {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
private HealthIndicator simpleHealthIndicator() {
|
|
|
|
static class HealthIndicatorConfiguration {
|
|
|
|
HealthIndicator mock = mock(HealthIndicator.class);
|
|
|
|
|
|
|
|
given(mock.health()).willReturn(Health.status(Status.UP).build());
|
|
|
|
@Bean
|
|
|
|
return mock;
|
|
|
|
public HealthIndicator simpleHealthIndicator() {
|
|
|
|
|
|
|
|
HealthIndicator mock = mock(HealthIndicator.class);
|
|
|
|
|
|
|
|
given(mock.health()).willReturn(Health.status(Status.UP).build());
|
|
|
|
|
|
|
|
return mock;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
private ReactiveHealthIndicator reactiveHealthIndicator() {
|
|
|
|
static class ReactiveHealthIndicatorConfiguration {
|
|
|
|
ReactiveHealthIndicator mock = mock(ReactiveHealthIndicator.class);
|
|
|
|
|
|
|
|
given(mock.health()).willReturn(Mono.just(Health.status(Status.UP).build()));
|
|
|
|
@Bean
|
|
|
|
return mock;
|
|
|
|
public ReactiveHealthIndicator reactiveHealthIndicator() {
|
|
|
|
|
|
|
|
ReactiveHealthIndicator mock = mock(ReactiveHealthIndicator.class);
|
|
|
|
|
|
|
|
given(mock.health()).willReturn(Mono.just(Health.status(Status.UP).build()));
|
|
|
|
|
|
|
|
return mock;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|