improve LogFilter

This commit is contained in:
wenshao
2012-12-25 01:02:28 +08:00
parent 0ffda4f76f
commit 34dc7b577d
6 changed files with 208 additions and 16 deletions
@@ -59,7 +59,7 @@ public class Case1 extends TestCase {
private String validationQuery = "SELECT 1";
private int threadCount = 5;
private int loopCount = 10;
final int LOOP_COUNT = 1000 * 1000 * 1 / threadCount;
final int LOOP_COUNT = 1000 * 1 * 1 / threadCount;
private static AtomicLong physicalConnStat = new AtomicLong();
@@ -0,0 +1,44 @@
package com.alibaba.druid.bvt.filter.log;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import junit.framework.TestCase;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.util.JdbcUtils;
public class LogFilterTest3 extends TestCase {
private DruidDataSource dataSource;
protected void setUp() throws Exception {
System.setProperty("druid.log.stmt.executableSql", "true");
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:derby:classpath:petstore-db");
dataSource.setFilters("log4j");
}
public void test_select() throws Exception {
Connection conn = dataSource.getConnection();
PreparedStatement stmt = conn.prepareStatement("SELECT * FROM ITEM WHERE LISTPRICE > ?");
stmt.setInt(1, 10);
for (int i = 0; i < 10; ++i) {
ResultSet rs = stmt.executeQuery();
rs.close();
}
stmt.close();
conn.close();
}
protected void tearDown() throws Exception {
JdbcUtils.close(dataSource);
System.clearProperty("druid.log.stmt.executableSql");
}
}