org.apache.commons.pool.impl
Class TestGenericObjectPool

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.commons.pool.TestObjectPool
              extended by org.apache.commons.pool.TestBaseObjectPool
                  extended by org.apache.commons.pool.impl.TestGenericObjectPool
All Implemented Interfaces:
junit.framework.Test

public class TestGenericObjectPool
extends TestBaseObjectPool

Version:
$Revision: 1205211 $ $Date: 2011-11-22 15:47:57 -0700 (Tue, 22 Nov 2011) $
Author:
Rodney Waldhoff, Dirk Verbeeck, Sandy McArthur

Nested Class Summary
 class TestGenericObjectPool.SimpleFactory
           
 
Field Summary
protected  GenericObjectPool pool
           
 
Constructor Summary
TestGenericObjectPool(String testName)
           
 
Method Summary
 void checkEvict(boolean lifo)
           
protected  Object getNthObject(int n)
           
protected  boolean isFifo()
           
protected  boolean isLifo()
           
protected  ObjectPool makeEmptyPool(int mincap)
           
protected  ObjectPool makeEmptyPool(PoolableObjectFactory factory)
          Create an ObjectPool with the specified factory.
 void runTestThreads(int numThreads, int iterations, int delay)
          Kicks off test threads, each of which will go through borrow-return cycles with random delay times <= delay in between.
 void setUp()
           
 void tearDown()
           
 void testAddObject()
           
 void testBorrowObjectFairness()
           
 void testBrokenFactoryShouldNotBlockPool()
          On first borrow, first object fails validation, second object is OK.
 void testConcurrentBorrowAndEvict()
           
 void testConstructors()
           
 void testDebugInfo()
           
 void testDefaultConfiguration()
           
 void testEvictAddObjects()
          Tests addObject contention between ensureMinIdle triggered by the Evictor with minIdle > 0 and borrowObject.
 void testEvictFIFO()
           
 void testEviction()
           
 void testEvictionOrder()
          Test to make sure evictor visits least recently used objects first, regardless of FIFO/LIFO JIRA: POOL-86
 void testEvictionSoftMinIdle()
           
 void testEvictionWithNegativeNumTests()
           
 void testEvictLIFO()
           
 void testEvictorVisiting()
          Verifies that the evictor visits objects in expected order and frequency.
 void testEvictWhileEmpty()
           
 void testExceptionOnActivateDuringBorrow()
           
 void testExceptionOnDestroyDuringBorrow()
           
 void testExceptionOnDestroyDuringReturn()
           
 void testExceptionOnPassivateDuringReturn()
           
 void testFIFO()
           
 void testInvalidWhenExhaustedAction()
           
 void testLIFO()
           
 void testMakeConcurrentWithReturn()
          Test the following scenario: Thread 1 borrows an instance Thread 2 starts to borrow another instance before thread 1 returns its instance 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.
 void testMaxActive()
           
 void testMaxActiveInvariant()
          Verifies that maxActive is not exceeded when factory destroyObject has high latency, testOnReturn is set and there is high incidence of validation failures.
 void testMaxActiveUnderLoad()
           
 void testMaxActiveZero()
           
 void testMaxIdle()
           
 void testMaxIdleZero()
           
 void testMaxWaitMultiThreaded()
           
 void testMinIdle()
           
 void testMinIdleMaxActive()
           
 void testNegativeMaxActive()
           
 void testSetConfig()
           
 void testSetFactoryWithActiveObjects()
           
 void testSetFactoryWithNoActiveObjects()
           
 void testSettersAndGetters()
           
 void testStartAndStopEvictor()
           
 void testThreaded1()
           
 void testTimeoutNoLeak()
           
 void testWhenExhaustedBlock()
           
 void testWhenExhaustedBlockClosePool()
           
 void testWhenExhaustedBlockInterupt()
           
 void testWhenExhaustedFail()
           
 void testWhenExhaustedGrow()
           
 
