mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
修正分配连接超过最大数量的问题
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@566 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user