use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class DiskSpaceHealthIndicatorTests method whenPathDoesNotExistDiskSpaceIsDown.
@Test
void whenPathDoesNotExistDiskSpaceIsDown() {
Health health = new DiskSpaceHealthIndicator(new File("does/not/exist"), THRESHOLD).health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails().get("free")).isEqualTo(0L);
assertThat(health.getDetails().get("total")).isEqualTo(0L);
assertThat(health.getDetails().get("exists")).isEqualTo(false);
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class Neo4jHealthContributorAutoConfigurationTests method defaultIndicatorCanBeReplaced.
@Test
void defaultIndicatorCanBeReplaced() {
this.contextRunner.withUserConfiguration(Neo4jConfiguration.class, CustomIndicatorConfiguration.class).run((context) -> {
assertThat(context).hasBean("neo4jHealthIndicator");
Health health = context.getBean("neo4jHealthIndicator", HealthIndicator.class).health();
assertThat(health.getDetails()).containsOnly(entry("test", true));
});
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class HazelcastHealthIndicatorTests method hazelcastUp.
@Test
void hazelcastUp() {
new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(HazelcastAutoConfiguration.class)).withPropertyValues("spring.hazelcast.config=hazelcast.xml").run((context) -> {
HazelcastInstance hazelcast = context.getBean(HazelcastInstance.class);
Health health = new HazelcastHealthIndicator(hazelcast).health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails()).containsOnlyKeys("name", "uuid").containsEntry("name", "actuator-hazelcast");
assertThat(health.getDetails().get("uuid")).asString().isNotEmpty();
});
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class DataSourceHealthIndicatorTests method healthIndicatorWithDefaultSettings.
@Test
void healthIndicatorWithDefaultSettings() {
this.indicator.setDataSource(this.dataSource);
Health health = this.indicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails()).containsOnly(entry("database", "HSQL Database Engine"), entry("validationQuery", "isValid()"));
}
use of org.springframework.boot.actuate.health.Health in project spring-boot by spring-projects.
the class DataSourceHealthIndicatorTests method healthIndicatorWithConnectionValidationFailure.
@Test
void healthIndicatorWithConnectionValidationFailure() throws SQLException {
DataSource dataSource = mock(DataSource.class);
Connection connection = mock(Connection.class);
given(connection.isValid(0)).willReturn(false);
given(connection.getMetaData()).willReturn(this.dataSource.getConnection().getMetaData());
given(dataSource.getConnection()).willReturn(connection);
this.indicator.setDataSource(dataSource);
Health health = this.indicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat(health.getDetails()).containsOnly(entry("database", "HSQL Database Engine"), entry("validationQuery", "isValid()"));
}
Aggregations