improve LogFilter

This commit is contained in:
wenshao
2012-11-27 14:44:32 +08:00
parent b66ecca5d7
commit ba1d978f9e
3 changed files with 45 additions and 4 deletions
@@ -0,0 +1,40 @@
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 LogFilterTest2 extends TestCase {
private DruidDataSource dataSource;
protected void setUp() throws Exception {
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 > 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);
}
}
@@ -34,6 +34,7 @@ public class HibernateCRUDTest extends TestCase {
dataSource.setUsername("sa");
dataSource.setPassword("");
dataSource.setDefaultAutoCommit(false);
dataSource.setFilters("log4j");
/*init sessionFactory*/
LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();