bug fixed for sql stat maxSize

This commit is contained in:
wenshao
2012-08-02 08:49:19 +08:00
parent 58dd93afb9
commit e552bb9170
4 changed files with 102 additions and 5 deletions
@@ -0,0 +1,46 @@
package com.alibaba.druid.bvt.pool;
import java.util.Properties;
import junit.framework.Assert;
import junit.framework.TestCase;
import com.alibaba.druid.Constants;
import com.alibaba.druid.stat.JdbcDataSourceStat;
public class JdbcDataSourceStatTest extends TestCase {
public void test_max() throws Exception {
JdbcDataSourceStat stat = new JdbcDataSourceStat("", "");
for (int i = 0; i < 1000 * 10; ++i) {
stat.createSqlStat("select " + i);
}
Assert.assertEquals(1000, stat.getSqlStatMap().size());
}
public void test_max_10() throws Exception {
Properties connectProperties = new Properties();
connectProperties.put(Constants.DRUID_STAT_SQL_MAX_SIZE, 10);
JdbcDataSourceStat stat = new JdbcDataSourceStat("", "", "mysql", connectProperties);
for (int i = 0; i < 1000 * 1; ++i) {
stat.createSqlStat("select " + i);
}
Assert.assertEquals(10, stat.getSqlStatMap().size());
}
public void test_max_10_str() throws Exception {
Properties connectProperties = new Properties();
connectProperties.put(Constants.DRUID_STAT_SQL_MAX_SIZE, "10");
JdbcDataSourceStat stat = new JdbcDataSourceStat("", "", "mysql", connectProperties);
for (int i = 0; i < 1000 * 1; ++i) {
stat.createSqlStat("select " + i);
}
Assert.assertEquals(10, stat.getSqlStatMap().size());
}
}