Java 类org.springframework.boot.actuate.health.DataSourceHealthIndicator 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HealthIndicatorAutoConfigurationTests.java   
@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");
}
项目:spring-boot-concourse    文件:HealthIndicatorAutoConfigurationTests.java   
@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");
}
项目:contestparser    文件:HealthIndicatorAutoConfigurationTests.java   
@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.validation-query:SELECT from FOOBAR",
            "management.health.diskspace.enabled:false");
    this.context.refresh();
    Map<String, HealthIndicator> beans = this.context
            .getBeansOfType(HealthIndicator.class);
    assertEquals(1, beans.size());
    HealthIndicator healthIndicator = beans.values().iterator().next();
    assertEquals(DataSourceHealthIndicator.class, healthIndicator.getClass());
    DataSourceHealthIndicator dataSourceHealthIndicator = (DataSourceHealthIndicator) healthIndicator;
    assertEquals("SELECT from FOOBAR", dataSourceHealthIndicator.getQuery());
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void dataSourceHealthIndicator() {
    this.context.register(EmbeddedDataSourceConfiguration.class,
            ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "management.health.diskspace.enabled:false");
    this.context.refresh();
    Map<String, HealthIndicator> beans = this.context
            .getBeansOfType(HealthIndicator.class);
    assertThat(beans).hasSize(1);
    assertThat(beans.values().iterator().next().getClass())
            .isEqualTo(DataSourceHealthIndicator.class);
}
项目:spring-boot-concourse    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void dataSourceHealthIndicator() {
    this.context.register(EmbeddedDataSourceConfiguration.class,
            ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "management.health.diskspace.enabled:false");
    this.context.refresh();
    Map<String, HealthIndicator> beans = this.context
            .getBeansOfType(HealthIndicator.class);
    assertThat(beans).hasSize(1);
    assertThat(beans.values().iterator().next().getClass())
            .isEqualTo(DataSourceHealthIndicator.class);
}
项目:contestparser    文件:HealthIndicatorAutoConfigurationTests.java   
@Test
public void dataSourceHealthIndicator() {
    this.context.register(EmbeddedDataSourceConfiguration.class,
            ManagementServerProperties.class, HealthIndicatorAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context,
            "management.health.diskspace.enabled:false");
    this.context.refresh();
    Map<String, HealthIndicator> beans = this.context
            .getBeansOfType(HealthIndicator.class);
    assertEquals(1, beans.size());
    assertEquals(DataSourceHealthIndicator.class,
            beans.values().iterator().next().getClass());
}
项目:lemonaid    文件:HealthConfiguration.java   
@Bean
public HealthIndicator dbHealthIndicator(final DataSource dataSource) {
    DataSourceHealthIndicator indicator = new DataSourceHealthIndicator(dataSource);
    indicator.setQuery("SELECT COUNT(1) id FROM mentors");
    return indicator;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:HealthIndicatorAutoConfiguration.java   
@Override
protected DataSourceHealthIndicator createHealthIndicator(DataSource source) {
    return new DataSourceHealthIndicator(source, getValidationQuery(source));
}
项目:spring-boot-concourse    文件:HealthIndicatorAutoConfiguration.java   
@Override
protected DataSourceHealthIndicator createHealthIndicator(DataSource source) {
    return new DataSourceHealthIndicator(source, getValidationQuery(source));
}
项目:contestparser    文件:HealthIndicatorAutoConfiguration.java   
@Override
protected DataSourceHealthIndicator createHealthIndicator(DataSource source) {
    return new DataSourceHealthIndicator(source, getValidationQuery(source));
}