@Test void testUnhealthyDefault() { final HealthCheck check = new DBHealthCheck(); assertEquals(HealthCheckResponse.State.DOWN, check.call().getState(), "Database connection isn't healthy!"); }
@Override public HealthCheckResponse call() { if (dataSource != null) { try (final Connection conn = dataSource.getConnection()) { return HealthCheckResponse.named(DBHealthCheck.class.getSimpleName()) .state(!conn.isClosed()).build(); } catch (final SQLException ex) { return HealthCheckResponse.named(DBHealthCheck.class.getSimpleName()) .withData("exception", ex.getMessage()).down().build(); } } return HealthCheckResponse.named(DBHealthCheck.class.getSimpleName()).down().build(); }
DBHealthCheck implements HealthCheck { @Override public HealthCheckResponse call() { if (dataSource != null) { try (final Connection conn = dataSource.getConnection()) { return HealthCheckResponse.named(DBHealthCheck.class.getSimpleName()) .state(!conn.isClosed()).build(); } catch (final SQLException ex) { return HealthCheckResponse.named(DBHealthCheck.class.getSimpleName()) .withData("exception", ex.getMessage()).down().build(); } } return HealthCheckResponse.named(DBHealthCheck.class.getSimpleName()).down().build(); } }
DBHealthCheck implements HealthCheck { @Override public HealthCheckResponse call() { if (dataSource != null) { try (final Connection conn = dataSource.getConnection()) { return HealthCheckResponse.named(DBHealthCheck.class.getSimpleName()) .state(!conn.isClosed()).build(); } catch (final SQLException ex) { return HealthCheckResponse.named(DBHealthCheck.class.getSimpleName()) .withData("exception", ex.getMessage()).down().build(); } } return HealthCheckResponse.named(DBHealthCheck.class.getSimpleName()).down().build(); } DBHealthCheck(); @Inject  DBHealthCheck(final DataSource dataSource); }
DBHealthCheck implements HealthCheck { @Override public HealthCheckResponse call() { if (dataSource != null) { try (final Connection conn = dataSource.getConnection()) { return HealthCheckResponse.named(DBHealthCheck.class.getSimpleName()) .state(!conn.isClosed()).build(); } catch (final SQLException ex) { return HealthCheckResponse.named(DBHealthCheck.class.getSimpleName()) .withData("exception", ex.getMessage()).down().build(); } } return HealthCheckResponse.named(DBHealthCheck.class.getSimpleName()).down().build(); } DBHealthCheck(); @Inject  DBHealthCheck(final DataSource dataSource); @Override HealthCheckResponse call(); }
DBHealthCheck implements HealthCheck { @Override public HealthCheckResponse call() { if (dataSource != null) { try (final Connection conn = dataSource.getConnection()) { return HealthCheckResponse.named(DBHealthCheck.class.getSimpleName()) .state(!conn.isClosed()).build(); } catch (final SQLException ex) { return HealthCheckResponse.named(DBHealthCheck.class.getSimpleName()) .withData("exception", ex.getMessage()).down().build(); } } return HealthCheckResponse.named(DBHealthCheck.class.getSimpleName()).down().build(); } DBHealthCheck(); @Inject  DBHealthCheck(final DataSource dataSource); @Override HealthCheckResponse call();  }