mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add sharding visitor
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package com.alibaba.druid.bvt.pool;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.sql.Connection;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.stat.DruidDataSourceStatManager;
|
||||
|
||||
public class TestActiveTrace extends TestCase {
|
||||
|
||||
private DruidDataSource dataSource;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
Assert.assertEquals(0, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
|
||||
|
||||
dataSource = new DruidDataSource();
|
||||
dataSource.setRemoveAbandoned(true);
|
||||
dataSource.setRemoveAbandonedTimeoutMillis(10);
|
||||
dataSource.setLogAbandoned(true);
|
||||
dataSource.setTimeBetweenEvictionRunsMillis(10);
|
||||
dataSource.setMinEvictableIdleTimeMillis(300 * 1000);
|
||||
dataSource.setUrl("jdbc:mock:xxx");
|
||||
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
dataSource.close();
|
||||
Assert.assertEquals(0, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
|
||||
}
|
||||
|
||||
public void test_activeTrace() throws Exception {
|
||||
for (int i = 0; i < 1000 * 1000; ++i) {
|
||||
dataSource.shrink();
|
||||
|
||||
Connection conn = dataSource.getConnection();
|
||||
conn.close();
|
||||
// Assert.assertEquals(1, dataSource.getPoolingCount());
|
||||
dataSource.shrink();
|
||||
Assert.assertEquals(0, dataSource.getPoolingCount());
|
||||
Assert.assertEquals(0, dataSource.getActiveConnections().size());
|
||||
|
||||
if (i % 5000 == 0) {
|
||||
System.out.println(ManagementFactory.getClassLoadingMXBean().getLoadedClassCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user