add testcase

This commit is contained in:
wenshao
2012-08-10 08:46:18 +08:00
parent 08aa4fbc03
commit b4f9d65840
2 changed files with 39 additions and 1 deletions
@@ -12,7 +12,7 @@ public class SlowSqlMillisTest extends TestCase {
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:wrap-jdbc:jdbc:mock:xxx");
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setTestOnBorrow(false);
dataSource.setTestOnReturn(false);
dataSource.setTestWhileIdle(false);
@@ -0,0 +1,38 @@
package com.alibaba.druid.bvt.pool;
import junit.framework.Assert;
import junit.framework.TestCase;
import com.alibaba.druid.filter.stat.StatFilter;
import com.alibaba.druid.pool.DruidDataSource;
public class SlowSqlMillisTest2 extends TestCase {
private DruidDataSource dataSource;
protected void setUp() throws Exception {
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setTestOnBorrow(false);
dataSource.setTestOnReturn(false);
dataSource.setTestWhileIdle(false);
System.setProperty("druid.stat.slowSqlMillis", "500");
dataSource.setFilters("stat");
{
StatFilter filter = (StatFilter) dataSource.getProxyFilters().get(0);
Assert.assertEquals(3000, filter.getSlowSqlMillis());
}
dataSource.init();
}
protected void tearDown() throws Exception {
System.clearProperty("druid.stat.slowSqlMillis");
dataSource.close();
}
public void test_connect() throws Exception {
StatFilter filter = (StatFilter) dataSource.getProxyFilters().get(0);
Assert.assertEquals(500, filter.getSlowSqlMillis());
}
}