mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed for useGloalDataSourceStat
This commit is contained in:
@@ -3,14 +3,18 @@ package com.alibaba.druid.bvt.proxy.filter;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
import org.junit.Assert;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.stat.JdbcDataSourceStat;
|
||||
import com.alibaba.druid.stat.JdbcStatManager;
|
||||
import com.alibaba.druid.support.json.JSONUtils;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
|
||||
public class GlobalStatTest0 extends TestCase {
|
||||
@@ -41,6 +45,7 @@ public class GlobalStatTest0 extends TestCase {
|
||||
Assert.assertEquals(0, JdbcStatManager.getInstance().getSqlList().size());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void test_execute() throws Exception {
|
||||
{
|
||||
Connection conn = dataSourceA.getConnection();
|
||||
@@ -69,6 +74,12 @@ public class GlobalStatTest0 extends TestCase {
|
||||
Assert.assertSame(JdbcDataSourceStat.getGlobal(), dataSourceB.getDataSourceStat());
|
||||
|
||||
Assert.assertEquals(1, JdbcStatManager.getInstance().getSqlList().size());
|
||||
String json = JSONUtils.toJSONString(JdbcStatManager.getInstance().getSqlList());
|
||||
List<Map<String, Object>> sqlList = (List<Map<String, Object>>) JSONUtils.parse(json);
|
||||
Map<String, Object> sqlInfo = sqlList.get(0);
|
||||
Assert.assertEquals(JdbcConstants.MOCK, sqlInfo.get("DbType"));
|
||||
Assert.assertEquals(2, sqlInfo.get("ExecuteCount"));
|
||||
Assert.assertEquals(2, sqlInfo.get("FetchRowCount"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user