From b6adf85ccab735aed4a56414526c63b7d46803e8 Mon Sep 17 00:00:00 2001 From: wenshao Date: Tue, 23 Oct 2012 20:54:03 +0800 Subject: [PATCH] add lock fair testcase --- .../alibaba/druid/bvt/pool/LockFairTest.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/test/java/com/alibaba/druid/bvt/pool/LockFairTest.java diff --git a/src/test/java/com/alibaba/druid/bvt/pool/LockFairTest.java b/src/test/java/com/alibaba/druid/bvt/pool/LockFairTest.java new file mode 100644 index 0000000000..7193efbc2b --- /dev/null +++ b/src/test/java/com/alibaba/druid/bvt/pool/LockFairTest.java @@ -0,0 +1,29 @@ +package com.alibaba.druid.bvt.pool; + +import java.util.concurrent.locks.ReentrantLock; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import com.alibaba.druid.pool.DruidDataSource; +import com.alibaba.druid.util.JdbcUtils; + +public class LockFairTest extends TestCase { + + private DruidDataSource dataSource; + + protected void setUp() throws Exception { + dataSource = new DruidDataSource(); + } + + protected void tearDown() throws Exception { + JdbcUtils.close(dataSource); + } + + public void test_fair() throws Exception { + Assert.assertEquals(false, ((ReentrantLock)dataSource.getLock()).isFair()); + dataSource.setMaxWait(100); + + Assert.assertEquals(true, ((ReentrantLock)dataSource.getLock()).isFair()); + } +}