You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/04/24 22:11:00 UTC
svn commit: r1096372 - in
/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl:
TestStackKeyedObjectPool.java TestStackKeyedObjectPoolFactory.java
TestStackObjectPool.java TestStackObjectPoolFactory.java
Author: simonetripodi
Date: Sun Apr 24 20:11:00 2011
New Revision: 1096372
URL: http://svn.apache.org/viewvc?rev=1096372&view=rev
Log:
added generics to TestStack(Keyed)ObjectPool(Factory) test classes
Modified:
commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPool.java
commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPoolFactory.java
commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java
commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPoolFactory.java
Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPool.java?rev=1096372&r1=1096371&r2=1096372&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPool.java Sun Apr 24 20:11:00 2011
@@ -35,29 +35,34 @@ public class TestStackKeyedObjectPool ex
super(testName);
}
- protected KeyedObjectPool makeEmptyPool(int mincapacity) {
- StackKeyedObjectPool pool = new StackKeyedObjectPool(new SimpleFactory(),mincapacity);
+ @Override
+ protected KeyedObjectPool<Object,Object> makeEmptyPool(int mincapacity) {
+ StackKeyedObjectPool<Object,Object> pool = new StackKeyedObjectPool<Object,Object>(new SimpleFactory(),mincapacity);
return pool;
}
- protected KeyedObjectPool makeEmptyPool(KeyedPoolableObjectFactory factory) {
- return new StackKeyedObjectPool(factory);
+ @Override
+ protected KeyedObjectPool<Object,Object> makeEmptyPool(KeyedPoolableObjectFactory<Object,Object> factory) {
+ return new StackKeyedObjectPool<Object,Object>(factory);
}
+ @Override
protected Object getNthObject(Object key, int n) {
return String.valueOf(key) + String.valueOf(n);
}
+ @Override
protected Object makeKey(int n) {
return String.valueOf(n);
}
- private StackKeyedObjectPool pool = null;
+ private StackKeyedObjectPool<Object,Object> pool = null;
+ @Override
public void setUp() throws Exception {
super.setUp();
- pool = new StackKeyedObjectPool(
- new KeyedPoolableObjectFactory() {
+ pool = new StackKeyedObjectPool<Object,Object>(
+ new KeyedPoolableObjectFactory<Object,Object>() {
int counter = 0;
public Object makeObject(Object key) { return String.valueOf(key) + String.valueOf(counter++); }
public void destroyObject(Object key, Object obj) { }
@@ -69,6 +74,7 @@ public class TestStackKeyedObjectPool ex
}
+ @Override
public void tearDown() throws Exception {
super.tearDown();
pool = null;
@@ -131,7 +137,7 @@ public class TestStackKeyedObjectPool ex
}
public void testPoolWithNullFactory() throws Exception {
- KeyedObjectPool pool = new StackKeyedObjectPool(10);
+ KeyedObjectPool<String,Integer> pool = new StackKeyedObjectPool<String,Integer>(10);
for(int i=0;i<10;i++) {
pool.returnObject("X",new Integer(i));
}
@@ -139,7 +145,7 @@ public class TestStackKeyedObjectPool ex
Integer[] borrowed = new Integer[10];
BitSet found = new BitSet();
for(int i=0;i<10;i++) {
- borrowed[i] = (Integer)(pool.borrowObject("X"));
+ borrowed[i] = pool.borrowObject("X");
assertNotNull(borrowed);
assertTrue(!found.get(borrowed[i].intValue()));
found.set(borrowed[i].intValue());
@@ -156,33 +162,34 @@ public class TestStackKeyedObjectPool ex
public void testVariousConstructors() throws Exception {
{
- StackKeyedObjectPool pool = new StackKeyedObjectPool();
+ StackKeyedObjectPool<String,Integer> pool = new StackKeyedObjectPool<String,Integer>();
assertNotNull(pool);
}
{
- StackKeyedObjectPool pool = new StackKeyedObjectPool(10);
+ StackKeyedObjectPool<String,Integer> pool = new StackKeyedObjectPool<String,Integer>(10);
assertNotNull(pool);
}
{
- StackKeyedObjectPool pool = new StackKeyedObjectPool(10,5);
+ StackKeyedObjectPool<String,Integer> pool = new StackKeyedObjectPool<String,Integer>(10,5);
assertNotNull(pool);
}
{
- StackKeyedObjectPool pool = new StackKeyedObjectPool(null);
+ StackKeyedObjectPool<String,Integer> pool = new StackKeyedObjectPool<String,Integer>(null);
assertNotNull(pool);
}
{
- StackKeyedObjectPool pool = new StackKeyedObjectPool(null,10);
+ StackKeyedObjectPool<String,Integer> pool = new StackKeyedObjectPool<String,Integer>(null,10);
assertNotNull(pool);
}
{
- StackKeyedObjectPool pool = new StackKeyedObjectPool(null,10,5);
+ StackKeyedObjectPool<String,Integer> pool = new StackKeyedObjectPool<String,Integer>(null,10,5);
assertNotNull(pool);
}
}
+ @Override
public void testToString() throws Exception {
- StackKeyedObjectPool pool = new StackKeyedObjectPool(new SimpleFactory());
+ StackKeyedObjectPool<Object,Object> pool = new StackKeyedObjectPool<Object,Object>(new SimpleFactory());
assertNotNull(pool.toString());
Object obj = pool.borrowObject("key");
assertNotNull(pool.toString());
@@ -191,7 +198,7 @@ public class TestStackKeyedObjectPool ex
}
public void testBorrowFromEmptyPoolWithNullFactory() throws Exception {
- KeyedObjectPool pool = new StackKeyedObjectPool();
+ KeyedObjectPool<String,Object> pool = new StackKeyedObjectPool<String,Object>();
try {
pool.borrowObject("x");
fail("Expected NoSuchElementException");
@@ -201,7 +208,7 @@ public class TestStackKeyedObjectPool ex
}
public void testSetFactory() throws Exception {
- KeyedObjectPool pool = new StackKeyedObjectPool();
+ KeyedObjectPool<Object,Object> pool = new StackKeyedObjectPool<Object,Object>();
try {
pool.borrowObject("x");
fail("Expected NoSuchElementException");
@@ -215,7 +222,7 @@ public class TestStackKeyedObjectPool ex
}
public void testCantResetFactoryWithActiveObjects() throws Exception {
- KeyedObjectPool pool = new StackKeyedObjectPool();
+ KeyedObjectPool<Object,Object> pool = new StackKeyedObjectPool<Object,Object>();
pool.setFactory(new SimpleFactory());
Object obj = pool.borrowObject("x");
assertNotNull(obj);
@@ -229,7 +236,7 @@ public class TestStackKeyedObjectPool ex
}
public void testCanResetFactoryWithoutActiveObjects() throws Exception {
- KeyedObjectPool pool = new StackKeyedObjectPool();
+ KeyedObjectPool<Object,Object> pool = new StackKeyedObjectPool<Object,Object>();
{
pool.setFactory(new SimpleFactory());
Object obj = pool.borrowObject("x");
@@ -245,8 +252,8 @@ public class TestStackKeyedObjectPool ex
}
public void testBorrowReturnWithSometimesInvalidObjects() throws Exception {
- KeyedObjectPool pool = new StackKeyedObjectPool(
- new KeyedPoolableObjectFactory() {
+ KeyedObjectPool<Object,Object> pool = new StackKeyedObjectPool<Object,Object>(
+ new KeyedPoolableObjectFactory<Object,Object>() {
int counter = 0;
public Object makeObject(Object key) { return new Integer(counter++); }
public void destroyObject(Object key, Object obj) { }
@@ -301,11 +308,11 @@ public class TestStackKeyedObjectPool ex
assertEquals(new Integer(1), pool.borrowObject("key"));
}
- class SimpleFactory implements KeyedPoolableObjectFactory {
- HashMap map = new HashMap();
+ class SimpleFactory implements KeyedPoolableObjectFactory<Object,Object> {
+ HashMap<Object,Integer> map = new HashMap<Object,Integer>();
public Object makeObject(Object key) {
int counter = 0;
- Integer Counter = (Integer)(map.get(key));
+ Integer Counter = map.get(key);
if(null != Counter) {
counter = Counter.intValue();
}
@@ -318,10 +325,12 @@ public class TestStackKeyedObjectPool ex
public void passivateObject(Object key, Object obj) { }
}
+ @Override
protected boolean isLifo() {
return true;
}
+ @Override
protected boolean isFifo() {
return false;
}
Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPoolFactory.java?rev=1096372&r1=1096371&r2=1096372&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPoolFactory.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackKeyedObjectPoolFactory.java Sun Apr 24 20:11:00 2011
@@ -34,36 +34,37 @@ public class TestStackKeyedObjectPoolFac
super(name);
}
- protected KeyedObjectPoolFactory makeFactory(final KeyedPoolableObjectFactory objectFactory) throws UnsupportedOperationException {
- return new StackKeyedObjectPoolFactory(objectFactory);
+ @Override
+ protected KeyedObjectPoolFactory<Object,Object> makeFactory(final KeyedPoolableObjectFactory<Object,Object> objectFactory) throws UnsupportedOperationException {
+ return new StackKeyedObjectPoolFactory<Object,Object>(objectFactory);
}
public void testConstructors() throws Exception {
- StackKeyedObjectPoolFactory factory = new StackKeyedObjectPoolFactory();
+ StackKeyedObjectPoolFactory<Object,Object> factory = new StackKeyedObjectPoolFactory<Object,Object>();
factory.createPool().close();
- factory = new StackKeyedObjectPoolFactory(1);
- StackKeyedObjectPool pool = (StackKeyedObjectPool)factory.createPool();
+ factory = new StackKeyedObjectPoolFactory<Object,Object>(1);
+ StackKeyedObjectPool<Object,Object> pool = (StackKeyedObjectPool<Object,Object>)factory.createPool();
assertEquals(1,pool._maxSleeping);
pool.close();
- factory = new StackKeyedObjectPoolFactory(1, 2);
- pool = (StackKeyedObjectPool)factory.createPool();
+ factory = new StackKeyedObjectPoolFactory<Object,Object>(1, 2);
+ pool = (StackKeyedObjectPool<Object,Object>)factory.createPool();
assertEquals(1,pool._maxSleeping);
assertEquals(2,pool._initSleepingCapacity);
pool.close();
- factory = new StackKeyedObjectPoolFactory(createObjectFactory());
- pool = (StackKeyedObjectPool)factory.createPool();
+ factory = new StackKeyedObjectPoolFactory<Object,Object>(createObjectFactory());
+ pool = (StackKeyedObjectPool<Object,Object>)factory.createPool();
pool.close();
- factory = new StackKeyedObjectPoolFactory(createObjectFactory(), 1);
- pool = (StackKeyedObjectPool)factory.createPool();
+ factory = new StackKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1);
+ pool = (StackKeyedObjectPool<Object,Object>)factory.createPool();
assertEquals(1,pool._maxSleeping);
pool.close();
- factory = new StackKeyedObjectPoolFactory(createObjectFactory(), 1, 2);
- pool = (StackKeyedObjectPool)factory.createPool();
+ factory = new StackKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, 2);
+ pool = (StackKeyedObjectPool<Object,Object>)factory.createPool();
assertEquals(1,pool._maxSleeping);
assertEquals(2,pool._initSleepingCapacity);
pool.close();
Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java?rev=1096372&r1=1096371&r2=1096372&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPool.java Sun Apr 24 20:11:00 2011
@@ -38,20 +38,23 @@ public class TestStackObjectPool extends
super(testName);
}
- protected ObjectPool makeEmptyPool(int mincap) {
- return new StackObjectPool(new SimpleFactory());
+ @Override
+ protected ObjectPool<Object> makeEmptyPool(int mincap) {
+ return new StackObjectPool<Object>(new SimpleFactory());
}
- protected ObjectPool makeEmptyPool(final PoolableObjectFactory factory) {
- return new StackObjectPool(factory);
+ @Override
+ protected ObjectPool<Object> makeEmptyPool(final PoolableObjectFactory<Object> factory) {
+ return new StackObjectPool<Object>(factory);
}
+ @Override
protected Object getNthObject(int n) {
return String.valueOf(n);
}
public void testIdleCap() throws Exception {
- ObjectPool pool = makeEmptyPool(8);
+ ObjectPool<Object> pool = makeEmptyPool(8);
Object[] active = new Object[100];
for(int i=0;i<100;i++) {
active[i] = pool.borrowObject();
@@ -69,7 +72,7 @@ public class TestStackObjectPool extends
* @deprecated - to be removed in pool 2.0
*/
public void testPoolWithNullFactory() throws Exception {
- ObjectPool pool = new StackObjectPool(10);
+ ObjectPool<Integer> pool = new StackObjectPool<Integer>(10);
for(int i=0;i<10;i++) {
pool.returnObject(new Integer(i));
}
@@ -77,7 +80,7 @@ public class TestStackObjectPool extends
Integer[] borrowed = new Integer[10];
BitSet found = new BitSet();
for(int i=0;i<10;i++) {
- borrowed[i] = (Integer)(pool.borrowObject());
+ borrowed[i] = pool.borrowObject();
assertNotNull(borrowed);
assertTrue(!found.get(borrowed[i].intValue()));
found.set(borrowed[i].intValue());
@@ -95,7 +98,7 @@ public class TestStackObjectPool extends
* @deprecated - to be removed in pool 2.0
*/
public void testBorrowFromEmptyPoolWithNullFactory() throws Exception {
- ObjectPool pool = new StackObjectPool();
+ ObjectPool<Object> pool = new StackObjectPool<Object>();
try {
pool.borrowObject();
fail("Expected NoSuchElementException");
@@ -107,8 +110,9 @@ public class TestStackObjectPool extends
/**
* @deprecated - to be removed in pool 2.0
*/
+ @Override
public void testSetFactory() throws Exception {
- ObjectPool pool = new StackObjectPool();
+ ObjectPool<Object> pool = new StackObjectPool<Object>();
try {
pool.borrowObject();
fail("Expected NoSuchElementException");
@@ -125,7 +129,7 @@ public class TestStackObjectPool extends
* @deprecated - to be removed in pool 2.0
*/
public void testCantResetFactoryWithActiveObjects() throws Exception {
- ObjectPool pool = new StackObjectPool();
+ ObjectPool<Object> pool = new StackObjectPool<Object>();
pool.setFactory(new SimpleFactory());
Object obj = pool.borrowObject();
assertNotNull(obj);
@@ -142,7 +146,7 @@ public class TestStackObjectPool extends
* @deprecated - to be removed in pool 2.0
*/
public void testCanResetFactoryWithoutActiveObjects() throws Exception {
- ObjectPool pool = new StackObjectPool();
+ ObjectPool<Object> pool = new StackObjectPool<Object>();
{
pool.setFactory(new SimpleFactory());
Object obj = pool.borrowObject();
@@ -166,7 +170,7 @@ public class TestStackObjectPool extends
SelectiveFactory factory = new SelectiveFactory();
factory.setValidateSelectively(true); // Even numbers fail validation
factory.setPassivateSelectively(true); // Multiples of 3 fail passivation
- ObjectPool pool = new StackObjectPool(factory, 20);
+ ObjectPool<Object> pool = new StackObjectPool<Object>(factory, 20);
Object[] obj = new Object[10];
for(int i=0;i<10;i++) {
Object object = null;
@@ -208,7 +212,7 @@ public class TestStackObjectPool extends
*/
public void testBorrowReturnWithSometimesInvalidObjects() throws Exception {
SelectiveFactory factory = new SelectiveFactory();
- ObjectPool pool = new StackObjectPool(factory, 20);
+ ObjectPool<Object> pool = new StackObjectPool<Object>(factory, 20);
Object[] obj = new Object[10];
for(int i=0;i<10;i++) {
@@ -230,27 +234,27 @@ public class TestStackObjectPool extends
public void testVariousConstructors() throws Exception {
{
- StackObjectPool pool = new StackObjectPool();
+ StackObjectPool<Object> pool = new StackObjectPool<Object>();
assertNotNull(pool);
}
{
- StackObjectPool pool = new StackObjectPool(10);
+ StackObjectPool<Object> pool = new StackObjectPool<Object>(10);
assertNotNull(pool);
}
{
- StackObjectPool pool = new StackObjectPool(10,5);
+ StackObjectPool<Object> pool = new StackObjectPool<Object>(10,5);
assertNotNull(pool);
}
{
- StackObjectPool pool = new StackObjectPool(null);
+ StackObjectPool<Object> pool = new StackObjectPool<Object>(null);
assertNotNull(pool);
}
{
- StackObjectPool pool = new StackObjectPool(null,10);
+ StackObjectPool<Object> pool = new StackObjectPool<Object>(null,10);
assertNotNull(pool);
}
{
- StackObjectPool pool = new StackObjectPool(null,10,5);
+ StackObjectPool<Object> pool = new StackObjectPool<Object>(null,10,5);
assertNotNull(pool);
}
}
@@ -260,7 +264,7 @@ public class TestStackObjectPool extends
*/
public void testMaxIdleInitCapacityOutOfRange() throws Exception {
SimpleFactory factory = new SimpleFactory();
- StackObjectPool pool = new StackObjectPool(factory, -1, 0);
+ StackObjectPool<Object> pool = new StackObjectPool<Object>(factory, -1, 0);
assertEquals(pool.getMaxSleeping(), StackObjectPool.DEFAULT_MAX_SLEEPING);
pool.addObject();
pool.close();
@@ -272,7 +276,7 @@ public class TestStackObjectPool extends
*/
public void testReturnObjectDiscardOrder() throws Exception {
SelectiveFactory factory = new SelectiveFactory();
- ObjectPool pool = new StackObjectPool(factory, 3);
+ ObjectPool<Object> pool = new StackObjectPool<Object>(factory, 3);
// borrow more objects than the pool can hold
Integer i0 = (Integer)pool.borrowObject();
@@ -305,7 +309,7 @@ public class TestStackObjectPool extends
*/
public void testExceptionOnActivate() throws Exception {
SelectiveFactory factory = new SelectiveFactory();
- ObjectPool pool = new StackObjectPool(factory);
+ ObjectPool<Object> pool = new StackObjectPool<Object>(factory);
pool.addObject();
pool.addObject();
factory.setThrowOnActivate(true);
@@ -325,7 +329,7 @@ public class TestStackObjectPool extends
*/
public void testExceptionOnDestroy() throws Exception {
SelectiveFactory factory = new SelectiveFactory();
- ObjectPool pool = new StackObjectPool(factory, 2);
+ ObjectPool<Object> pool = new StackObjectPool<Object>(factory, 2);
factory.setThrowOnDestroy(true);
for (int i = 0; i < 3; i++) {
pool.addObject(); // Third one will destroy, exception should be swallowed
@@ -348,7 +352,7 @@ public class TestStackObjectPool extends
*/
public void testExceptionOnPassivate() throws Exception {
SelectiveFactory factory = new SelectiveFactory();
- ObjectPool pool = new StackObjectPool(factory, 2);
+ ObjectPool<Object> pool = new StackObjectPool<Object>(factory, 2);
factory.setThrowOnPassivate(true);
// addObject propagates
@@ -372,7 +376,7 @@ public class TestStackObjectPool extends
*/
public void testExceptionOnValidate() throws Exception {
SelectiveFactory factory = new SelectiveFactory();
- ObjectPool pool = new StackObjectPool(factory, 2);
+ ObjectPool<Object> pool = new StackObjectPool<Object>(factory, 2);
factory.setThrowOnValidate(true);
// addObject
@@ -411,7 +415,7 @@ public class TestStackObjectPool extends
public void testExceptionOnMake() throws Exception {
SelectiveFactory factory = new SelectiveFactory();
factory.setThrowOnMake(true);
- ObjectPool pool = new StackObjectPool(factory);
+ ObjectPool<Object> pool = new StackObjectPool<Object>(factory);
try {
pool.borrowObject();
fail("Expecting IntegerFactoryException");
@@ -431,7 +435,7 @@ public class TestStackObjectPool extends
*/
public void testMakeNull() throws Exception {
SelectiveFactory factory = new SelectiveFactory();
- ObjectPool pool = new StackObjectPool(factory);
+ ObjectPool<Object> pool = new StackObjectPool<Object>(factory);
factory.setMakeNull(true);
try {
pool.borrowObject();
@@ -445,13 +449,13 @@ public class TestStackObjectPool extends
* Verifies that initIdleCapacity is not a hard limit, but maxIdle is.
*/
public void testInitIdleCapacityExceeded() throws Exception {
- PoolableObjectFactory factory = new SimpleFactory();
- ObjectPool pool = new StackObjectPool(factory, 2, 1);
+ PoolableObjectFactory<Object> factory = new SimpleFactory();
+ ObjectPool<Object> pool = new StackObjectPool<Object>(factory, 2, 1);
pool.addObject();
pool.addObject();
assertEquals(2, pool.getNumIdle());
pool.close();
- pool = new StackObjectPool(factory, 1, 2);
+ pool = new StackObjectPool<Object>(factory, 1, 2);
pool.addObject();
pool.addObject();
assertEquals(1, pool.getNumIdle());
@@ -461,9 +465,10 @@ public class TestStackObjectPool extends
* Verifies close contract - idle instances are destroyed, returning instances
* are destroyed, add/borrowObject throw IllegalStateException.
*/
+ @Override
public void testClose() throws Exception {
SelectiveFactory factory = new SelectiveFactory();
- ObjectPool pool = new StackObjectPool(factory);
+ ObjectPool<Object> pool = new StackObjectPool<Object>(factory);
pool.addObject(); // 0
pool.addObject(); // 1
pool.addObject(); // 2
@@ -472,7 +477,7 @@ public class TestStackObjectPool extends
pool.close();
assertEquals(0, pool.getNumIdle());
assertEquals(1, pool.getNumActive());
- List destroyed = factory.getDestroyed();
+ List<Object> destroyed = factory.getDestroyed();
assertEquals(2, destroyed.size());
assertTrue(destroyed.contains(new Integer(0)));
assertTrue(destroyed.contains(new Integer(0)));
@@ -496,7 +501,7 @@ public class TestStackObjectPool extends
* Simple factory that creates Integers. Validation and other factory methods
* always succeed.
*/
- static class SimpleFactory implements PoolableObjectFactory {
+ static class SimpleFactory implements PoolableObjectFactory<Object> {
int counter = 0;
public Object makeObject() { return String.valueOf(counter++); }
public void destroyObject(Object obj) { }
@@ -509,8 +514,8 @@ public class TestStackObjectPool extends
* Integer factory that fails validation and other factory methods "selectively" and
* tracks object destruction.
*/
- static class SelectiveFactory implements PoolableObjectFactory {
- private List destroyed = new ArrayList();
+ static class SelectiveFactory implements PoolableObjectFactory<Object> {
+ private List<Object> destroyed = new ArrayList<Object>();
private int counter = 0;
private boolean validateSelectively = false; // true <-> validate returns false for even Integers
private boolean passivateSelectively = false; // true <-> passivate throws RTE if Integer = 0 mod 3
@@ -568,7 +573,7 @@ public class TestStackObjectPool extends
}
}
}
- public List getDestroyed() {
+ public List<Object> getDestroyed() {
return destroyed;
}
public void setCounter(int counter) {
@@ -616,10 +621,12 @@ public class TestStackObjectPool extends
}
}
+ @Override
protected boolean isLifo() {
return true;
}
+ @Override
protected boolean isFifo() {
return false;
}
Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPoolFactory.java?rev=1096372&r1=1096371&r2=1096372&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPoolFactory.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestStackObjectPoolFactory.java Sun Apr 24 20:11:00 2011
@@ -35,27 +35,28 @@ public class TestStackObjectPoolFactory
super(name);
}
- protected ObjectPoolFactory makeFactory(final PoolableObjectFactory objectFactory) throws UnsupportedOperationException {
- return new StackObjectPoolFactory(objectFactory);
+ @Override
+ protected ObjectPoolFactory<Object> makeFactory(final PoolableObjectFactory<Object> objectFactory) throws UnsupportedOperationException {
+ return new StackObjectPoolFactory<Object>(objectFactory);
}
public void testConstructors() throws Exception {
- StackObjectPoolFactory factory = new StackObjectPoolFactory();
+ StackObjectPoolFactory<Object> factory = new StackObjectPoolFactory<Object>();
factory.createPool().close();
- factory = new StackObjectPoolFactory(1);
- StackObjectPool pool = (StackObjectPool)factory.createPool();
+ factory = new StackObjectPoolFactory<Object>(1);
+ StackObjectPool<Object> pool = (StackObjectPool<Object>)factory.createPool();
pool.close();
- factory = new StackObjectPoolFactory(1, 1);
- pool = (StackObjectPool)factory.createPool();
+ factory = new StackObjectPoolFactory<Object>(1, 1);
+ pool = (StackObjectPool<Object>)factory.createPool();
pool.close();
- factory = new StackObjectPoolFactory(new MethodCallPoolableObjectFactory(), 1);
- pool = (StackObjectPool)factory.createPool();
+ factory = new StackObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1);
+ pool = (StackObjectPool<Object>)factory.createPool();
Object a = pool.borrowObject();
Object b = pool.borrowObject();
pool.returnObject(a);