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()); + } +}