mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
添加测试
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@285 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package com.alibaba.druid.bvt.proxy.filter;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
|
||||
import javax.management.openmbean.TabularData;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.stat.JdbcStatManager;
|
||||
|
||||
public class StatFilterTest extends TestCase {
|
||||
|
||||
public void setUp() throws Exception {
|
||||
JdbcStatManager.getInstance().reset();
|
||||
}
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
JdbcStatManager.getInstance().reset();
|
||||
}
|
||||
|
||||
public void test_stat() throws Exception {
|
||||
Connection conn = DriverManager.getConnection("jdbc:wrap-jdbc:filters=default:jdbc:mock:xx");
|
||||
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT 1");
|
||||
while (rs.next()) {
|
||||
rs.getInt(1);
|
||||
}
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
||||
conn.close();
|
||||
|
||||
TabularData sqlList = JdbcStatManager.getInstance().getSqlList();
|
||||
Assert.assertEquals(1, sqlList.size());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user