Search in sources :

Example 1 with DataSourceHealthIndicator

use of org.springframework.boot.actuate.health.DataSourceHealthIndicator in project spring-boot by spring-projects.

the class HealthIndicatorAutoConfigurationTests method dataSourceHealthIndicatorWithCustomValidationQuery.

@Test
public void dataSourceHealthIndicatorWithCustomValidationQuery() {
    this.context.register(PropertyPlaceholderAutoConfiguration.class, ManagementServerProperties.class, DataSourceProperties.class, DataSourceConfig.class, DataSourcePoolMetadataProvidersConfiguration.class, HealthIndicatorAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.test.validation-query:SELECT from FOOBAR", "management.health.diskspace.enabled:false");
    this.context.refresh();
    Map<String, HealthIndicator> beans = this.context.getBeansOfType(HealthIndicator.class);
    assertThat(beans).hasSize(1);
    HealthIndicator healthIndicator = beans.values().iterator().next();
    assertThat(healthIndicator.getClass()).isEqualTo(DataSourceHealthIndicator.class);
    DataSourceHealthIndicator dataSourceHealthIndicator = (DataSourceHealthIndicator) healthIndicator;
    assertThat(dataSourceHealthIndicator.getQuery()).isEqualTo("SELECT from FOOBAR");
}
Also used : DataSourceHealthIndicator(org.springframework.boot.actuate.health.DataSourceHealthIndicator) CompositeHealthIndicator(org.springframework.boot.actuate.health.CompositeHealthIndicator) CassandraHealthIndicator(org.springframework.boot.actuate.health.CassandraHealthIndicator) SolrHealthIndicator(org.springframework.boot.actuate.health.SolrHealthIndicator) ElasticsearchJestHealthIndicator(org.springframework.boot.actuate.health.ElasticsearchJestHealthIndicator) CouchbaseHealthIndicator(org.springframework.boot.actuate.health.CouchbaseHealthIndicator) LdapHealthIndicator(org.springframework.boot.actuate.health.LdapHealthIndicator) ElasticsearchHealthIndicator(org.springframework.boot.actuate.health.ElasticsearchHealthIndicator) ApplicationHealthIndicator(org.springframework.boot.actuate.health.ApplicationHealthIndicator) RedisHealthIndicator(org.springframework.boot.actuate.health.RedisHealthIndicator) MailHealthIndicator(org.springframework.boot.actuate.health.MailHealthIndicator) DiskSpaceHealthIndicator(org.springframework.boot.actuate.health.DiskSpaceHealthIndicator) HealthIndicator(org.springframework.boot.actuate.health.HealthIndicator) RabbitHealthIndicator(org.springframework.boot.actuate.health.RabbitHealthIndicator) MongoHealthIndicator(org.springframework.boot.actuate.health.MongoHealthIndicator) JmsHealthIndicator(org.springframework.boot.actuate.health.JmsHealthIndicator) DataSourceHealthIndicator(org.springframework.boot.actuate.health.DataSourceHealthIndicator) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 ApplicationHealthIndicator (org.springframework.boot.actuate.health.ApplicationHealthIndicator)1 CassandraHealthIndicator (org.springframework.boot.actuate.health.CassandraHealthIndicator)1 CompositeHealthIndicator (org.springframework.boot.actuate.health.CompositeHealthIndicator)1 CouchbaseHealthIndicator (org.springframework.boot.actuate.health.CouchbaseHealthIndicator)1 DataSourceHealthIndicator (org.springframework.boot.actuate.health.DataSourceHealthIndicator)1 DiskSpaceHealthIndicator (org.springframework.boot.actuate.health.DiskSpaceHealthIndicator)1 ElasticsearchHealthIndicator (org.springframework.boot.actuate.health.ElasticsearchHealthIndicator)1 ElasticsearchJestHealthIndicator (org.springframework.boot.actuate.health.ElasticsearchJestHealthIndicator)1 HealthIndicator (org.springframework.boot.actuate.health.HealthIndicator)1 JmsHealthIndicator (org.springframework.boot.actuate.health.JmsHealthIndicator)1 LdapHealthIndicator (org.springframework.boot.actuate.health.LdapHealthIndicator)1 MailHealthIndicator (org.springframework.boot.actuate.health.MailHealthIndicator)1 MongoHealthIndicator (org.springframework.boot.actuate.health.MongoHealthIndicator)1 RabbitHealthIndicator (org.springframework.boot.actuate.health.RabbitHealthIndicator)1 RedisHealthIndicator (org.springframework.boot.actuate.health.RedisHealthIndicator)1 SolrHealthIndicator (org.springframework.boot.actuate.health.SolrHealthIndicator)1