From 65e611dc1c19ccb3047375b1e6e08ac44c478638 Mon Sep 17 00:00:00 2001 From: wenshao Date: Sat, 3 Sep 2011 11:03:10 +0000 Subject: [PATCH] test git-svn-id: http://code.alibabatech.com/svn/druid/trunk@621 b9813039-fb51-4c41-a8b9-e21c2acb5095 --- .../druid/bvt/pool/TestConcurrent.java | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/alibaba/druid/bvt/pool/TestConcurrent.java b/src/test/java/com/alibaba/druid/bvt/pool/TestConcurrent.java index 0b0f6dbf7a..f4447814ff 100644 --- a/src/test/java/com/alibaba/druid/bvt/pool/TestConcurrent.java +++ b/src/test/java/com/alibaba/druid/bvt/pool/TestConcurrent.java @@ -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()); }