Configure ping (formerly application) health indicator by default
This commit renames ApplicationHealthIndicator to PingHealthIndicator and changes the auto-configuration so that it is now always configured by default. Closes gh-17926
This commit is contained in:
@@ -20,7 +20,6 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.amqp.RabbitHealthIndicator;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
@@ -40,15 +39,13 @@ class RabbitHealthContributorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(RabbitHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(RabbitHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.rabbit.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(RabbitHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(RabbitHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
@@ -44,15 +43,13 @@ class CassandraHealthContributorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(CassandraHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(CassandraHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.cassandra.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(CassandraHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(CassandraHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraHealthIndicator;
|
||||
import org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.data.cassandra.core.ReactiveCassandraOperations;
|
||||
@@ -45,14 +44,13 @@ class CassandraReactiveHealthContributorAutoConfigurationTests {
|
||||
@Test
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(CassandraReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(CassandraHealthIndicator.class).doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
.doesNotHaveBean(CassandraHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.cassandra.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(CassandraReactiveHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(CassandraReactiveHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.couchbase.CouchbaseHealthIndicator;
|
||||
import org.springframework.boot.actuate.couchbase.CouchbaseReactiveHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
|
||||
@@ -43,15 +42,13 @@ class CouchbaseHealthContributorAutoConfigurationTests {
|
||||
@Test
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(CouchbaseHealthIndicator.class)
|
||||
.doesNotHaveBean(CouchbaseReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
.doesNotHaveBean(CouchbaseReactiveHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.couchbase.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(CouchbaseHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(CouchbaseHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.couchbase.CouchbaseHealthIndicator;
|
||||
import org.springframework.boot.actuate.couchbase.CouchbaseReactiveHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
|
||||
@@ -44,14 +43,13 @@ class CouchbaseReactiveHealthContributorAutoConfigurationTests {
|
||||
@Test
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(CouchbaseReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(CouchbaseHealthIndicator.class).doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
.doesNotHaveBean(CouchbaseHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.couchbase.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(CouchbaseReactiveHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(CouchbaseReactiveHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.elasticsearch.ElasticsearchHealthIndicator;
|
||||
import org.springframework.boot.actuate.elasticsearch.ElasticsearchJestHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
@@ -49,8 +48,7 @@ class ElasticsearchHealthContributorAutoConfigurationTests {
|
||||
this.contextRunner.withPropertyValues("spring.data.elasticsearch.cluster-nodes:localhost:0")
|
||||
.withSystemProperties("es.set.netty.runtime.available.processors=false")
|
||||
.run((context) -> assertThat(context).hasSingleBean(ElasticsearchHealthIndicator.class)
|
||||
.doesNotHaveBean(ElasticsearchJestHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
.doesNotHaveBean(ElasticsearchJestHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,16 +56,14 @@ class ElasticsearchHealthContributorAutoConfigurationTests {
|
||||
this.contextRunner.withBean(JestClient.class, () -> mock(JestClient.class))
|
||||
.withSystemProperties("es.set.netty.runtime.available.processors=false")
|
||||
.run((context) -> assertThat(context).hasSingleBean(ElasticsearchJestHealthIndicator.class)
|
||||
.doesNotHaveBean(ElasticsearchHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
.doesNotHaveBean(ElasticsearchHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.elasticsearch.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(ElasticsearchHealthIndicator.class)
|
||||
.doesNotHaveBean(ElasticsearchJestHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.doesNotHaveBean(ElasticsearchJestHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.hazelcast.HazelcastHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
@@ -40,15 +39,13 @@ class HazelcastHealthContributorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(HazelcastHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(HazelcastHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.hazelcast.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(HazelcastHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(HazelcastHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ package org.springframework.boot.actuate.autoconfigure.health;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.boot.actuate.health.PingHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -40,32 +40,31 @@ class HealthContributorAutoConfigurationTests {
|
||||
.withConfiguration(AutoConfigurations.of(HealthContributorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
void runWhenNoOtherIndicatorsCreatesDefaultApplicationHealthIndicator() {
|
||||
void runWhenNoOtherIndicatorsCreatesPingHealthIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).getBean(HealthIndicator.class)
|
||||
.isInstanceOf(ApplicationHealthIndicator.class));
|
||||
.isInstanceOf(PingHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenHasDefinedIndicatorDoesNotCreateDefaultApplicationHealthIndicator() {
|
||||
void runWhenHasDefinedIndicatorCreatesPingHealthIndicator() {
|
||||
this.contextRunner.withUserConfiguration(CustomHealthIndicatorConfiguration.class)
|
||||
.run((context) -> assertThat(context).getBean(HealthIndicator.class)
|
||||
.isInstanceOf(CustomHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).hasSingleBean(PingHealthIndicator.class)
|
||||
.hasSingleBean(CustomHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenHasDefaultsDisabledAndNoSingleIndicatorEnabledCreatesDefaultApplicationHealthIndicator() {
|
||||
void runWhenHasDefaultsDisabledDoesNotCreatePingHealthIndicator() {
|
||||
this.contextRunner.withUserConfiguration(CustomHealthIndicatorConfiguration.class)
|
||||
.withPropertyValues("management.health.defaults.enabled:false").run((context) -> assertThat(context)
|
||||
.getBean(HealthIndicator.class).isInstanceOf(ApplicationHealthIndicator.class));
|
||||
.withPropertyValues("management.health.defaults.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(HealthIndicator.class));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenHasDefaultsDisabledAndSingleIndicatorEnabledDoesNotCreateEnabledIndicator() {
|
||||
void runWhenHasDefaultsDisabledAndPingIndicatorEnabledCreatesPingHealthIndicator() {
|
||||
this.contextRunner.withUserConfiguration(CustomHealthIndicatorConfiguration.class)
|
||||
.withPropertyValues("management.health.defaults.enabled:false", "management.health.custom.enabled:true")
|
||||
.run((context) -> assertThat(context).getBean(HealthIndicator.class)
|
||||
.isInstanceOf(CustomHealthIndicator.class));
|
||||
.withPropertyValues("management.health.defaults.enabled:false", "management.health.ping.enabled:true")
|
||||
.run((context) -> assertThat(context).hasSingleBean(PingHealthIndicator.class));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ class HealthEndpointAutoConfigurationTests {
|
||||
this.contextRunner.run((context) -> {
|
||||
HealthContributorRegistry registry = context.getBean(HealthContributorRegistry.class);
|
||||
Object[] names = registry.stream().map(NamedContributor::getName).toArray();
|
||||
assertThat(names).containsExactlyInAnyOrder("simple", "additional");
|
||||
assertThat(names).containsExactlyInAnyOrder("simple", "additional", "ping");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ class HealthEndpointAutoConfigurationTests {
|
||||
this.reactiveContextRunner.run((context) -> {
|
||||
ReactiveHealthContributorRegistry registry = context.getBean(ReactiveHealthContributorRegistry.class);
|
||||
Object[] names = registry.stream().map(NamedContributor::getName).toArray();
|
||||
assertThat(names).containsExactlyInAnyOrder("simple", "additional", "reactive");
|
||||
assertThat(names).containsExactlyInAnyOrder("simple", "additional", "reactive", "ping");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.influxdb.InfluxDB;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.actuate.influx.InfluxDbHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
@@ -41,15 +40,13 @@ class InfluxDbHealthContributorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(InfluxDbHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(InfluxDbHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.influxdb.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(InfluxDbHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(InfluxDbHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,9 +21,7 @@ import javax.sql.DataSource;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.CompositeHealthContributor;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.boot.actuate.health.NamedContributor;
|
||||
import org.springframework.boot.actuate.jdbc.DataSourceHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
@@ -57,8 +55,7 @@ class DataSourceHealthContributorAutoConfigurationTests {
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> {
|
||||
context.getBean(DataSourceHealthIndicator.class);
|
||||
assertThat(context).hasSingleBean(DataSourceHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class);
|
||||
assertThat(context).hasSingleBean(DataSourceHealthIndicator.class);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -85,7 +82,7 @@ class DataSourceHealthContributorAutoConfigurationTests {
|
||||
this.contextRunner
|
||||
.withUserConfiguration(DataSourceConfig.class, DataSourcePoolMetadataProvidersConfiguration.class)
|
||||
.withPropertyValues("spring.datasource.test.validation-query:SELECT from FOOBAR").run((context) -> {
|
||||
assertThat(context).hasSingleBean(HealthIndicator.class);
|
||||
assertThat(context).hasSingleBean(DataSourceHealthIndicator.class);
|
||||
DataSourceHealthIndicator indicator = context.getBean(DataSourceHealthIndicator.class);
|
||||
assertThat(indicator.getQuery()).isEqualTo("SELECT from FOOBAR");
|
||||
});
|
||||
@@ -96,8 +93,7 @@ class DataSourceHealthContributorAutoConfigurationTests {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
|
||||
.withPropertyValues("management.health.db.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(DataSourceHealthIndicator.class)
|
||||
.doesNotHaveBean(CompositeHealthContributor.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.doesNotHaveBean(CompositeHealthContributor.class));
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.boot.actuate.autoconfigure.jms;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.actuate.jms.JmsHealthIndicator;
|
||||
import org.springframework.boot.actuate.ldap.LdapHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
@@ -41,15 +40,13 @@ class JmsHealthContributorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(JmsHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(JmsHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.jms.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(LdapHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(LdapHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.boot.actuate.autoconfigure.ldap;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.actuate.ldap.LdapHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
@@ -42,15 +41,13 @@ class LdapHealthContributorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(LdapHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(LdapHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.ldap.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(LdapHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(LdapHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.boot.actuate.autoconfigure.mail;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.actuate.mail.MailHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration;
|
||||
@@ -41,15 +40,13 @@ class MailHealthContributorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(MailHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(MailHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.mail.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(MailHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(MailHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.boot.actuate.autoconfigure.mongo;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.actuate.mongo.MongoHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
|
||||
@@ -41,15 +40,13 @@ class MongoHealthContributorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(MongoHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(MongoHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.mongo.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(MongoHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(MongoHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.boot.actuate.autoconfigure.mongo;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.actuate.mongo.MongoHealthIndicator;
|
||||
import org.springframework.boot.actuate.mongo.MongoReactiveHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
@@ -46,14 +45,14 @@ class MongoReactiveHealthContributorAutoConfigurationTests {
|
||||
@Test
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(MongoReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(MongoHealthIndicator.class).doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
.doesNotHaveBean(MongoHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.mongo.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(MongoReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(MongoHealthIndicator.class).hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.doesNotHaveBean(MongoHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.neo4j.ogm.session.Session;
|
||||
import org.neo4j.ogm.session.SessionFactory;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.neo4j.Neo4jHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
@@ -47,22 +46,19 @@ class Neo4jHealthContributorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(Neo4jHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(Neo4jHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.neo4j.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(Neo4jHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(Neo4jHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultIndicatorCanBeReplaced() {
|
||||
this.contextRunner.withUserConfiguration(CustomIndicatorConfiguration.class).run((context) -> {
|
||||
assertThat(context).hasSingleBean(Neo4jHealthIndicator.class);
|
||||
assertThat(context).doesNotHaveBean(ApplicationHealthIndicator.class);
|
||||
Health health = context.getBean(Neo4jHealthIndicator.class).health();
|
||||
assertThat(health.getDetails()).containsOnly(entry("test", true));
|
||||
});
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.boot.actuate.autoconfigure.redis;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.actuate.redis.RedisHealthIndicator;
|
||||
import org.springframework.boot.actuate.redis.RedisReactiveHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
@@ -44,15 +43,14 @@ class RedisHealthContributorAutoConfigurationTests {
|
||||
@Test
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(RedisHealthIndicator.class)
|
||||
.doesNotHaveBean(RedisReactiveHealthIndicator.class).doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
.doesNotHaveBean(RedisReactiveHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.redis.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(RedisHealthIndicator.class)
|
||||
.doesNotHaveBean(RedisReactiveHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.doesNotHaveBean(RedisReactiveHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.boot.actuate.autoconfigure.redis;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.actuate.redis.RedisHealthIndicator;
|
||||
import org.springframework.boot.actuate.redis.RedisReactiveHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
@@ -43,14 +42,14 @@ class RedisReactiveHealthContributorAutoConfigurationTests {
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run(
|
||||
(context) -> assertThat(context).hasSingleBean(RedisReactiveHealthContributorAutoConfiguration.class)
|
||||
.doesNotHaveBean(RedisHealthIndicator.class).doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
.doesNotHaveBean(RedisHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.redis.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(RedisReactiveHealthIndicator.class)
|
||||
.doesNotHaveBean(RedisHealthIndicator.class).hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.doesNotHaveBean(RedisHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.boot.actuate.autoconfigure.solr;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.actuate.solr.SolrHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration;
|
||||
@@ -40,15 +39,13 @@ class SolrHealthContributorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(SolrHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(SolrHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.solr.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(SolrHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(SolrHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.boot.actuate.autoconfigure.system;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.health.ApplicationHealthIndicator;
|
||||
import org.springframework.boot.actuate.system.DiskSpaceHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
@@ -40,8 +39,7 @@ class DiskSpaceHealthContributorAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(DiskSpaceHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(DiskSpaceHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,8 +61,7 @@ class DiskSpaceHealthContributorAutoConfigurationTests {
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.diskspace.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(DiskSpaceHealthIndicator.class)
|
||||
.hasSingleBean(ApplicationHealthIndicator.class));
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(DiskSpaceHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user