Methods inherited from class org.apache.commons.pool.TestBaseObjectPool
testBaseAddObject, testBaseBorrow, testBaseBorrowReturn, testBaseClear, testBaseClosePool, testBaseInvalidateObject, testBaseNumActiveNumIdle, testClose, testUnsupportedOperations
 
Methods inherited from class org.apache.commons.pool.TestObjectPool
testClosedPoolBehavior, testPOFAddObjectUsage, testPOFBorrowObjectUsages, testPOFClearUsages, testPOFCloseUsages, testPOFInvalidateObjectUsages, testPOFReturnObjectUsages, testSetFactory, testToString
 
Methods inherited from class junit.framework.TestCase
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pool

protected GenericObjectPool pool
Constructor Detail

TestGenericObjectPool

public TestGenericObjectPool(String testName)
Method Detail

makeEmptyPool

protected ObjectPool makeEmptyPool(int mincap)
Overrides:
makeEmptyPool in class TestBaseObjectPool

makeEmptyPool

protected ObjectPool makeEmptyPool(PoolableObjectFactory factory)
Description copied from class: TestObjectPool
Create an ObjectPool with the specified factory. The pool should be in a default configuration and conform to the expected behaviors described in ObjectPool. Generally speaking there should be no limits on the various object counts.

Overrides:
makeEmptyPool in class TestBaseObjectPool

getNthObject

protected Object getNthObject(int n)
Overrides:
getNthObject in class TestBaseObjectPool

setUp

public void setUp()
           throws Exception
Overrides:
setUp in class junit.framework.TestCase
Throws:
Exception

tearDown

public void tearDown()
              throws Exception
Overrides:
tearDown in class junit.framework.TestCase
Throws:
Exception

testWhenExhaustedGrow

public void testWhenExhaustedGrow()
                           throws Exception
Throws:
Exception

testWhenExhaustedFail

public void testWhenExhaustedFail()
                           throws Exception
Throws:
Exception

testWhenExhaustedBlock

public void testWhenExhaustedBlock()
                            throws Exception
Throws:
Exception

testWhenExhaustedBlockInterupt

public void testWhenExhaustedBlockInterupt()
                                    throws Exception
Throws:
Exception

testWhenExhaustedBlockClosePool

public void testWhenExhaustedBlockClosePool()
                                     throws Exception
Throws:
Exception

testEvictWhileEmpty

public void testEvictWhileEmpty()
                         throws Exception
Throws:
Exception

testEvictAddObjects

public void testEvictAddObjects()
                         throws Exception
Tests addObject contention between ensureMinIdle triggered by the Evictor with minIdle > 0 and borrowObject.

Throws:
Exception

testEvictLIFO

public void testEvictLIFO()
                   throws Exception
Throws:
Exception

testEvictFIFO

public void testEvictFIFO()
                   throws Exception
Throws:
Exception

checkEvict

public void checkEvict(boolean lifo)
                throws Exception
Throws:
Exception

testEvictionOrder

public void testEvictionOrder()
                       throws Exception
Test to make sure evictor visits least recently used objects first, regardless of FIFO/LIFO JIRA: POOL-86

Throws:
Exception

testEvictorVisiting

public void testEvictorVisiting()
                         throws Exception
Verifies that the evictor visits objects in expected order and frequency.

Throws:
Exception

testExceptionOnPassivateDuringReturn

public void testExceptionOnPassivateDuringReturn()
                                          throws Exception
Throws:
Exception

testExceptionOnDestroyDuringBorrow

public void testExceptionOnDestroyDuringBorrow()
                                        throws Exception
Throws:
Exception

testExceptionOnDestroyDuringReturn

public void testExceptionOnDestroyDuringReturn()
                                        throws Exception
Throws:
Exception

testExceptionOnActivateDuringBorrow

public void testExceptionOnActivateDuringBorrow()
                                         throws Exception
Throws:
Exception

testSetFactoryWithActiveObjects

