@Test public void propagates_any_datasource_access_exceptions() throws SQLException { DataSource dataSource = mock(DataSource.class); when(dataSource.getConnection()).thenThrow(SQLException.class); Supplier<Connection> connectionProvider = new ConnectionConfigurationByDataSource( dataSource, Optional.<String>empty(), Optional.<String>empty() ); thrown.expect(RuntimeException.class); thrown.expectCause(CoreMatchers.isA(SQLException.class)); connectionProvider.get(); }
@Override public Connection get() { try { return connection(); } catch (SQLException e) { throw propagate(e); } }
ConnectionConfigurationByDataSource implements ConnectionConfiguration { @Override public Connection get() { try { return connection(); } catch (SQLException e) { throw propagate(e); } } }
ConnectionConfigurationByDataSource implements ConnectionConfiguration { @Override public Connection get() { try { return connection(); } catch (SQLException e) { throw propagate(e); } } ConnectionConfigurationByDataSource(DataSource dataSource,
                                               Optional<String> username,
                                               Optional<String> password); }
ConnectionConfigurationByDataSource implements ConnectionConfiguration { @Override public Connection get() { try { return connection(); } catch (SQLException e) { throw propagate(e); } } ConnectionConfigurationByDataSource(DataSource dataSource,
                                               Optional<String> username,
                                               Optional<String> password); @Override Connection get(); }
ConnectionConfigurationByDataSource implements ConnectionConfiguration { @Override public Connection get() { try { return connection(); } catch (SQLException e) { throw propagate(e); } } ConnectionConfigurationByDataSource(DataSource dataSource,
                                               Optional<String> username,
                                               Optional<String> password); @Override Connection get();  }