mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
test
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@621 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -102,13 +102,40 @@ public class TestConcurrent extends TestCase {
|
||||
Assert.assertEquals(COUNT, dataSource.getPoolingCount());
|
||||
}
|
||||
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
// 2个并发
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
concurrent(2);
|
||||
}
|
||||
|
||||
// 5个并发
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
concurrent(5);
|
||||
}
|
||||
|
||||
// 10并发
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
concurrent(10);
|
||||
}
|
||||
|
||||
// 20并发
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
concurrent(20);
|
||||
}
|
||||
|
||||
// 50并发
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
concurrent(50);
|
||||
}
|
||||
|
||||
// 100并发
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
concurrent(100);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 并发执行10000次
|
||||
*
|
||||
* @param threadCount
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
@@ -141,16 +168,16 @@ public class TestConcurrent extends TestCase {
|
||||
};
|
||||
threads[i].start();
|
||||
}
|
||||
|
||||
|
||||
dataSource.shrink();
|
||||
Assert.assertEquals(0, dataSource.getActiveCount());
|
||||
Assert.assertEquals(dataSource.getMinIdle(), dataSource.getPoolingCount());
|
||||
|
||||
|
||||
System.out.println(threadCount + "-threads start");
|
||||
startLatch.countDown();
|
||||
endLatch.await();
|
||||
endLatch.await();
|
||||
System.out.println(threadCount + "-threads complete");
|
||||
|
||||
|
||||
Assert.assertEquals(0, dataSource.getActiveCount());
|
||||
Assert.assertTrue(threadCount >= dataSource.getPoolingCount());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user