public void testSetFactoryWithActiveObjects()
                                     throws Exception
Throws:
Exception

testSetFactoryWithNoActiveObjects

public void testSetFactoryWithNoActiveObjects()
                                       throws Exception
Throws:
Exception

testNegativeMaxActive

public void testNegativeMaxActive()
                           throws Exception
Throws:
Exception

testMaxIdle

public void testMaxIdle()
                 throws Exception
Throws:
Exception

testMaxIdleZero

public void testMaxIdleZero()
                     throws Exception
Throws:
Exception

testMaxActive

public void testMaxActive()
                   throws Exception
Throws:
Exception

testTimeoutNoLeak

public void testTimeoutNoLeak()
                       throws Exception
Throws:
Exception

testMaxActiveZero

public void testMaxActiveZero()
                       throws Exception
Throws:
Exception

testMaxActiveUnderLoad

public void testMaxActiveUnderLoad()

testInvalidWhenExhaustedAction

public void testInvalidWhenExhaustedAction()
                                    throws Exception
Throws:
Exception

testSettersAndGetters

public void testSettersAndGetters()
                           throws Exception
Throws:
Exception

testDefaultConfiguration

public void testDefaultConfiguration()
                              throws Exception
Throws:
Exception

testConstructors

public void testConstructors()
                      throws Exception
Throws:
Exception

testSetConfig

public void testSetConfig()
                   throws Exception
Throws:
Exception

testDebugInfo

public void testDebugInfo()
                   throws Exception
Throws:
Exception

testStartAndStopEvictor

public void testStartAndStopEvictor()
                             throws Exception
Throws:
Exception

testEvictionWithNegativeNumTests

public void testEvictionWithNegativeNumTests()
                                      throws Exception
Throws:
Exception

testEviction

public void testEviction()
                  throws Exception
Throws:
Exception

testEvictionSoftMinIdle

public void testEvictionSoftMinIdle()
                             throws Exception
Throws:
Exception

testMinIdle

public void testMinIdle()
                 throws Exception
Throws:
Exception

testMinIdleMaxActive

public void testMinIdleMaxActive()
                          throws Exception
Throws:
Exception

runTestThreads

public void runTestThreads(int numThreads,
                           int iterations,
                           int delay)
Kicks off test threads, each of which will go through borrow-return cycles with random delay times <= delay in between.


testThreaded1

public void testThreaded1()
                   throws Exception
Throws:
Exception

testMaxActiveInvariant

public void testMaxActiveInvariant()
                            throws Exception
Verifies that maxActive is not exceeded when factory destroyObject has high latency, testOnReturn is set and there is high incidence of validation failures.

Throws:
Exception

testConcurrentBorrowAndEvict

public void testConcurrentBorrowAndEvict()
                                  throws Exception
Throws:
Exception

testFIFO

public void testFIFO()
              throws Exception
Throws:
Exception

testLIFO

public void testLIFO()
              throws Exception
Throws:
Exception

testAddObject

public void testAddObject()
                   throws Exception
Throws:
Exception

isLifo

protected boolean isLifo()
Overrides:
isLifo in class TestBaseObjectPool

isFifo

protected boolean isFifo()
Overrides:
isFifo in class TestBaseObjectPool

testBorrowObjectFairness

public void testBorrowObjectFairness()

testBrokenFactoryShouldNotBlockPool

public void testBrokenFactoryShouldNotBlockPool()
On first borrow, first object fails validation, second object is OK. Subsequent borrows are OK. This was POOL-152.


testMaxWaitMultiThreaded

public void testMaxWaitMultiThreaded()
                              throws Exception
Throws:
Exception

testMakeConcurrentWithReturn

public void testMakeConcurrentWithReturn()
                                  throws Exception
Test the following scenario: Thread 1 borrows an instance Thread 2 starts to borrow another instance before thread 1 returns its instance 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.

Throws:
Exception


Copyright © 2001-2014 The Apache Software Foundation. All Rights Reserved.