修正分配连接超过最大数量的问题

git-svn-id: http://code.alibabatech.com/svn/druid/trunk@566 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-09-02 12:45:17 +00:00
parent 23b3b40f15
commit 1f407510a9
2 changed files with 22 additions and 17 deletions
@@ -38,8 +38,8 @@ public class TestIdle3_Concurrent_MaxActive extends TestCase {
public void test_idle2() throws Exception {
ManagementFactory.getPlatformMBeanServer().registerMBean(dataSource,
new ObjectName("com.alibaba:type=DataSource"));
// ManagementFactory.getPlatformMBeanServer().registerMBean(dataSource,
// new ObjectName("com.alibaba:type=DataSource"));
// 第一次创建连接
{
@@ -54,14 +54,14 @@ public class TestIdle3_Concurrent_MaxActive extends TestCase {
conn.close();
Assert.assertEquals(0, dataSource.getDestroyCount());
//Assert.assertEquals(2, driver.getConnections().size());
//Assert.assertEquals(2, dataSource.getCreateCount());
Assert.assertEquals(1, driver.getConnections().size());
Assert.assertEquals(1, dataSource.getCreateCount());
Assert.assertEquals(0, dataSource.getActiveCount());
}
for (int i = 0; i < 100; ++i) {
concurrent(20);
Assert.assertEquals(14, dataSource.getPoolingCount());
for (int i = 0; i < 1000; ++i) {
concurrent(200);
Assert.assertEquals("" + i, dataSource.getMaxActive(), dataSource.getPoolingCount());
dataSource.shrink();
}
@@ -90,7 +90,7 @@ public class TestIdle3_Concurrent_MaxActive extends TestCase {
try {
startLatch.await();
Connection conn = dataSource.getConnection();
long millis = new Random().nextInt(10) + 10;
long millis = new Random().nextInt(5) + 5;
Thread.sleep(millis);
conn.close();
} catch (Exception e) {