MySQLStorage extends StorageComponent { @Override public CheckResult check() { try (Connection conn = datasource.getConnection()) { context.get(conn).select(ZIPKIN_SPANS.TRACE_ID).from(ZIPKIN_SPANS).limit(1).execute(); } catch (Throwable e) { Call.propagateIfFatal(e); return CheckResult.failed(e); } return CheckResult.OK; } MySQLStorage(MySQLStorage.Builder builder); static Builder newBuilder(); DataSource datasource(); @Override SpanStore spanStore(); @Override Traces traces(); @Override ServiceAndSpanNames serviceAndSpanNames(); @Override AutocompleteTags autocompleteTags(); @Override SpanConsumer spanConsumer(); @Override CheckResult check(); @Override final String toString(); @Override void close();  }
@Test public void check_failsInsteadOfThrowing() throws SQLException { DataSource dataSource = mock(DataSource.class); when(dataSource.getConnection()).thenThrow(new SQLException("foo")); CheckResult result = storage(dataSource).check(); assertThat(result.ok()).isFalse(); assertThat(result.error()) .isInstanceOf(SQLException.class); }