Java 类org.springframework.jdbc.datasource.AbstractDataSource 实例源码

项目:FinanceAnalytics    文件:BoneCPHackTest.java   
private BoneCPConfig createConfig() {
  final BoneCPConfig config = new BoneCPConfig();
  config.setPartitionCount(1);
  config.setLazyInit(false);
  config.setMinConnectionsPerPartition(3);
  config.setMaxConnectionsPerPartition(3);
  config.setDatasourceBean(new AbstractDataSource() {

    @Override
    public Connection getConnection() throws SQLException {
      return Mockito.mock(Connection.class);
    }

    @Override
    public Connection getConnection(String username, String password) throws SQLException {
      return getConnection();
    }

    public Logger getParentLogger() {
      return null;
    }
  });
  config.setConnectionTimeoutInMs(Timeout.standardTimeoutMillis());
  config.setConnectionHook(new BoneCPHack(config.getConnectionHook()));
  return config;
}