bug fixed for useGloalDataSourceStat

This commit is contained in:
wenshao
2013-05-10 02:31:36 +08:00
parent 0cf04d27f1
commit dc45b9d57e
3 changed files with 26 additions and 3 deletions
@@ -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"));
}
}