BoneCpDatasourceAccessor implements DatasourceAccessor { @Override public DataSourceInfo getInfo(final Object resource) throws Exception { DataSourceInfo dataSourceInfo = null; if (canMap(resource)) { final BoneCPDataSource source = (BoneCPDataSource) resource; BoneCP pool; try { pool = source.getPool(); } catch (NoSuchMethodError ex) { logger.trace("", ex); final Field poolField = BoneCPDataSource.class.getDeclaredField("pool"); poolField.setAccessible(true); pool = (BoneCP) poolField.get(source); } dataSourceInfo = new DataSourceInfo(); dataSourceInfo.setBusyConnections(source.getTotalLeased()); if (pool == null) { dataSourceInfo.setEstablishedConnections(source.getMinConnectionsPerPartition()); logger.warn("pool is null {}", source.getJdbcUrl()); } else { dataSourceInfo.setEstablishedConnections(pool.getTotalCreatedConnections()); } dataSourceInfo .setMaxConnections(source.getPartitionCount() * source.getMaxConnectionsPerPartition()); dataSourceInfo.setJdbcUrl(source.getJdbcUrl()); dataSourceInfo.setUsername(source.getUsername()); dataSourceInfo.setResettable(false); dataSourceInfo.setType("bonecp"); } return dataSourceInfo; }  @Override DataSourceInfo getInfo(final Object resource); @Override boolean reset(final Object resource); @Override boolean canMap(final Object resource);  }
@Test public void getInfoTest() throws Exception { accessor.getInfo(source); }