You should probably use a constant instead of repeating 60000 for each method.
Gary -----Original Message----- From: s...@apache.org [mailto:s...@apache.org] Sent: Monday, September 12, 2011 15:22 PM To: comm...@commons.apache.org Subject: svn commit: r1169883 - in /commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl: TestGenericKeyedObjectPool.java TestGenericObjectPool.java Author: sebb Date: Mon Sep 12 19:21:48 2011 New Revision: 1169883 URL: http://svn.apache.org/viewvc?rev=1169883&view=rev Log: Add some guard timers (may need to be adjusted) Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java?rev=1169883&r1=1169882&r2=1169883&view=diff ============================================================================== --- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java (original) +++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/Tes +++ tGenericKeyedObjectPool.java Mon Sep 12 19:21:48 2011 @@ -113,7 +113,7 @@ public class TestGenericKeyedObjectPool pool = null; } - @Test + @Test(timeout=60000) public void testNegativeMaxTotalPerKey() throws Exception { pool.setMaxTotalPerKey(-1); pool.setBlockWhenExhausted(false); @@ -122,7 +122,7 @@ public class TestGenericKeyedObjectPool pool.returnObject("",obj); } - @Test + @Test(timeout=60000) public void testNumActiveNumIdle2() throws Exception { assertEquals(0,pool.getNumActive()); assertEquals(0,pool.getNumIdle()); @@ -172,7 +172,7 @@ public class TestGenericKeyedObjectPool assertEquals(2,pool.getNumIdle("B")); } - @Test + @Test(timeout=60000) public void testMaxIdle() throws Exception { pool.setMaxTotalPerKey(100); pool.setMaxIdlePerKey(8); @@ -207,7 +207,7 @@ public class TestGenericKeyedObjectPool } - @Test + @Test(timeout=60000) public void testMaxTotalPerKey() throws Exception { pool.setMaxTotalPerKey(3); pool.setBlockWhenExhausted(false); @@ -223,7 +223,7 @@ public class TestGenericKeyedObjectPool } } - @Test + @Test(timeout=60000) public void testMaxTotalPerKeyZero() throws Exception { pool.setMaxTotalPerKey(0); pool.setBlockWhenExhausted(false); @@ -236,7 +236,7 @@ public class TestGenericKeyedObjectPool } } - @Test + @Test(timeout=60000) public void testMaxTotal() throws Exception { pool.setMaxTotalPerKey(2); pool.setMaxTotal(3); @@ -278,7 +278,7 @@ public class TestGenericKeyedObjectPool pool.getMaxTotal()); } - @Test + @Test(timeout=60000) public void testMaxTotalZero() throws Exception { pool.setMaxTotal(0); pool.setBlockWhenExhausted(false); @@ -291,7 +291,7 @@ public class TestGenericKeyedObjectPool } } - @Test + @Test(timeout=60000) public void testMaxTotalLRU() throws Exception { pool.setMaxTotalPerKey(2); pool.setMaxTotal(3); @@ -341,7 +341,7 @@ public class TestGenericKeyedObjectPool assertSame(o4, o7); } - @Test + @Test(timeout=60000) public void testSettersAndGetters() throws Exception { GenericKeyedObjectPool<String,String> pool = new GenericKeyedObjectPool<String,String>( @@ -396,7 +396,7 @@ public class TestGenericKeyedObjectPool } } - @Test + @Test(timeout=60000) public void testEviction() throws Exception { pool.setMaxIdlePerKey(500); pool.setMaxTotalPerKey(500); @@ -446,7 +446,7 @@ public class TestGenericKeyedObjectPool assertEquals("Should be zero idle, found " + pool.getNumIdle(""),0,pool.getNumIdle("")); } - @Test + @Test(timeout=60000) public void testEviction2() throws Exception { pool.setMaxIdlePerKey(500); pool.setMaxTotalPerKey(500); @@ -517,7 +517,7 @@ public class TestGenericKeyedObjectPool } } - @Test + @Test(timeout=60000) public void testThreaded1() throws Exception { pool.setMaxTotalPerKey(15); pool.setMaxIdlePerKey(15); @@ -530,7 +530,7 @@ public class TestGenericKeyedObjectPool * has high latency, testOnReturn is set and there is high incidence of * validation failures. */ - @Test + @Test(timeout=60000) public void testMaxTotalInvariant() throws Exception { int maxTotal = 15; SimpleFactory<String> factory = new SimpleFactory<String>(); @@ -546,7 +546,7 @@ public class TestGenericKeyedObjectPool runTestThreads(5, 10, 50, pool); } - @Test + @Test(timeout=60000) public void testMinIdle() throws Exception { pool.setMaxIdlePerKey(500); pool.setMinIdlePerKey(5); @@ -586,7 +586,7 @@ public class TestGenericKeyedObjectPool assertTrue("Should be 10 idle, found " + pool.getNumIdle(),pool.getNumIdle() == 10); } - @Test + @Test(timeout=60000) public void testMinIdleMaxTotalPerKey() throws Exception { pool.setMaxIdlePerKey(500); pool.setMinIdlePerKey(5); @@ -639,7 +639,7 @@ public class TestGenericKeyedObjectPool assertTrue("Should be 10 idle, found " + pool.getNumIdle(),pool.getNumIdle() == 10); } - @Test + @Test(timeout=60000) public void testMinIdleNoPreparePool() throws Exception { pool.setMaxIdlePerKey(500); pool.setMinIdlePerKey(5); @@ -663,7 +663,7 @@ public class TestGenericKeyedObjectPool assertTrue("Should be 5 idle, found " + pool.getNumIdle(),pool.getNumIdle() == 5); } - @Test + @Test(timeout=60000) public void testFIFO() throws Exception { pool.setLifo(false); final String key = "key"; @@ -680,7 +680,7 @@ public class TestGenericKeyedObjectPool assertEquals("new-4", "key4", pool.borrowObject(key)); } - @Test + @Test(timeout=60000) public void testLIFO() throws Exception { pool.setLifo(true); final String key = "key"; @@ -703,7 +703,7 @@ public class TestGenericKeyedObjectPool * * JIRA: POOL-86 */ - @Test + @Test(timeout=60000) public void testEvictionOrder() throws Exception { checkEvictionOrder(false); checkEvictionOrder(true); @@ -826,7 +826,7 @@ public class TestGenericKeyedObjectPool * Verifies that the evictor visits objects in expected order * and frequency. */ - @Test + @Test(timeout=60000) public void testEvictorVisiting() throws Exception { checkEvictorVisiting(true); checkEvictorVisiting(false); @@ -1000,7 +1000,7 @@ public class TestGenericKeyedObjectPool } } - @Test + @Test(timeout=60000) public void testConstructors() { // Make constructor arguments all different from defaults @@ -1074,7 +1074,7 @@ public class TestGenericKeyedObjectPool assertEquals(lifo, pool.getLifo()); } - @Test + @Test(timeout=60000) public void testExceptionOnPassivateDuringReturn() throws Exception { SimpleFactory<String> factory = new SimpleFactory<String>(); GenericKeyedObjectPool<String,String> pool = @@ -1086,7 +1086,7 @@ public class TestGenericKeyedObjectPool pool.close(); } - @Test + @Test(timeout=60000) public void testExceptionOnDestroyDuringBorrow() throws Exception { SimpleFactory<String> factory = new SimpleFactory<String>(); factory.setThrowExceptionOnDestroy(true); @@ -1108,7 +1108,7 @@ public class TestGenericKeyedObjectPool assertEquals(0, pool.getNumIdle()); } - @Test + @Test(timeout=60000) public void testExceptionOnDestroyDuringReturn() throws Exception { SimpleFactory<String> factory = new SimpleFactory<String>(); factory.setThrowExceptionOnDestroy(true); @@ -1126,7 +1126,7 @@ public class TestGenericKeyedObjectPool assertEquals(0, pool.getNumIdle()); } - @Test + @Test(timeout=60000) public void testExceptionOnActivateDuringBorrow() throws Exception { SimpleFactory<String> factory = new SimpleFactory<String>(); GenericKeyedObjectPool<String,String> pool = @@ -1161,7 +1161,7 @@ public class TestGenericKeyedObjectPool assertEquals(0, pool.getNumIdle()); } - @Test + @Test(timeout=60000) public void testBlockedKeyDoesNotBlockPool() throws Exception { SimpleFactory<String> factory = new SimpleFactory<String>(); GenericKeyedObjectPool<String,String> pool = @@ -1203,7 +1203,7 @@ public class TestGenericKeyedObjectPool * TestSharedPoolDataSource.testMultipleThreads2() * Let's see if the this fails on Continuum too! */ - @Test + @Test(timeout=60000) public void testMaxWaitMultiThreaded() throws Exception { final long maxWait = 500; // wait for connection final long holdTime = 4 * maxWait; // how long to hold connection @@ -1259,7 +1259,7 @@ public class TestGenericKeyedObjectPool /** * Test case for POOL-180. */ - @Test + @Test(timeout=60000) public void testMaxActivePerKeyExceeded() { WaiterFactory<String> factory = new WaiterFactory<String>(0, 20, 0, 0, 0, 0, 8, 5, 0); // TODO Fix this. Can't use local pool since runTestThreads uses the @@ -1277,7 +1277,7 @@ public class TestGenericKeyedObjectPool /** * Test to make sure that clearOldest does not destroy instances that have been checked out. */ - @Test + @Test(timeout=60000) public void testClearOldest() throws Exception { // Make destroy have some latency so clearOldest takes some time WaiterFactory<String> factory = new WaiterFactory<String>(0, 20, 0, 0, 0, 0, 50, 5, 0); Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java?rev=1169883&r1=1169882&r2=1169883&view=diff ============================================================================== --- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java (original) +++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/Tes +++ tGenericObjectPool.java Mon Sep 12 19:21:48 2011 @@ -78,7 +78,7 @@ public class TestGenericObjectPool exten pool = null; } - @Test + @Test(timeout=60000) public void testWhenExhaustedFail() throws Exception { pool.setMaxTotal(1); pool.setBlockWhenExhausted(false); @@ -95,7 +95,7 @@ public class TestGenericObjectPool exten pool.close(); } - @Test + @Test(timeout=60000) public void testWhenExhaustedBlock() throws Exception { pool.setMaxTotal(1); pool.setBlockWhenExhausted(true); @@ -112,7 +112,7 @@ public class TestGenericObjectPool exten pool.close(); } - @Test + @Test(timeout=60000) public void testWhenExhaustedBlockInterupt() throws Exception { pool.setMaxTotal(1); pool.setBlockWhenExhausted(true); @@ -153,14 +153,14 @@ public class TestGenericObjectPool exten } - @Test + @Test(timeout=60000) public void testEvictWhileEmpty() throws Exception { pool.evict(); pool.evict(); pool.close(); } - @Test + @Test(timeout=60000) /** * Tests addObject contention between ensureMinIdle triggered by * the Evictor with minIdle > 0 and borrowObject. @@ -185,12 +185,12 @@ public class TestGenericObjectPool exten pool.close(); } - @Test + @Test(timeout=60000) public void testEvictLIFO() throws Exception { checkEvict(true); } - @Test + @Test(timeout=60000) public void testEvictFIFO() throws Exception { checkEvict(false); } @@ -228,7 +228,7 @@ public class TestGenericObjectPool exten * * JIRA: POOL-86 */ - @Test + @Test(timeout=60000) public void testEvictionOrder() throws Exception { checkEvictionOrder(false); checkEvictionOrder(true); @@ -396,7 +396,7 @@ public class TestGenericObjectPool exten } } - @Test + @Test(timeout=60000) public void testExceptionOnPassivateDuringReturn() throws Exception { SimpleFactory factory = new SimpleFactory(); GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory); @@ -407,7 +407,7 @@ public class TestGenericObjectPool exten pool.close(); } - @Test + @Test(timeout=60000) public void testExceptionOnDestroyDuringBorrow() throws Exception { SimpleFactory factory = new SimpleFactory(); factory.setThrowExceptionOnDestroy(true); @@ -425,7 +425,7 @@ public class TestGenericObjectPool exten assertEquals(0, pool.getNumIdle()); } - @Test + @Test(timeout=60000) public void testExceptionOnDestroyDuringReturn() throws Exception { SimpleFactory factory = new SimpleFactory(); factory.setThrowExceptionOnDestroy(true); @@ -439,7 +439,7 @@ public class TestGenericObjectPool exten assertEquals(0, pool.getNumIdle()); } - @Test + @Test(timeout=60000) public void testExceptionOnActivateDuringBorrow() throws Exception { SimpleFactory factory = new SimpleFactory(); GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory); @@ -469,7 +469,7 @@ public class TestGenericObjectPool exten assertEquals(0, pool.getNumIdle()); } - @Test + @Test(timeout=60000) public void testNegativeMaxTotal() throws Exception { pool.setMaxTotal(-1); pool.setBlockWhenExhausted(false); @@ -478,7 +478,7 @@ public class TestGenericObjectPool exten pool.returnObject(obj); } - @Test + @Test(timeout=60000) public void testMaxIdle() throws Exception { pool.setMaxTotal(100); pool.setMaxIdle(8); @@ -495,7 +495,7 @@ public class TestGenericObjectPool exten } } - @Test + @Test(timeout=60000) public void testMaxIdleZero() throws Exception { pool.setMaxTotal(100); pool.setMaxIdle(0); @@ -512,7 +512,7 @@ public class TestGenericObjectPool exten } } - @Test + @Test(timeout=60000) public void testMaxTotal() throws Exception { pool.setMaxTotal(3); pool.setBlockWhenExhausted(false); @@ -528,7 +528,7 @@ public class TestGenericObjectPool exten } } - @Test + @Test(timeout=60000) public void testTimeoutNoLeak() throws Exception { pool.setMaxTotal(2); pool.setMaxWait(10); @@ -548,7 +548,7 @@ public class TestGenericObjectPool exten obj2 = pool.borrowObject(); } - @Test + @Test(timeout=60000) public void testMaxTotalZero() throws Exception { pool.setMaxTotal(0); pool.setBlockWhenExhausted(false); @@ -561,7 +561,7 @@ public class TestGenericObjectPool exten } } - @Test + @Test(timeout=60000) public void testMaxTotalUnderLoad() { // Config int numThreads = 199; // And main thread makes a round 200. @@ -640,7 +640,7 @@ public class TestGenericObjectPool exten } } - @Test + @Test(timeout=60000) public void testSettersAndGetters() throws Exception { GenericObjectPool<Object> pool = new GenericObjectPool<Object>(new SimpleFactory()); @@ -698,7 +698,7 @@ public class TestGenericObjectPool exten } } - @Test + @Test(timeout=60000) public void testDefaultConfiguration() throws Exception { SimpleFactory factory = new SimpleFactory(); GenericObjectPool<Object> pool = @@ -706,7 +706,7 @@ public class TestGenericObjectPool exten assertConfiguration(new GenericObjectPoolConfig<Object>(),pool); } - @Test + @Test(timeout=60000) public void testSetConfig() throws Exception { GenericObjectPoolConfig<Object> expected = new GenericObjectPoolConfig<Object>(); @@ -727,7 +727,7 @@ public class TestGenericObjectPool exten assertConfiguration(expected,pool); } - @Test + @Test(timeout=60000) public void testDebugInfo() throws Exception { GenericObjectPool<Object> pool = new GenericObjectPool<Object>(new SimpleFactory()); @@ -739,7 +739,7 @@ public class TestGenericObjectPool exten assertNotNull(pool.debugInfo()); } - @Test + @Test(timeout=60000) public void testStartAndStopEvictor() throws Exception { // set up pool without evictor pool.setMaxIdle(6); @@ -776,7 +776,7 @@ public class TestGenericObjectPool exten } } - @Test + @Test(timeout=60000) public void testEvictionWithNegativeNumTests() throws Exception { // when numTestsPerEvictionRun is negative, it represents a fraction of the idle objects to test pool.setMaxIdle(6); @@ -803,7 +803,7 @@ public class TestGenericObjectPool exten assertEquals("Should be zero idle, found " + pool.getNumIdle(),0,pool.getNumIdle()); } - @Test + @Test(timeout=60000) public void testEviction() throws Exception { pool.setMaxIdle(500); pool.setMaxTotal(500); @@ -854,7 +854,7 @@ public class TestGenericObjectPool exten assertEquals("Should be zero idle, found " + pool.getNumIdle(),0,pool.getNumIdle()); } - @Test + @Test(timeout=60000) public void testEvictionSoftMinIdle() throws Exception { class TimeTest extends BasePoolableObjectFactory<TimeTest> { private final long createTime; @@ -902,7 +902,7 @@ public class TestGenericObjectPool exten assertEquals("Idle count different than expected.", 0, pool.getNumIdle()); } - @Test + @Test(timeout=60000) public void testEvictionInvalid() throws Exception { class InvalidFactory extends BasePoolableObjectFactory<Object> { @@ -966,7 +966,7 @@ public class TestGenericObjectPool exten assertEquals("Total count different than expected.", 0, pool.getNumActive()); } - @Test + @Test(timeout=60000) public void testMinIdle() throws Exception { pool.setMaxIdle(500); pool.setMinIdle(5); @@ -1000,7 +1000,7 @@ public class TestGenericObjectPool exten assertTrue("Should be 10 idle, found " + pool.getNumIdle(),pool.getNumIdle() == 10); } - @Test + @Test(timeout=60000) public void testMinIdleMaxTotal() throws Exception { pool.setMaxIdle(500); pool.setMinIdle(5); @@ -1073,7 +1073,7 @@ public class TestGenericObjectPool exten } } - @Test + @Test(timeout=60000) public void testThreaded1() throws Exception { pool.setMaxTotal(15); pool.setMaxIdle(15); @@ -1086,7 +1086,7 @@ public class TestGenericObjectPool exten * has high latency, testOnReturn is set and there is high incidence of * validation failures. */ - @Test + @Test(timeout=60000) public void testMaxTotalInvariant() throws Exception { int maxTotal = 15; SimpleFactory factory = new SimpleFactory(); @@ -1102,7 +1102,7 @@ public class TestGenericObjectPool exten runTestThreads(5, 10, 50); } - @Test + @Test(timeout=60000) public void testConcurrentBorrowAndEvict() throws Exception { pool.setMaxTotal(1); @@ -1241,7 +1241,7 @@ public class TestGenericObjectPool exten } } - @Test + @Test(timeout=60000) public void testFIFO() throws Exception { Object o = null; pool.setLifo(false); @@ -1258,7 +1258,7 @@ public class TestGenericObjectPool exten assertEquals("new-4", "4", pool.borrowObject()); } - @Test + @Test(timeout=60000) public void testLIFO() throws Exception { Object o = null; pool.setLifo(true); @@ -1275,7 +1275,7 @@ public class TestGenericObjectPool exten assertEquals("new-4", "4", pool.borrowObject()); } - @Test + @Test(timeout=60000) public void testAddObject() throws Exception { assertEquals("should be zero idle", 0, pool.getNumIdle()); pool.addObject(); @@ -1486,7 +1486,7 @@ public class TestGenericObjectPool exten * enough margin for this to work correctly on most (all?) systems but be * aware of this if you see a failure of this test. */ - @Test + @Test(timeout=60000) public void testBorrowObjectFairness() { // Config @@ -1530,7 +1530,7 @@ public class TestGenericObjectPool exten * On first borrow, first object fails validation, second object is OK. * Subsequent borrows are OK. This was POOL-152. */ - @Test + @Test(timeout=60000) public void testBrokenFactoryShouldNotBlockPool() { int maxTotal = 1; @@ -1627,7 +1627,7 @@ public class TestGenericObjectPool exten * TestPerUserPoolDataSource.testMultipleThreads2() * Let's see if the this fails on Continuum too! */ - @Test + @Test(timeout=60000) public void testMaxWaitMultiThreaded() throws Exception { final long maxWait = 500; // wait for connection final long holdTime = 2 * maxWait; // how long to hold connection @@ -1683,7 +1683,7 @@ public class TestGenericObjectPool exten * Thread 1 returns its instance while thread 2 is validating its newly created instance * The test verifies that the instance created by Thread 2 is not leaked. */ - @Test + @Test(timeout=60000) public void testMakeConcurrentWithReturn() throws Exception { SimpleFactory factory = new SimpleFactory(); GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);