dataSource.setFilters("stat");
JdbcStatManager.getInstance().reset();
dataSource.init();
JdbcDataSourceStat stat = dataSource.getDataSourceStat();
Assert.assertEquals(0, stat.getConnectionStat().getConnectCount());
Assert.assertEquals(1, dataSource.getProxyFilters().size());
for (int i = 0; i < 2; ++i) {
Connection conn = dataSource.getConnection();
Assert.assertEquals(1, stat.getConnectionStat().getConnectCount());
Assert.assertEquals(0, stat.getConnectionStat().getCloseCount());
conn.close();
Assert.assertEquals(1, stat.getConnectionStat().getConnectCount());
Assert.assertEquals(0, stat.getConnectionStat().getCloseCount()); // logic
// close不会导致计数器+1
}
dataSource.close();
// Assert.assertEquals(0, JdbcStatManager.getInstance().getDataSources().size());
Assert.assertEquals(1, stat.getConnectionStat().getConnectCount());
Assert.assertEquals(1, stat.getConnectionStat().getCloseCount());
JdbcStatManager.getInstance().reset();
Assert.assertEquals(1, stat.getConnectionStat().getConnectCount());
Assert.assertEquals(1, stat.getConnectionStat().getCloseCount());
}