org.apache.commons.pool.impl
Class TestStackObjectPool

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.TestStackObjectPool
All Implemented Interfaces:
junit.framework.Test

public class TestStackObjectPool
extends TestBaseObjectPool

Version:
$Revision: 960644 $ $Date: 2010-07-05 10:15:07 -0700 (Mon, 05 Jul 2010) $
Author:
Rodney Waldhoff, Dirk Verbeeck, Sandy McArthur

Constructor Summary
TestStackObjectPool(String testName)
           
 
Method Summary
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 testBorrowFromEmptyPoolWithNullFactory()
          Deprecated. - to be removed in pool 2.0
 void testBorrowReturnWithSometimesInvalidObjects()
          Verifies that validation and passivation failures returning objects are handled properly - instances destroyed and not returned to the pool, but no exceptions propagated.
 void testBorrowWithSometimesInvalidObjects()
          Verifies that validation failures when borrowing newly created instances from the pool result in NoSuchElementExceptions and passivation failures result in instances not being returned to the pool.
 void testCanResetFactoryWithoutActiveObjects()
          Deprecated. - to be removed in pool 2.0
 void testCantResetFactoryWithActiveObjects()
          Deprecated. - to be removed in pool 2.0
 void testClose()
          Verifies close contract - idle instances are destroyed, returning instances are destroyed, add/borrowObject throw IllegalStateException.
 void testExceptionOnActivate()
          Verifies that exceptions thrown by factory activate method are not propagated to the caller.
 void testExceptionOnDestroy()
          Verifies that exceptions thrown by factory destroy are swallowed by both addObject and returnObject.
 void testExceptionOnMake()
          Verifies that exceptions thrown by makeObject are propagated.
 void testExceptionOnPassivate()
          Verifies that addObject propagates exceptions thrown by factory passivate, but returnObject swallows these.
 void testExceptionOnValidate()
          Verifies that validation exceptions always propagate
 void testIdleCap()
           
 void testInitIdleCapacityExceeded()
          Verifies that initIdleCapacity is not a hard limit, but maxIdle is.
 void testMakeNull()
          Verifies NoSuchElementException when the factory returns a null object in borrowObject
 void testMaxIdleInitCapacityOutOfRange()
          Verify that out of range constructor arguments are ignored.
 void testPoolWithNullFactory()
          Deprecated. - to be removed in pool 2.0
 void testReturnObjectDiscardOrder()
          Verifies that when returning objects cause maxSleeping exceeded, oldest instances are destroyed to make room for returning objects.
 void testSetFactory()
          Deprecated. - to be removed in pool 2.0
 void testVariousConstructors()
           
 
Methods inherited from class org.apache.commons.pool.TestBaseObjectPool
testBaseAddObject, testBaseBorrow, testBaseBorrowReturn, testBaseClear, testBaseClosePool, testBaseInvalidateObject, testBaseNumActiveNumIdle, testUnsupportedOperations
 
Methods inherited from class org.apache.commons.pool.TestObjectPool
testClosedPoolBehavior, testPOFAddObjectUsage, testPOFBorrowObjectUsages, testPOFClearUsages, testPOFCloseUsages, testPOFInvalidateObjectUsages, testPOFReturnObjectUsages, 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, setUp, tearDown, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestStackObjectPool

public TestStackObjectPool(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

testIdleCap

public void testIdleCap()
                 throws Exception
Throws:
Exception

testPoolWithNullFactory

public void testPoolWithNullFactory()
                             throws Exception
Deprecated. - to be removed in pool 2.0

Throws:
Exception

testBorrowFromEmptyPoolWithNullFactory

public void testBorrowFromEmptyPoolWithNullFactory()
                                            throws Exception
Deprecated. - to be removed in pool 2.0

Throws:
Exception

testSetFactory

public void testSetFactory()
                    throws Exception
Deprecated. - to be removed in pool 2.0

Overrides:
testSetFactory in class TestObjectPool
Throws:
Exception

testCantResetFactoryWithActiveObjects

public void testCantResetFactoryWithActiveObjects()
                                           throws Exception
Deprecated. - to be removed in pool 2.0

Throws:
Exception

testCanResetFactoryWithoutActiveObjects

public void testCanResetFactoryWithoutActiveObjects()
                                             throws Exception
Deprecated. - to be removed in pool 2.0

Throws:
Exception

testBorrowWithSometimesInvalidObjects

public void testBorrowWithSometimesInvalidObjects()
                                           throws Exception
Verifies that validation failures when borrowing newly created instances from the pool result in NoSuchElementExceptions and passivation failures result in instances not being returned to the pool.

Throws:
Exception

testBorrowReturnWithSometimesInvalidObjects

public void testBorrowReturnWithSometimesInvalidObjects()
                                                 throws Exception
Verifies that validation and passivation failures returning objects are handled properly - instances destroyed and not returned to the pool, but no exceptions propagated.

Throws:
Exception

testVariousConstructors

public void testVariousConstructors()
                             throws Exception
Throws:
Exception

testMaxIdleInitCapacityOutOfRange

public void testMaxIdleInitCapacityOutOfRange()
                                       throws Exception
Verify that out of range constructor arguments are ignored.

Throws:
Exception

testReturnObjectDiscardOrder

public void testReturnObjectDiscardOrder()
                                  throws Exception
Verifies that when returning objects cause maxSleeping exceeded, oldest instances are destroyed to make room for returning objects.

Throws:
Exception

testExceptionOnActivate

public void testExceptionOnActivate()
                             throws Exception
Verifies that exceptions thrown by factory activate method are not propagated to the caller. Objects that throw on activate are destroyed and if none succeed, the caller gets NoSuchElementException.

Throws:
Exception

testExceptionOnDestroy

public void testExceptionOnDestroy()
                            throws Exception
Verifies that exceptions thrown by factory destroy are swallowed by both addObject and returnObject.

Throws:
Exception

testExceptionOnPassivate

public void testExceptionOnPassivate()
                              throws Exception
Verifies that addObject propagates exceptions thrown by factory passivate, but returnObject swallows these.

Throws:
Exception

testExceptionOnValidate

public void testExceptionOnValidate()
                             throws Exception
Verifies that validation exceptions always propagate

Throws:
Exception

testExceptionOnMake

public void testExceptionOnMake()
                         throws Exception
Verifies that exceptions thrown by makeObject are propagated.

Throws:
Exception

testMakeNull

public void testMakeNull()
                  throws Exception
Verifies NoSuchElementException when the factory returns a null object in borrowObject

Throws:
Exception

testInitIdleCapacityExceeded

public void testInitIdleCapacityExceeded()
                                  throws Exception
Verifies that initIdleCapacity is not a hard limit, but maxIdle is.

Throws:
Exception

testClose

public void testClose()
               throws Exception
Verifies close contract - idle instances are destroyed, returning instances are destroyed, add/borrowObject throw IllegalStateException.

Overrides:
testClose in class TestBaseObjectPool
Throws:
Exception

isLifo

protected boolean isLifo()
Overrides:
isLifo in class TestBaseObjectPool

isFifo

protected boolean isFifo()
Overrides:
isFifo in class TestBaseObjectPool


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