@Test public void error() { this.indicator.setDataSource(this.dataSource); this.indicator.setQuery("SELECT COUNT(*) from BAR"); Health health = this.indicator.health(); assertThat(health.getDetails().get("database"), notNullValue()); assertEquals(Status.DOWN, health.getStatus()); }
@Test public void diskSpaceIsDown() throws Exception { given(this.fileMock.getFreeSpace()).willReturn(THRESHOLD_BYTES - 10); given(this.fileMock.getTotalSpace()).willReturn(THRESHOLD_BYTES * 10); Health health = this.healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.DOWN); assertThat(health.getDetails().get("threshold")).isEqualTo(THRESHOLD_BYTES); assertThat(health.getDetails().get("free")).isEqualTo(THRESHOLD_BYTES - 10); assertThat(health.getDetails().get("total")).isEqualTo(THRESHOLD_BYTES * 10); }
@Test public void customQuery() { 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"); Health health = this.indicator.health(); System.err.println(health); assertNotNull(health.getDetails().get("database")); assertEquals(Status.UP, health.getStatus()); assertNotNull(health.getDetails().get("hello")); }