@Test public void reportsUnhealthy() throws Exception { Connection connection; try (Connection c = dataSource.getConnection()) { connection = c; } when(managedDataSource.getConnection()).thenReturn(connection); JooqHealthCheck healthCheck = new JooqHealthCheck(managedDataSource, RETURN_UNHEALTHY); HealthCheck.Result result = healthCheck.check(); assertThat(result.isHealthy()).isFalse(); assertThat(result.getMessage()).isEqualTo("Unhealthy connection to database."); }
@Override protected Result check() throws Exception { try { databaseAgnostic(dataSource).selectOne().execute(); } catch (DataAccessException | SQLException e) { switch (onFailure) { case LOG_ONLY: logger.warn("Unhealthy connection to database."); break; case RETURN_UNHEALTHY: return Result.unhealthy("Unhealthy connection to database."); } } return Result.healthy(); }
JooqHealthCheck extends HealthCheck { @Override protected Result check() throws Exception { try { databaseAgnostic(dataSource).selectOne().execute(); } catch (DataAccessException | SQLException e) { switch (onFailure) { case LOG_ONLY: logger.warn("Unhealthy connection to database."); break; case RETURN_UNHEALTHY: return Result.unhealthy("Unhealthy connection to database."); } } return Result.healthy(); } }
JooqHealthCheck extends HealthCheck { @Override protected Result check() throws Exception { try { databaseAgnostic(dataSource).selectOne().execute(); } catch (DataAccessException | SQLException e) { switch (onFailure) { case LOG_ONLY: logger.warn("Unhealthy connection to database."); break; case RETURN_UNHEALTHY: return Result.unhealthy("Unhealthy connection to database."); } } return Result.healthy(); } JooqHealthCheck(ManagedDataSource dataSource, OnFailure onFailure); }
JooqHealthCheck extends HealthCheck { @Override protected Result check() throws Exception { try { databaseAgnostic(dataSource).selectOne().execute(); } catch (DataAccessException | SQLException e) { switch (onFailure) { case LOG_ONLY: logger.warn("Unhealthy connection to database."); break; case RETURN_UNHEALTHY: return Result.unhealthy("Unhealthy connection to database."); } } return Result.healthy(); } JooqHealthCheck(ManagedDataSource dataSource, OnFailure onFailure);  }
JooqHealthCheck extends HealthCheck { @Override protected Result check() throws Exception { try { databaseAgnostic(dataSource).selectOne().execute(); } catch (DataAccessException | SQLException e) { switch (onFailure) { case LOG_ONLY: logger.warn("Unhealthy connection to database."); break; case RETURN_UNHEALTHY: return Result.unhealthy("Unhealthy connection to database."); } } return Result.healthy(); } JooqHealthCheck(ManagedDataSource dataSource, OnFailure onFailure);   }