mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve test
This commit is contained in:
@@ -48,7 +48,7 @@ public class DruidStatServiceTest extends TestCase {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void test_statService() throws Exception {
|
||||
public void test_statService_getSqlList() throws Exception {
|
||||
String sql = "select 1";
|
||||
Connection conn = dataSource.getConnection();
|
||||
|
||||
@@ -74,4 +74,29 @@ public class DruidStatServiceTest extends TestCase {
|
||||
Assert.assertEquals(1, sqlStat.get("FetchRowCount"));
|
||||
Assert.assertEquals(0, sqlStat.get("EffectedRowCount"));
|
||||
}
|
||||
|
||||
public void test_statService_getDataSourceList() throws Exception {
|
||||
String sql = "select 1";
|
||||
Connection conn = dataSource.getConnection();
|
||||
|
||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
||||
conn.close();
|
||||
|
||||
String result = DruidStatService.getInstance().service("/datasource.json");
|
||||
Map<String, Object> resultMap = (Map<String, Object>) JSONUtils.parse(result);
|
||||
|
||||
List<Map<String, Object>> dataSourceList = (List<Map<String, Object>>) resultMap.get("Content");
|
||||
|
||||
Assert.assertEquals(1, dataSourceList.size());
|
||||
|
||||
Map<String, Object> dataSourceStat = dataSourceList.get(0);
|
||||
|
||||
Assert.assertEquals(1, dataSourceStat.get("PoolingCount"));
|
||||
Assert.assertEquals(0, dataSourceStat.get("ActiveCount"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user