From 9e84abc46b8ac40dd6a5f5e88c677ac330448b3a Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 3 Dec 2018 15:10:59 +0100 Subject: [PATCH] Polish "Add validation query to DataSourceHealthIndicator details" Closes gh-15055 --- .../actuate/jdbc/DataSourceHealthIndicatorTests.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicatorTests.java index c75e7be6dd..31b434b908 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicatorTests.java @@ -26,6 +26,7 @@ import org.junit.Test; import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.Status; +import org.springframework.boot.jdbc.DatabaseDriver; import org.springframework.boot.jdbc.EmbeddedDatabaseConnection; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.SingleConnectionDataSource; @@ -68,6 +69,8 @@ public class DataSourceHealthIndicatorTests { Health health = this.indicator.health(); assertThat(health.getDetails().get("database")).isNotNull(); assertThat(health.getDetails().get("result")).isNotNull(); + assertThat(health.getDetails().get("validationQuery")) + .isEqualTo(DatabaseDriver.HSQLDB.getValidationQuery()); } @Test @@ -75,14 +78,14 @@ public class DataSourceHealthIndicatorTests { this.indicator.setDataSource(this.dataSource); new JdbcTemplate(this.dataSource) .execute("CREATE TABLE FOO (id INTEGER IDENTITY PRIMARY KEY)"); - this.indicator.setQuery("SELECT COUNT(*) from FOO"); + String customValidationQuery = "SELECT COUNT(*) from FOO"; + this.indicator.setQuery(customValidationQuery); Health health = this.indicator.health(); - System.err.println(health); assertThat(health.getDetails().get("database")).isNotNull(); assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getDetails().get("result")).isNotNull(); assertThat(health.getDetails().get("validationQuery")) - .isEqualTo("SELECT COUNT(*) from FOO"); + .isEqualTo(customValidationQuery); } @Test