commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1221705 [8/9] - in /commons/proper/pool/branches/POOL_1_X: ./ src/java/org/apache/commons/pool/ src/java/org/apache/commons/pool/impl/ src/site/ src/site/xdoc/ src/test/org/apache/commons/pool/ src/test/org/apache/commons/pool/impl/ src/te...
Date Wed, 21 Dec 2011 13:03:55 GMT
Modified: commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java?rev=1221705&r1=1221704&r2=1221705&view=diff
==============================================================================
--- commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java (original)
+++ commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java Wed Dec 21 13:03:54 2011
@@ -17,6 +17,7 @@
 
 package org.apache.commons.pool.impl;
 
+import java.math.BigInteger;
 import java.util.NoSuchElementException;
 import java.util.Random;
 
@@ -34,29 +35,29 @@ import org.apache.commons.pool.VisitTrac
  * @author Sandy McArthur
  * @version $Revision$ $Date$
  */
-public class TestGenericObjectPool extends TestBaseObjectPool {
+public class TestGenericObjectPool extends TestBaseObjectPool<String> {
     public TestGenericObjectPool(String testName) {
         super(testName);
     }
 
-    protected ObjectPool makeEmptyPool(int mincap) {
-       GenericObjectPool pool = new GenericObjectPool(new SimpleFactory());
+    protected ObjectPool<String> makeEmptyPool(int mincap) {
+       GenericObjectPool<String> pool = new GenericObjectPool<String>(new SimpleFactory());
        pool.setMaxActive(mincap);
        pool.setMaxIdle(mincap);
        return pool;
     }
 
-    protected ObjectPool makeEmptyPool(final PoolableObjectFactory factory) {
-        return new GenericObjectPool(factory);
+    protected ObjectPool<Integer> makeEmptyPool(final PoolableObjectFactory<Integer> factory) {
+        return new GenericObjectPool<Integer>(factory);
     }
 
-    protected Object getNthObject(int n) {
+    protected String getNthObject(int n) {
         return String.valueOf(n);
     }
 
     public void setUp() throws Exception {
         super.setUp();
-        pool = new GenericObjectPool(new SimpleFactory());
+        pool = new GenericObjectPool<String>(new SimpleFactory());
     }
 
     public void tearDown() throws Exception {
@@ -69,9 +70,9 @@ public class TestGenericObjectPool exten
     public void testWhenExhaustedGrow() throws Exception {
         pool.setMaxActive(1);
         pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW);
-        Object obj1 = pool.borrowObject();
+        String obj1 = pool.borrowObject();
         assertNotNull(obj1);
-        Object obj2 = pool.borrowObject();
+        String obj2 = pool.borrowObject();
         assertNotNull(obj2);
         pool.returnObject(obj2);
         pool.returnObject(obj1);
@@ -81,7 +82,7 @@ public class TestGenericObjectPool exten
     public void testWhenExhaustedFail() throws Exception {
         pool.setMaxActive(1);
         pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_FAIL);
-        Object obj1 = pool.borrowObject();
+        String obj1 = pool.borrowObject();
         assertNotNull(obj1);
         try {
             pool.borrowObject();
@@ -98,7 +99,7 @@ public class TestGenericObjectPool exten
         pool.setMaxActive(1);
         pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK);
         pool.setMaxWait(10L);
-        Object obj1 = pool.borrowObject();
+        String obj1 = pool.borrowObject();
         assertNotNull(obj1);
         try {
             pool.borrowObject();
@@ -114,13 +115,13 @@ public class TestGenericObjectPool exten
         pool.setMaxActive(1);
         pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK);
         pool.setMaxWait(0);
-        Object obj1 = pool.borrowObject();
+        String obj1 = pool.borrowObject();
         
         // Make sure an object was obtained
         assertNotNull(obj1);
         
         // Create a separate thread to try and borrow another object
-        WaitingTestThread wtt = new WaitingTestThread(pool, 200);
+        WaitingTestThread<String> wtt = new WaitingTestThread<String>(pool, 200);
         wtt.start();
         // Give wtt time to start
         Thread.sleep(200);
@@ -137,7 +138,7 @@ public class TestGenericObjectPool exten
         
         // Bug POOL-162 - check there is now an object in the pool
         pool.setMaxWait(10L);
-        Object obj2 = null;
+        String obj2 = null;
         try {
              obj2 = pool.borrowObject();
             assertNotNull(obj2);
@@ -159,7 +160,7 @@ public class TestGenericObjectPool exten
         assertNotNull(obj1);
         
         // Create a separate thread to try and borrow another object
-        WaitingTestThread wtt = new WaitingTestThread(pool, 200);
+        WaitingTestThread<String> wtt = new WaitingTestThread<String>(pool, 200);
         wtt.start();
         // Give wtt time to start
         Thread.sleep(200);
@@ -188,13 +189,13 @@ public class TestGenericObjectPool exten
         SimpleFactory factory = new SimpleFactory();
         factory.setMakeLatency(300);
         factory.setMaxActive(2);
-        GenericObjectPool pool = new GenericObjectPool(factory);
+        GenericObjectPool<String> pool = new GenericObjectPool<String>(factory);
         pool.setMaxActive(2);
         pool.setMinIdle(1);
         pool.borrowObject(); // numActive = 1, numIdle = 0
         // Create a test thread that will run once and try a borrow after
         // 150ms fixed delay
-        TestThread borrower = new TestThread(pool, 1, 150, false);
+        TestThread<String> borrower = new TestThread<String>(pool, 1, 150, false);
         Thread borrowerThread = new Thread(borrower);
         // Set evictor to run in 100 ms - will create idle instance
         pool.setTimeBetweenEvictionRunsMillis(100);
@@ -215,7 +216,7 @@ public class TestGenericObjectPool exten
     public void checkEvict(boolean lifo) throws Exception {
         // yea this is hairy but it tests all the code paths in GOP.evict()
         final SimpleFactory factory = new SimpleFactory();
-        final GenericObjectPool pool = new GenericObjectPool(factory);
+        final GenericObjectPool<String> pool = new GenericObjectPool<String>(factory);
         pool.setSoftMinEvictableIdleTimeMillis(10);
         pool.setMinIdle(2);
         pool.setTestWhileIdle(true);
@@ -251,7 +252,7 @@ public class TestGenericObjectPool exten
     
     private void checkEvictionOrder(boolean lifo) throws Exception {
         SimpleFactory factory = new SimpleFactory();
-        GenericObjectPool pool = new GenericObjectPool(factory);
+        GenericObjectPool<String> pool = new GenericObjectPool<String>(factory);
         pool.setNumTestsPerEvictionRun(2);
         pool.setMinEvictableIdleTimeMillis(100);
         pool.setLifo(lifo);
@@ -269,7 +270,7 @@ public class TestGenericObjectPool exten
         
         // Two eviction runs in sequence
         factory = new SimpleFactory();
-        pool = new GenericObjectPool(factory);
+        pool = new GenericObjectPool<String>(factory);
         pool.setNumTestsPerEvictionRun(2);
         pool.setMinEvictableIdleTimeMillis(100);
         pool.setLifo(lifo);
@@ -293,8 +294,8 @@ public class TestGenericObjectPool exten
     }
     
     private void checkEvictorVisiting(boolean lifo) throws Exception {
-        VisitTrackerFactory factory = new VisitTrackerFactory();
-        GenericObjectPool pool = new GenericObjectPool(factory);
+        VisitTrackerFactory<Object> factory = new VisitTrackerFactory<Object>();
+        GenericObjectPool<VisitTracker<Object>> pool = new GenericObjectPool<VisitTracker<Object>>(factory);
         pool.setNumTestsPerEvictionRun(2);
         pool.setMinEvictableIdleTimeMillis(-1);
         pool.setTestWhileIdle(true);
@@ -305,7 +306,7 @@ public class TestGenericObjectPool exten
             pool.addObject();
         }
         pool.evict(); // Visit oldest 2 - 0 and 1
-        Object obj = pool.borrowObject();
+        VisitTracker<Object> obj = pool.borrowObject();
         pool.returnObject(obj);
         obj = pool.borrowObject();
         pool.returnObject(obj);
@@ -314,7 +315,7 @@ public class TestGenericObjectPool exten
         //  LIFO, 7 out, then in, then out, then in
         pool.evict();  // Should visit 2 and 3 in either case
         for (int i = 0; i < 8; i++) {
-            VisitTracker tracker = (VisitTracker) pool.borrowObject();    
+            VisitTracker<Object> tracker = pool.borrowObject();    
             if (tracker.getId() >= 4) {
                 assertEquals("Unexpected instance visited " + tracker.getId(),
                         0, tracker.getValidateCount());
@@ -325,8 +326,8 @@ public class TestGenericObjectPool exten
             }
         } 
 
-        factory = new VisitTrackerFactory();
-        pool = new GenericObjectPool(factory);
+        factory = new VisitTrackerFactory<Object>();
+        pool = new GenericObjectPool<VisitTracker<Object>>(factory);
         pool.setNumTestsPerEvictionRun(3);
         pool.setMinEvictableIdleTimeMillis(-1);
         pool.setTestWhileIdle(true);
@@ -351,7 +352,7 @@ public class TestGenericObjectPool exten
         pool.evict();
         // Should hit 6,7,0 - 0 for second time
         for (int i = 0; i < 8; i++) {
-            VisitTracker tracker = (VisitTracker) pool.borrowObject();
+            VisitTracker<Object> tracker = pool.borrowObject();
             if (tracker.getId() != 0) {
                 assertEquals("Instance " +  tracker.getId() + 
                         " visited wrong number of times.",
@@ -370,7 +371,7 @@ public class TestGenericObjectPool exten
         for (int i = 0; i < 4; i++) {
             pool.setNumTestsPerEvictionRun(smallPrimes[i]);
             for (int j = 0; j < 5; j++) {
-                pool = new GenericObjectPool(factory);
+                pool = new GenericObjectPool<VisitTracker<Object>>(factory);
                 pool.setNumTestsPerEvictionRun(3);
                 pool.setMinEvictableIdleTimeMillis(-1);
                 pool.setTestWhileIdle(true);
@@ -396,10 +397,10 @@ public class TestGenericObjectPool exten
 
                 // Look at elements and make sure they are visited cycleCount
                 // or cycleCount + 1 times
-                VisitTracker tracker = null;
+                VisitTracker<Object> tracker = null;
                 int visitCount = 0;
                 for (int k = 0; k < instanceCount; k++) {
-                    tracker = (VisitTracker) pool.borrowObject(); 
+                    tracker = pool.borrowObject(); 
                     assertTrue(pool.getNumActive() <= pool.getMaxActive());
                     visitCount = tracker.getValidateCount();                  
                     assertTrue(visitCount >= cycleCount && 
@@ -411,8 +412,8 @@ public class TestGenericObjectPool exten
 
     public void testExceptionOnPassivateDuringReturn() throws Exception {
         SimpleFactory factory = new SimpleFactory();        
-        GenericObjectPool pool = new GenericObjectPool(factory);
-        Object obj = pool.borrowObject();
+        GenericObjectPool<String> pool = new GenericObjectPool<String>(factory);
+        String obj = pool.borrowObject();
         factory.setThrowExceptionOnPassivate(true);
         pool.returnObject(obj);
         assertEquals(0,pool.getNumIdle());
@@ -422,7 +423,7 @@ public class TestGenericObjectPool exten
     public void testExceptionOnDestroyDuringBorrow() throws Exception {
         SimpleFactory factory = new SimpleFactory(); 
         factory.setThrowExceptionOnDestroy(true);
-        GenericObjectPool pool = new GenericObjectPool(factory);
+        GenericObjectPool<String> pool = new GenericObjectPool<String>(factory);
         pool.setTestOnBorrow(true);
         pool.borrowObject();
         factory.setValid(false); // Make validation fail on next borrow attempt
@@ -439,9 +440,9 @@ public class TestGenericObjectPool exten
     public void testExceptionOnDestroyDuringReturn() throws Exception {
         SimpleFactory factory = new SimpleFactory(); 
         factory.setThrowExceptionOnDestroy(true);
-        GenericObjectPool pool = new GenericObjectPool(factory);
+        GenericObjectPool<String> pool = new GenericObjectPool<String>(factory);
         pool.setTestOnReturn(true);
-        Object obj1 = pool.borrowObject();
+        String obj1 = pool.borrowObject();
         pool.borrowObject();
         factory.setValid(false); // Make validation fail
         pool.returnObject(obj1);
@@ -451,16 +452,16 @@ public class TestGenericObjectPool exten
     
     public void testExceptionOnActivateDuringBorrow() throws Exception {
         SimpleFactory factory = new SimpleFactory(); 
-        GenericObjectPool pool = new GenericObjectPool(factory);
-        Object obj1 = pool.borrowObject();
-        Object obj2 = pool.borrowObject();
+        GenericObjectPool<String> pool = new GenericObjectPool<String>(factory);
+        String obj1 = pool.borrowObject();
+        String obj2 = pool.borrowObject();
         pool.returnObject(obj1);
         pool.returnObject(obj2);
         factory.setThrowExceptionOnActivate(true);
         factory.setEvenValid(false);  
         // Activation will now throw every other time
         // First attempt throws, but loop continues and second succeeds
-        Object obj = pool.borrowObject();
+        String obj = pool.borrowObject();
         assertEquals(1, pool.getNumActive());
         assertEquals(0, pool.getNumIdle());
         
@@ -479,10 +480,10 @@ public class TestGenericObjectPool exten
     }
 
     public void testSetFactoryWithActiveObjects() throws Exception {
-        GenericObjectPool pool = new GenericObjectPool();
+        GenericObjectPool<String> pool = new GenericObjectPool<String>();
         pool.setMaxIdle(10);
         pool.setFactory(new SimpleFactory());
-        Object obj = pool.borrowObject();
+        String obj = pool.borrowObject();
         assertNotNull(obj);
         try {
             pool.setFactory(null);
@@ -499,10 +500,10 @@ public class TestGenericObjectPool exten
     }
 
     public void testSetFactoryWithNoActiveObjects() throws Exception {
-        GenericObjectPool pool = new GenericObjectPool();
+        GenericObjectPool<String> pool = new GenericObjectPool<String>();
         pool.setMaxIdle(10);
         pool.setFactory(new SimpleFactory());
-        Object obj = pool.borrowObject();
+        String obj = pool.borrowObject();
         pool.returnObject(obj);
         assertEquals(1,pool.getNumIdle());
         pool.setFactory(new SimpleFactory());
@@ -512,7 +513,7 @@ public class TestGenericObjectPool exten
     public void testNegativeMaxActive() throws Exception {
         pool.setMaxActive(-1);
         pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_FAIL);
-        Object obj = pool.borrowObject();
+        String obj = pool.borrowObject();
         assertEquals(getNthObject(0),obj);
         pool.returnObject(obj);
     }
@@ -520,7 +521,7 @@ public class TestGenericObjectPool exten
     public void testMaxIdle() throws Exception {
         pool.setMaxActive(100);
         pool.setMaxIdle(8);
-        Object[] active = new Object[100];
+        String[] active = new String[100];
         for(int i=0;i<100;i++) {
             active[i] = pool.borrowObject();
         }
@@ -536,7 +537,7 @@ public class TestGenericObjectPool exten
     public void testMaxIdleZero() throws Exception {
         pool.setMaxActive(100);
         pool.setMaxIdle(0);
-        Object[] active = new Object[100];
+        String[] active = new String[100];
         for(int i=0;i<100;i++) {
             active[i] = pool.borrowObject();
         }
@@ -568,8 +569,8 @@ public class TestGenericObjectPool exten
         pool.setMaxActive(2);
         pool.setMaxWait(10);
         pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK);
-        Object obj = pool.borrowObject();
-        Object obj2 = pool.borrowObject();
+        String obj = pool.borrowObject();
+        String obj2 = pool.borrowObject();
         try {
             pool.borrowObject();
             fail("Expecting NoSuchElementException");
@@ -610,12 +611,13 @@ public class TestGenericObjectPool exten
         pool.setTimeBetweenEvictionRunsMillis(-1);
         
         // Start threads to borrow objects
-        TestThread[] threads = new TestThread[numThreads];
+        @SuppressWarnings("unchecked")
+        TestThread<String>[] threads = new TestThread[numThreads];
         for(int i=0;i<numThreads;i++) {
             // Factor of 2 on iterations so main thread does work whilst other
             // threads are running. Factor of 2 on delay so average delay for
             // other threads == actual delay for main thread
-            threads[i] = new TestThread(pool, numIter * 2, delay * 2);
+            threads[i] = new TestThread<String>(pool, numIter * 2, delay * 2);
             Thread t = new Thread(threads[i]);
             t.start();
         }
@@ -627,7 +629,7 @@ public class TestGenericObjectPool exten
         }
         
         for (int i = 0; i < numIter; i++) {
-            Object obj = null;
+            String obj = null;
             try {
                 try {
                     Thread.sleep(delay);
@@ -682,7 +684,7 @@ public class TestGenericObjectPool exten
         }
 
         try {
-            ObjectPool pool = new GenericObjectPool(
+            ObjectPool<String> pool = new GenericObjectPool<String>(
                 new SimpleFactory(),
                 GenericObjectPool.DEFAULT_MAX_ACTIVE, 
                 Byte.MAX_VALUE,
@@ -703,7 +705,7 @@ public class TestGenericObjectPool exten
     }
 
     public void testSettersAndGetters() throws Exception {
-        GenericObjectPool pool = new GenericObjectPool();
+        GenericObjectPool<String> pool = new GenericObjectPool<String>();
         {
             pool.setFactory(new SimpleFactory());
         }
@@ -764,17 +766,17 @@ public class TestGenericObjectPool exten
     }
     
     public void testDefaultConfiguration() throws Exception {
-        GenericObjectPool pool = new GenericObjectPool();
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
         assertConfiguration(new GenericObjectPool.Config(),pool);
     }
 
     public void testConstructors() throws Exception {
         {
-            GenericObjectPool pool = new GenericObjectPool();
+            GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
             assertConfiguration(new GenericObjectPool.Config(),pool);
         }
         {
-            GenericObjectPool pool = new GenericObjectPool(new SimpleFactory());
+            GenericObjectPool<String> pool = new GenericObjectPool<String>(new SimpleFactory());
             assertConfiguration(new GenericObjectPool.Config(),pool);
         }
         {
@@ -789,13 +791,13 @@ public class TestGenericObjectPool exten
             expected.testWhileIdle = true;
             expected.timeBetweenEvictionRunsMillis = 11L;
             expected.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;
-            GenericObjectPool pool = new GenericObjectPool(null,expected);
+            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected);
             assertConfiguration(expected,pool);
         }
         {
             GenericObjectPool.Config expected = new GenericObjectPool.Config();
             expected.maxActive = 2;
-            GenericObjectPool pool = new GenericObjectPool(null,expected.maxActive);
+            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive);
             assertConfiguration(expected,pool);
         }
         {
@@ -803,7 +805,7 @@ public class TestGenericObjectPool exten
             expected.maxActive = 2;
             expected.maxWait = 5L;
             expected.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;
-            GenericObjectPool pool = new GenericObjectPool(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait);
+            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait);
             assertConfiguration(expected,pool);
         }
         {
@@ -813,7 +815,7 @@ public class TestGenericObjectPool exten
             expected.testOnBorrow = true;
             expected.testOnReturn = true;
             expected.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;
-            GenericObjectPool pool = new GenericObjectPool(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait,expected.testOnBorrow,expected.testOnReturn);
+            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait,expected.testOnBorrow,expected.testOnReturn);
             assertConfiguration(expected,pool);
         }
         {
@@ -822,7 +824,7 @@ public class TestGenericObjectPool exten
             expected.maxIdle = 3;
             expected.maxWait = 5L;
             expected.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;
-            GenericObjectPool pool = new GenericObjectPool(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait,expected.maxIdle);
+            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait,expected.maxIdle);
             assertConfiguration(expected,pool);
         }
         {
@@ -833,7 +835,7 @@ public class TestGenericObjectPool exten
             expected.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;
             expected.testOnBorrow = true;
             expected.testOnReturn = true;
-            GenericObjectPool pool = new GenericObjectPool(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait,expected.maxIdle,expected.testOnBorrow,expected.testOnReturn);
+            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait,expected.maxIdle,expected.testOnBorrow,expected.testOnReturn);
             assertConfiguration(expected,pool);
         }
         {
@@ -848,7 +850,7 @@ public class TestGenericObjectPool exten
             expected.testWhileIdle = true;
             expected.timeBetweenEvictionRunsMillis = 11L;
             expected.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;
-            GenericObjectPool pool = new GenericObjectPool(null,expected.maxActive, expected.whenExhaustedAction, expected.maxWait, expected.maxIdle, expected.testOnBorrow, expected.testOnReturn, expected.timeBetweenEvictionRunsMillis, expected.numTestsPerEvictionRun, expected.minEvictableIdleTimeMillis, expected.testWhileIdle);
+            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive, expected.whenExhaustedAction, expected.maxWait, expected.maxIdle, expected.testOnBorrow, expected.testOnReturn, expected.timeBetweenEvictionRunsMillis, expected.numTestsPerEvictionRun, expected.minEvictableIdleTimeMillis, expected.testWhileIdle);
             assertConfiguration(expected,pool);
         }
         {
@@ -864,14 +866,14 @@ public class TestGenericObjectPool exten
             expected.testWhileIdle = true;
             expected.timeBetweenEvictionRunsMillis = 11L;
             expected.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;
-            GenericObjectPool pool = new GenericObjectPool(null,expected.maxActive, expected.whenExhaustedAction, expected.maxWait, expected.maxIdle, expected.minIdle, expected.testOnBorrow, expected.testOnReturn, expected.timeBetweenEvictionRunsMillis, expected.numTestsPerEvictionRun, expected.minEvictableIdleTimeMillis, expected.testWhileIdle);
+            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive, expected.whenExhaustedAction, expected.maxWait, expected.maxIdle, expected.minIdle, expected.testOnBorrow, expected.testOnReturn, expected.timeBetweenEvictionRunsMillis, expected.numTestsPerEvictionRun, expected.minEvictableIdleTimeMillis, expected.testWhileIdle);
             assertConfiguration(expected,pool);
         }
     }
 
     public void testSetConfig() throws Exception {
         GenericObjectPool.Config expected = new GenericObjectPool.Config();
-        GenericObjectPool pool = new GenericObjectPool();
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
         assertConfiguration(expected,pool);
         expected.maxActive = 2;
         expected.maxIdle = 3;
@@ -888,10 +890,10 @@ public class TestGenericObjectPool exten
     }
 
     public void testDebugInfo() throws Exception {
-        GenericObjectPool pool = new GenericObjectPool(new SimpleFactory());
+        GenericObjectPool<String> pool = new GenericObjectPool<String>(new SimpleFactory());
         pool.setMaxIdle(3);
         assertNotNull(pool.debugInfo());
-        Object obj = pool.borrowObject();
+        String obj = pool.borrowObject();
         assertNotNull(pool.debugInfo());
         pool.returnObject(obj);
         assertNotNull(pool.debugInfo());
@@ -907,7 +909,7 @@ public class TestGenericObjectPool exten
         for(int j=0;j<2;j++) {
             // populate the pool
             {
-                Object[] active = new Object[6];
+                String[] active = new String[6];
                 for(int i=0;i<6;i++) {
                     active[i] = pool.borrowObject();
                 }
@@ -941,7 +943,7 @@ public class TestGenericObjectPool exten
         pool.setMinEvictableIdleTimeMillis(50L);
         pool.setTimeBetweenEvictionRunsMillis(100L);
 
-        Object[] active = new Object[6];
+        String[] active = new String[6];
         for(int i=0;i<6;i++) {
             active[i] = pool.borrowObject();
         }
@@ -967,7 +969,7 @@ public class TestGenericObjectPool exten
         pool.setTimeBetweenEvictionRunsMillis(500L);
         pool.setTestWhileIdle(true);
 
-        Object[] active = new Object[500];
+        String[] active = new String[500];
         for(int i=0;i<500;i++) {
             active[i] = pool.borrowObject();
         }
@@ -1010,14 +1012,12 @@ public class TestGenericObjectPool exten
     }
  
     public void testEvictionSoftMinIdle() throws Exception {
-        GenericObjectPool pool = null;
-        
-        class TimeTest extends BasePoolableObjectFactory {
+        class TimeTest extends BasePoolableObjectFactory<TimeTest> {
             private final long createTime;
             public TimeTest() {
                 createTime = System.currentTimeMillis();
             }
-            public Object makeObject() throws Exception {
+            public TimeTest makeObject() throws Exception {
                 return new TimeTest();
             }
             public long getCreateTime() {
@@ -1025,7 +1025,8 @@ public class TestGenericObjectPool exten
             }
         }
         
-        pool = new GenericObjectPool(new TimeTest());
+        GenericObjectPool<TimeTest> pool = null;        
+        pool = new GenericObjectPool<TimeTest>(new TimeTest());
         
         pool.setMaxIdle(5);
         pool.setMaxActive(5);
@@ -1034,11 +1035,11 @@ public class TestGenericObjectPool exten
         pool.setSoftMinEvictableIdleTimeMillis(1000L);
         pool.setMinIdle(2);
 
-        Object[] active = new Object[5];
+        TimeTest[] active = new TimeTest[5];
         Long[] creationTime = new Long[5] ;
         for(int i=0;i<5;i++) {
             active[i] = pool.borrowObject();
-            creationTime[i] = new Long(((TimeTest)active[i]).getCreateTime());
+            creationTime[i] = new Long(active[i].getCreateTime());
         }
         
         for(int i=0;i<5;i++) {
@@ -1068,7 +1069,7 @@ public class TestGenericObjectPool exten
         try { Thread.sleep(150L); } catch(InterruptedException e) { }
         assertTrue("Should be 5 idle, found " + pool.getNumIdle(),pool.getNumIdle() == 5);
 
-        Object[] active = new Object[5];
+        String[] active = new String[5];
         active[0] = pool.borrowObject();
 
         try { Thread.sleep(150L); } catch(InterruptedException e) { }
@@ -1101,7 +1102,7 @@ public class TestGenericObjectPool exten
         try { Thread.sleep(150L); } catch(InterruptedException e) { }
         assertTrue("Should be 5 idle, found " + pool.getNumIdle(),pool.getNumIdle() == 5);
 
-        Object[] active = new Object[10];
+        String[] active = new String[10];
 
         try { Thread.sleep(150L); } catch(InterruptedException e) { }
         assertTrue("Should be 5 idle, found " + pool.getNumIdle(),pool.getNumIdle() == 5);
@@ -1141,9 +1142,10 @@ public class TestGenericObjectPool exten
      * in between.
      */
     public void runTestThreads(int numThreads, int iterations, int delay) {
-        TestThread[] threads = new TestThread[numThreads];
+        @SuppressWarnings("unchecked")
+        TestThread<String>[] threads = new TestThread[numThreads];
         for(int i=0;i<numThreads;i++) {
-            threads[i] = new TestThread(pool,iterations,delay);
+            threads[i] = new TestThread<String>(pool,iterations,delay);
             Thread t = new Thread(threads[i]);
             t.start();
         }
@@ -1180,7 +1182,7 @@ public class TestGenericObjectPool exten
         factory.setDestroyLatency(100);  // Destroy takes 100 ms
         factory.setMaxActive(maxActive); // (makes - destroys) bound
         factory.setValidationEnabled(true);
-        pool = new GenericObjectPool(factory);
+        pool = new GenericObjectPool<String>(factory);
         pool.setMaxActive(maxActive);
         pool.setMaxIdle(-1);
         pool.setTestOnReturn(true);
@@ -1216,7 +1218,7 @@ public class TestGenericObjectPool exten
 
     private class ConcurrentBorrowAndEvictThread extends Thread {
         private boolean borrow;
-        public Object obj;
+        public String obj;
         
         public ConcurrentBorrowAndEvictThread(boolean borrow) {
             this.borrow = borrow;
@@ -1233,39 +1235,39 @@ public class TestGenericObjectPool exten
         }
     }
 
-    static class TestThread implements Runnable {
+    static class TestThread<T> implements Runnable {
         private final java.util.Random _random = new java.util.Random();
         
         // Thread config items
-        private final ObjectPool _pool;
+        private final ObjectPool<T> _pool;
         private final int _iter;
         private final int _delay;
         private final boolean _randomDelay;
-        private final Object _expectedObject;
+        private final T _expectedObject;
         
         private volatile boolean _complete = false;
         private volatile boolean _failed = false;
         private volatile Throwable _error;
 
-        public TestThread(ObjectPool pool) {
+        public TestThread(ObjectPool<T> pool) {
             this(pool, 100, 50, true, null);
         }
 
-        public TestThread(ObjectPool pool, int iter) {
+        public TestThread(ObjectPool<T> pool, int iter) {
             this(pool, iter, 50, true, null);
         }
 
-        public TestThread(ObjectPool pool, int iter, int delay) {
+        public TestThread(ObjectPool<T> pool, int iter, int delay) {
             this(pool, iter, delay, true, null);
         }
         
-        public TestThread(ObjectPool pool, int iter, int delay,
+        public TestThread(ObjectPool<T> pool, int iter, int delay,
                 boolean randomDelay) {
             this(pool, iter, delay, randomDelay, null);
         }
 
-        public TestThread(ObjectPool pool, int iter, int delay,
-                boolean randomDelay, Object obj) {
+        public TestThread(ObjectPool<T> pool, int iter, int delay,
+                boolean randomDelay, T obj) {
             _pool = pool;
             _iter = iter;
             _delay = delay;
@@ -1290,7 +1292,7 @@ public class TestGenericObjectPool exten
                 } catch(InterruptedException e) {
                     // ignored
                 }
-                Object obj = null;
+                T obj = null;
                 try {
                     obj = _pool.borrowObject();
                 } catch(Exception e) {
@@ -1358,14 +1360,14 @@ public class TestGenericObjectPool exten
         pool.addObject();
         assertEquals("should be one idle", 1, pool.getNumIdle());
         assertEquals("should be zero active", 0, pool.getNumActive());
-        Object obj = pool.borrowObject();
+        String obj = pool.borrowObject();
         assertEquals("should be zero idle", 0, pool.getNumIdle());
         assertEquals("should be one active", 1, pool.getNumActive());
         pool.returnObject(obj);
         assertEquals("should be one idle", 1, pool.getNumIdle());
         assertEquals("should be zero active", 0, pool.getNumActive());
 
-        ObjectPool op = new GenericObjectPool();
+        ObjectPool<Object> op = new GenericObjectPool<Object>();
         try {
             op.addObject();
             fail("Expected IllegalStateException when there is no factory.");
@@ -1375,9 +1377,9 @@ public class TestGenericObjectPool exten
         op.close();
     }
     
-    protected GenericObjectPool pool = null;
+    protected GenericObjectPool<String> pool = null;
 
-    private void assertConfiguration(GenericObjectPool.Config expected, GenericObjectPool actual) throws Exception {
+    private void assertConfiguration(GenericObjectPool.Config expected, GenericObjectPool<?> actual) throws Exception {
         assertEquals("testOnBorrow",expected.testOnBorrow,actual.getTestOnBorrow());
         assertEquals("testOnReturn",expected.testOnReturn,actual.getTestOnReturn());
         assertEquals("testWhileIdle",expected.testWhileIdle,actual.getTestWhileIdle());
@@ -1390,7 +1392,7 @@ public class TestGenericObjectPool exten
         assertEquals("timeBetweenEvictionRunsMillis",expected.timeBetweenEvictionRunsMillis,actual.getTimeBetweenEvictionRunsMillis());
     }
 
-    public class SimpleFactory implements PoolableObjectFactory {
+    public class SimpleFactory implements PoolableObjectFactory<String> {
         public SimpleFactory() {
             this(true);
         }
@@ -1426,7 +1428,7 @@ public class TestGenericObjectPool exten
         public synchronized void setValidateLatency(long validateLatency) {
             this.validateLatency = validateLatency;
         }
-        public Object makeObject() { 
+        public String makeObject() { 
             final long waitLatency;
             synchronized(this) {
                 activeCount++;
@@ -1445,7 +1447,7 @@ public class TestGenericObjectPool exten
             }
             return String.valueOf(counter);
         }
-        public void destroyObject(Object obj) throws Exception {
+        public void destroyObject(String obj) throws Exception {
             final long waitLatency;
             final boolean hurl;
             synchronized(this) {
@@ -1462,7 +1464,7 @@ public class TestGenericObjectPool exten
                 throw new Exception();
             }
         }
-        public boolean validateObject(Object obj) {
+        public boolean validateObject(String obj) {
             final boolean validate;
             final boolean evenTest;
             final boolean oddTest;
@@ -1485,7 +1487,7 @@ public class TestGenericObjectPool exten
                 return true;
             }
         }
-        public void activateObject(Object obj) throws Exception {
+        public void activateObject(String obj) throws Exception {
             final boolean hurl;
             final boolean evenTest;
             final boolean oddTest;
@@ -1502,7 +1504,7 @@ public class TestGenericObjectPool exten
                 }
             }
         }
-        public void passivateObject(Object obj) throws Exception {
+        public void passivateObject(String obj) throws Exception {
             final boolean hurl;
             synchronized(this) {
                 hurl = exceptionOnPassivate;
@@ -1583,9 +1585,10 @@ public class TestGenericObjectPool exten
         pool.setTimeBetweenEvictionRunsMillis(-1);
 
         // Start threads to borrow objects
-        TestThread[] threads = new TestThread[numThreads];
+        @SuppressWarnings("unchecked")
+        TestThread<String>[] threads = new TestThread[numThreads];
         for(int i=0;i<numThreads;i++) {
-            threads[i] = new TestThread(pool, 1, 2000, false, String.valueOf(i % maxActive));
+            threads[i] = new TestThread<String>(pool, 1, 2000, false, String.valueOf(i % maxActive));
             Thread t = new Thread(threads[i]);
             t.start();
             // Short delay to ensure threads start in correct order
@@ -1627,7 +1630,7 @@ public class TestGenericObjectPool exten
         
         // First borrow object will need to create a new object which will fail
         // validation.
-        Object obj = null;
+        String obj = null;
         Exception ex = null;
         factory.setValid(false);
         try {
@@ -1662,8 +1665,8 @@ public class TestGenericObjectPool exten
      * Very simple test thread that just tries to borrow an object from
      * the provided pool returns it after a wait
      */
-    static class WaitingTestThread extends Thread {
-        private final GenericObjectPool _pool;
+    static class WaitingTestThread<T> extends Thread {
+        private final GenericObjectPool<T> _pool;
         private final long _pause;
         private Throwable _thrown;
         
@@ -1673,7 +1676,7 @@ public class TestGenericObjectPool exten
         private long ended;
         private String objectId;
 
-        public WaitingTestThread(GenericObjectPool pool, long pause) {
+        public WaitingTestThread(GenericObjectPool<T> pool, long pause) {
             _pool = pool;
             _pause = pause;
             _thrown = null;
@@ -1682,7 +1685,7 @@ public class TestGenericObjectPool exten
         public void run() {
             try {
                 preborrow = System.currentTimeMillis();
-                Object obj = _pool.borrowObject();
+                T obj = _pool.borrowObject();
                 objectId=obj.toString();
                 postborrow = System.currentTimeMillis();
                 Thread.sleep(_pause);
@@ -1715,14 +1718,15 @@ public class TestGenericObjectPool exten
         final long holdTime = 2 * maxWait; // how long to hold connection
         final int threads = 10; // number of threads to grab the object initially
         SimpleFactory factory = new SimpleFactory();
-        GenericObjectPool pool = new GenericObjectPool(factory);
+        GenericObjectPool<String> pool = new GenericObjectPool<String>(factory);
         pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK);
         pool.setMaxWait(maxWait);
         pool.setMaxActive(threads);
         // Create enough threads so half the threads will have to wait
-        WaitingTestThread wtt[] = new WaitingTestThread[threads * 2];
+        @SuppressWarnings("unchecked")
+        WaitingTestThread<String> wtt[] = new WaitingTestThread[threads * 2];
         for(int i=0; i < wtt.length; i++){
-            wtt[i] = new WaitingTestThread(pool,holdTime);
+            wtt[i] = new WaitingTestThread<String>(pool,holdTime);
         }
         long origin = System.currentTimeMillis()-1000;
         for(int i=0; i < wtt.length; i++){
@@ -1744,7 +1748,7 @@ public class TestGenericObjectPool exten
                     +" Failed: "+failed
                     );
             for(int i=0; i < wtt.length; i++){
-                WaitingTestThread wt = wtt[i];
+                WaitingTestThread<String> wt = wtt[i];
                 System.out.println(
                         "Preborrow: "+(wt.preborrow-origin)
                         + " Postborrow: "+(wt.postborrow != 0 ? wt.postborrow-origin : -1)
@@ -1767,19 +1771,47 @@ public class TestGenericObjectPool exten
      */
     public void testMakeConcurrentWithReturn() throws Exception {
         SimpleFactory factory = new SimpleFactory();
-        GenericObjectPool pool = new GenericObjectPool(factory); 
+        GenericObjectPool<String> pool = new GenericObjectPool<String>(factory); 
         pool.setTestOnBorrow(true);
         factory.setValid(true);
         // Borrow and return an instance, with a short wait
-        WaitingTestThread thread1 = new WaitingTestThread(pool, 200);
+        WaitingTestThread<String> thread1 = new WaitingTestThread<String>(pool, 200);
         thread1.start();
         Thread.sleep(50); // wait for validation to succeed
         // Slow down validation and borrow an instance
         factory.setValidateLatency(400);
-        Object instance = pool.borrowObject();
+        String instance = pool.borrowObject();
         // Now make sure that we have not leaked an instance
         assertEquals(factory.getMakeCounter(), pool.getNumIdle() + 1); 
         pool.returnObject(instance);
         assertEquals(factory.getMakeCounter(), pool.getNumIdle());
     }
+    
+    public void testPoolTypeSubclass() throws Exception {
+        ObjectPool<Number> numberPool = new GenericObjectPool<Number>(new PoolableObjectFactory<Number>() {
+            public Number makeObject() throws Exception {
+                return BigInteger.ONE;
+            }
+
+            public void destroyObject(Number obj) throws Exception {
+                // do nothing                
+            }
+
+            public boolean validateObject(Number obj) {
+                return false;
+            }
+
+            public void activateObject(Number obj) throws Exception {
+                // do nothing                
+            }
+
+            public void passivateObject(Number obj) throws Exception {
+                // do nothing                
+            }
+        });
+        Number n = numberPool.borrowObject();
+        numberPool.returnObject(n);
+        BigInteger bi = (BigInteger) numberPool.borrowObject();
+        numberPool.returnObject(bi);
+    }
 }

Modified: commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestGenericObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestGenericObjectPoolFactory.java?rev=1221705&r1=1221704&r2=1221705&view=diff
==============================================================================
--- commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestGenericObjectPoolFactory.java (original)
+++ commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestGenericObjectPoolFactory.java Wed Dec 21 13:03:54 2011
@@ -35,13 +35,13 @@ public class TestGenericObjectPoolFactor
         super(name);
     }
 
-    protected ObjectPoolFactory makeFactory(final PoolableObjectFactory objectFactory) throws UnsupportedOperationException {
-        return new GenericObjectPoolFactory(objectFactory);
+    protected ObjectPoolFactory<Integer> makeFactory(final PoolableObjectFactory<Integer> objectFactory) throws UnsupportedOperationException {
+        return new GenericObjectPoolFactory<Integer>(objectFactory);
     }
 
     public void testConstructors() throws Exception {
-        GenericObjectPoolFactory factory = new GenericObjectPoolFactory(new MethodCallPoolableObjectFactory());
-        GenericObjectPool pool;
+        GenericObjectPoolFactory<Integer> factory = new GenericObjectPoolFactory<Integer>(new MethodCallPoolableObjectFactory());
+        GenericObjectPool<Integer> pool;
         factory.createPool().close();
 
         final GenericObjectPool.Config config = new GenericObjectPool.Config();
@@ -58,8 +58,8 @@ public class TestGenericObjectPoolFactor
         config.lifo = false;
         config.timeBetweenEvictionRunsMillis = 8;
         config.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;
-        factory = new GenericObjectPoolFactory(new MethodCallPoolableObjectFactory(), config);
-        pool = (GenericObjectPool)factory.createPool();
+        factory = new GenericObjectPoolFactory<Integer>(new MethodCallPoolableObjectFactory(), config);
+        pool = (GenericObjectPool<Integer>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxIdle());
         assertEquals(3, pool.getMaxWait());
@@ -77,15 +77,15 @@ public class TestGenericObjectPoolFactor
         pool.close();
 
 
-        factory = new GenericObjectPoolFactory(new MethodCallPoolableObjectFactory(), 1);
-        pool = (GenericObjectPool)factory.createPool();
+        factory = new GenericObjectPoolFactory<Integer>(new MethodCallPoolableObjectFactory(), 1);
+        pool = (GenericObjectPool<Integer>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         pool.borrowObject();
         pool.close();
 
 
-        factory = new GenericObjectPoolFactory(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_BLOCK, 125);
-        pool = (GenericObjectPool)factory.createPool();
+        factory = new GenericObjectPoolFactory<Integer>(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_BLOCK, 125);
+        pool = (GenericObjectPool<Integer>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(GenericObjectPool.WHEN_EXHAUSTED_BLOCK, pool.getWhenExhaustedAction());
         assertEquals(125, pool.getMaxWait());
@@ -102,8 +102,8 @@ public class TestGenericObjectPoolFactor
         pool.close();
 
 
-        factory = new GenericObjectPoolFactory(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_GROW, 2, true, false);
-        pool = (GenericObjectPool)factory.createPool();
+        factory = new GenericObjectPoolFactory<Integer>(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_GROW, 2, true, false);
+        pool = (GenericObjectPool<Integer>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(true, pool.getTestOnBorrow());
@@ -113,8 +113,8 @@ public class TestGenericObjectPoolFactor
         pool.close();
 
 
-        factory = new GenericObjectPoolFactory(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_GROW, 2, 3);
-        pool = (GenericObjectPool)factory.createPool();
+        factory = new GenericObjectPoolFactory<Integer>(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_GROW, 2, 3);
+        pool = (GenericObjectPool<Integer>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());
@@ -123,8 +123,8 @@ public class TestGenericObjectPoolFactor
         pool.close();
 
 
-        factory = new GenericObjectPoolFactory(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, true, false);
-        pool = (GenericObjectPool)factory.createPool();
+        factory = new GenericObjectPoolFactory<Integer>(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, true, false);
+        pool = (GenericObjectPool<Integer>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());
@@ -135,8 +135,8 @@ public class TestGenericObjectPoolFactor
         pool.close();
 
 
-        factory = new GenericObjectPoolFactory(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, true, false, 4, 5, 6, false);
-        pool = (GenericObjectPool)factory.createPool();
+        factory = new GenericObjectPoolFactory<Integer>(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, true, false, 4, 5, 6, false);
+        pool = (GenericObjectPool<Integer>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());
@@ -151,8 +151,8 @@ public class TestGenericObjectPoolFactor
         pool.close();
 
 
-        factory = new GenericObjectPoolFactory(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, 4, true, false, 5, 6, 7, true);
-        pool = (GenericObjectPool)factory.createPool();
+        factory = new GenericObjectPoolFactory<Integer>(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, 4, true, false, 5, 6, 7, true);
+        pool = (GenericObjectPool<Integer>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());
@@ -168,8 +168,8 @@ public class TestGenericObjectPoolFactor
         pool.close();
 
 
-        factory = new GenericObjectPoolFactory(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, 4, true, false, 5, 6, 7, true, 8, false);
-        pool = (GenericObjectPool)factory.createPool();
+        factory = new GenericObjectPoolFactory<Integer>(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, 4, true, false, 5, 6, 7, true, 8, false);
+        pool = (GenericObjectPool<Integer>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());

Modified: commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestSoftRefOutOfMemory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestSoftRefOutOfMemory.java?rev=1221705&r1=1221704&r2=1221705&view=diff
==============================================================================
--- commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestSoftRefOutOfMemory.java (original)
+++ commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestSoftRefOutOfMemory.java Wed Dec 21 13:03:54 2011
@@ -32,7 +32,7 @@ import org.apache.commons.pool.PoolableO
  * @version $Revision$ $Date$
  */
 public class TestSoftRefOutOfMemory extends TestCase {
-    private SoftReferenceObjectPool pool;
+    private SoftReferenceObjectPool<String> pool;
 
     public TestSoftRefOutOfMemory(String testName) {
         super(testName);
@@ -47,16 +47,16 @@ public class TestSoftRefOutOfMemory exte
     }
 
     public void testOutOfMemory() throws Exception {
-        pool = new SoftReferenceObjectPool(new SmallPoolableObjectFactory());
+        pool = new SoftReferenceObjectPool<String>(new SmallPoolableObjectFactory());
 
-        Object obj = pool.borrowObject();
+        String obj = pool.borrowObject();
         assertEquals("1", obj);
         pool.returnObject(obj);
         obj = null;
 
         assertEquals(1, pool.getNumIdle());
 
-        final List garbage = new LinkedList();
+        final List<byte[]> garbage = new LinkedList<byte[]>();
         final Runtime runtime = Runtime.getRuntime();
         while (pool.getNumIdle() > 0) {
             try {
@@ -82,20 +82,20 @@ public class TestSoftRefOutOfMemory exte
     }
 
     public void testOutOfMemory1000() throws Exception {
-        pool = new SoftReferenceObjectPool(new SmallPoolableObjectFactory());
+        pool = new SoftReferenceObjectPool<String>(new SmallPoolableObjectFactory());
 
         for (int i = 0 ; i < 1000 ; i++) {
             pool.addObject();
         }
 
-        Object obj = pool.borrowObject();
+        String obj = pool.borrowObject();
         assertEquals("1000", obj);
         pool.returnObject(obj);
         obj = null;
 
         assertEquals(1000, pool.getNumIdle());
 
-        final List garbage = new LinkedList();
+        final List<byte[]> garbage = new LinkedList<byte[]>();
         final Runtime runtime = Runtime.getRuntime();
         while (pool.getNumIdle() > 0) {
             try {
@@ -121,16 +121,16 @@ public class TestSoftRefOutOfMemory exte
     }
 
     public void testOutOfMemoryLarge() throws Exception {
-        pool = new SoftReferenceObjectPool(new LargePoolableObjectFactory(1000000));
+        pool = new SoftReferenceObjectPool<String>(new LargePoolableObjectFactory(1000000));
 
-        Object obj = pool.borrowObject();
-        assertTrue(((String)obj).startsWith("1."));
+        String obj = pool.borrowObject();
+        assertTrue(obj.startsWith("1."));
         pool.returnObject(obj);
         obj = null;
 
         assertEquals(1, pool.getNumIdle());
 
-        final List garbage = new LinkedList();
+        final List<byte[]> garbage = new LinkedList<byte[]>();
         final Runtime runtime = Runtime.getRuntime();
         while (pool.getNumIdle() > 0) {
             try {
@@ -148,7 +148,7 @@ public class TestSoftRefOutOfMemory exte
         System.gc();
 
         obj = pool.borrowObject();
-        assertTrue(((String)obj).startsWith("2."));
+        assertTrue(obj.startsWith("2."));
         pool.returnObject(obj);
         obj = null;
 
@@ -159,8 +159,8 @@ public class TestSoftRefOutOfMemory exte
      * Makes sure an {@link OutOfMemoryError} isn't swallowed.
      */
     public void testOutOfMemoryError() throws Exception {
-        pool = new SoftReferenceObjectPool(new BasePoolableObjectFactory() {
-            public Object makeObject() throws Exception {
+        pool = new SoftReferenceObjectPool<String>(new BasePoolableObjectFactory<String>() {
+            public String makeObject() throws Exception {
                 throw new OutOfMemoryError();
             }
         });
@@ -174,12 +174,12 @@ public class TestSoftRefOutOfMemory exte
         }
         pool.close();
 
-        pool = new SoftReferenceObjectPool(new BasePoolableObjectFactory() {
-            public Object makeObject() throws Exception {
-                return new Object();
+        pool = new SoftReferenceObjectPool<String>(new BasePoolableObjectFactory<String>() {
+            public String makeObject() throws Exception {
+                return new String();
             }
 
-            public boolean validateObject(Object obj) {
+            public boolean validateObject(String obj) {
                 throw new OutOfMemoryError();
             }
         });
@@ -193,16 +193,16 @@ public class TestSoftRefOutOfMemory exte
         }
         pool.close();
         
-        pool = new SoftReferenceObjectPool(new BasePoolableObjectFactory() {
-            public Object makeObject() throws Exception {
-                return new Object();
+        pool = new SoftReferenceObjectPool<String>(new BasePoolableObjectFactory<String>() {
+            public String makeObject() throws Exception {
+                return new String();
             }
 
-            public boolean validateObject(Object obj) {
+            public boolean validateObject(String obj) {
                 throw new IllegalAccessError();
             }
 
-            public void destroyObject(Object obj) throws Exception {
+            public void destroyObject(String obj) throws Exception {
                 throw new OutOfMemoryError();
             }
         });
@@ -219,10 +219,10 @@ public class TestSoftRefOutOfMemory exte
     }
 
 
-    public static class SmallPoolableObjectFactory implements PoolableObjectFactory {
+    public static class SmallPoolableObjectFactory implements PoolableObjectFactory<String> {
         private int counter = 0;
 
-        public Object makeObject() {
+        public String makeObject() {
             counter++;
             // It seems that as of Java 1.4 String.valueOf may return an
             // intern()'ed String this may cause problems when the tests
@@ -231,15 +231,15 @@ public class TestSoftRefOutOfMemory exte
             // is returned eliminated false failures.
             return new String(String.valueOf(counter));
         }
-        public boolean validateObject(Object obj) {
+        public boolean validateObject(String obj) {
             return true;
         }
-        public void activateObject(Object obj) { }
-        public void passivateObject(Object obj) { }
-        public void destroyObject(Object obj) { }
+        public void activateObject(String obj) { }
+        public void passivateObject(String obj) { }
+        public void destroyObject(String obj) { }
     }
 
-    public static class LargePoolableObjectFactory implements PoolableObjectFactory {
+    public static class LargePoolableObjectFactory implements PoolableObjectFactory<String> {
         private String buffer;
         private int counter = 0;
 
@@ -249,15 +249,15 @@ public class TestSoftRefOutOfMemory exte
             buffer = new String(data);
         }
 
-        public Object makeObject() {
+        public String makeObject() {
             counter++;
             return String.valueOf(counter) + buffer;
         }
-        public boolean validateObject(Object obj) {
+        public boolean validateObject(String obj) {
             return true;
         }
-        public void activateObject(Object obj) { }
-        public void passivateObject(Object obj) { }
-        public void destroyObject(Object obj) { }
+        public void activateObject(String obj) { }
+        public void passivateObject(String obj) { }
+        public void destroyObject(String obj) { }
     }
 }
\ No newline at end of file

Modified: commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestSoftReferenceObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestSoftReferenceObjectPool.java?rev=1221705&r1=1221704&r2=1221705&view=diff
==============================================================================
--- commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestSoftReferenceObjectPool.java (original)
+++ commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestSoftReferenceObjectPool.java Wed Dec 21 13:03:54 2011
@@ -26,29 +26,29 @@ import org.apache.commons.pool.TestBaseO
  * @author Sandy McArthur
  * @version $Revision$ $Date$
  */
-public class TestSoftReferenceObjectPool extends TestBaseObjectPool {
+public class TestSoftReferenceObjectPool extends TestBaseObjectPool<String> {
     public TestSoftReferenceObjectPool(String testName) {
         super(testName);
     }
 
-    protected ObjectPool makeEmptyPool(int cap) {
-        return new SoftReferenceObjectPool(
-            new PoolableObjectFactory()  {
+    protected ObjectPool<String> makeEmptyPool(int cap) {
+        return new SoftReferenceObjectPool<String>(
+            new PoolableObjectFactory<String>()  {
                 int counter = 0;
-                public Object makeObject() { return String.valueOf(counter++); }
-                public void destroyObject(Object obj) { }
-                public boolean validateObject(Object obj) { return true; }
-                public void activateObject(Object obj) { }
-                public void passivateObject(Object obj) { }
+                public String makeObject() { return String.valueOf(counter++); }
+                public void destroyObject(String obj) { }
+                public boolean validateObject(String obj) { return true; }
+                public void activateObject(String obj) { }
+                public void passivateObject(String obj) { }
             }
             );
     }
 
-    protected ObjectPool makeEmptyPool(final PoolableObjectFactory factory) {
-        return new SoftReferenceObjectPool(factory);
+    protected ObjectPool<Integer> makeEmptyPool(final PoolableObjectFactory<Integer> factory) {
+        return new SoftReferenceObjectPool<Integer>(factory);
     }
 
-    protected Object getNthObject(int n) {
+    protected String getNthObject(int n) {
         return String.valueOf(n);
     }
 

Modified: commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java?rev=1221705&r1=1221704&r2=1221705&view=diff
==============================================================================
--- commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java (original)
+++ commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java Wed Dec 21 13:03:54 2011
@@ -29,40 +29,40 @@ import org.apache.commons.pool.TestBaseK
  * @author Rodney Waldhoff
  * @version $Revision$ $Date$
  */
-public class TestStackKeyedObjectPool extends TestBaseKeyedObjectPool {
+public class TestStackKeyedObjectPool extends TestBaseKeyedObjectPool<String, String> {
     public TestStackKeyedObjectPool(String testName) {
         super(testName);
     }
 
-    protected KeyedObjectPool makeEmptyPool(int mincapacity) {
-        StackKeyedObjectPool pool = new StackKeyedObjectPool(new SimpleFactory(),mincapacity);
+    protected KeyedObjectPool<String, String> makeEmptyPool(int mincapacity) {
+        StackKeyedObjectPool<String, String> pool = new StackKeyedObjectPool<String, String>(new SimpleFactory(),mincapacity);
         return pool;
     }
 
-    protected KeyedObjectPool makeEmptyPool(KeyedPoolableObjectFactory factory) {
-        return new StackKeyedObjectPool(factory);
+    protected KeyedObjectPool<Object, Integer> makeEmptyPool(KeyedPoolableObjectFactory<Object, Integer> factory) {
+        return new StackKeyedObjectPool<Object, Integer>(factory);
     }
 
-    protected Object getNthObject(Object key, int n) {
+    protected String getNthObject(Object key, int n) {
         return String.valueOf(key) + String.valueOf(n);
     }
 
-    protected Object makeKey(int n) {
+    protected String makeKey(int n) {
         return String.valueOf(n);
     }
 
-    private StackKeyedObjectPool pool = null;
+    private StackKeyedObjectPool<String, String> pool = null;
 
     public void setUp() throws Exception {
         super.setUp();
-        pool = new StackKeyedObjectPool(
-            new KeyedPoolableObjectFactory()  {
+        pool = new StackKeyedObjectPool<String, String>(
+            new KeyedPoolableObjectFactory<String, String>()  {
                 int counter = 0;
-                public Object makeObject(Object key) { return String.valueOf(key) + String.valueOf(counter++); }
-                public void destroyObject(Object key, Object obj) { }
-                public boolean validateObject(Object key, Object obj) { return true; }
-                public void activateObject(Object key, Object obj) { }
-                public void passivateObject(Object key, Object obj) { }
+                public String makeObject(String key) { return String.valueOf(key) + String.valueOf(counter++); }
+                public void destroyObject(String key, String obj) { }
+                public boolean validateObject(String key, String obj) { return true; }
+                public void activateObject(String key, String obj) { }
+                public void passivateObject(String key, String obj) { }
             }
             );
     }
@@ -75,8 +75,8 @@ public class TestStackKeyedObjectPool ex
 
     public void testCloseBug() throws Exception {
         {
-            Object obj0 = pool.borrowObject("");
-            Object obj1 = pool.borrowObject("");
+            String obj0 = pool.borrowObject("");
+            String obj1 = pool.borrowObject("");
             assertEquals(2,pool.getNumActive(""));
             assertEquals(0,pool.getNumIdle(""));
             pool.returnObject("",obj1);
@@ -85,8 +85,8 @@ public class TestStackKeyedObjectPool ex
             assertEquals(2,pool.getNumIdle(""));
         }
         {
-            Object obj0 = pool.borrowObject("2");
-            Object obj1 = pool.borrowObject("2");
+            String obj0 = pool.borrowObject("2");
+            String obj1 = pool.borrowObject("2");
             assertEquals(2,pool.getNumActive("2"));
             assertEquals(0,pool.getNumIdle("2"));
             pool.returnObject("2",obj1);
@@ -98,7 +98,7 @@ public class TestStackKeyedObjectPool ex
     }
 
     public void testIdleCap() throws Exception {
-        Object[] active = new Object[100];
+        String[] active = new String[100];
         for(int i=0;i<100;i++) {
             active[i] = pool.borrowObject("");
         }
@@ -118,9 +118,9 @@ public class TestStackKeyedObjectPool ex
      */
     public void testRemoveOldest() throws Exception {
         pool._maxSleeping = 2;
-        Object obj0 = pool.borrowObject("");
-        Object obj1 = pool.borrowObject("");
-        Object obj2 = pool.borrowObject("");
+        String obj0 = pool.borrowObject("");
+        String obj1 = pool.borrowObject("");
+        String obj2 = pool.borrowObject("");
         pool.returnObject("", obj0); // Push 0 onto bottom of stack
         pool.returnObject("", obj1); // Push 1
         pool.returnObject("", obj2); // maxSleeping exceeded -> 0 destroyed, 2 pushed
@@ -130,7 +130,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));
         }
@@ -138,7 +138,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());
@@ -155,42 +155,42 @@ public class TestStackKeyedObjectPool ex
 
     public void testVariousConstructors() throws Exception {
         {
-            StackKeyedObjectPool pool = new StackKeyedObjectPool();
+            StackKeyedObjectPool<Object, Object> pool = new StackKeyedObjectPool<Object, Object>();
             assertNotNull(pool);
         }
         {
-            StackKeyedObjectPool pool = new StackKeyedObjectPool(10);
+            StackKeyedObjectPool<Object, Object> pool = new StackKeyedObjectPool<Object, Object>(10);
             assertNotNull(pool);
         }
         {
-            StackKeyedObjectPool pool = new StackKeyedObjectPool(10,5);
+            StackKeyedObjectPool<Object, Object> pool = new StackKeyedObjectPool<Object, Object>(10,5);
             assertNotNull(pool);
         }
         {
-            StackKeyedObjectPool pool = new StackKeyedObjectPool(null);
+            StackKeyedObjectPool<Object, Object> pool = new StackKeyedObjectPool<Object, Object>(null);
             assertNotNull(pool);
         }
         {
-            StackKeyedObjectPool pool = new StackKeyedObjectPool(null,10);
+            StackKeyedObjectPool<Object, Object> pool = new StackKeyedObjectPool<Object, Object>(null,10);
             assertNotNull(pool);
         }
         {
-            StackKeyedObjectPool pool = new StackKeyedObjectPool(null,10,5);
+            StackKeyedObjectPool<Object, Object> pool = new StackKeyedObjectPool<Object, Object>(null,10,5);
             assertNotNull(pool);
         }
     }
 
     public void testToString() throws Exception {
-        StackKeyedObjectPool pool = new StackKeyedObjectPool(new SimpleFactory());
+        StackKeyedObjectPool<String, String> pool = new StackKeyedObjectPool<String, String>(new SimpleFactory());
         assertNotNull(pool.toString());
-        Object obj = pool.borrowObject("key");
+        String obj = pool.borrowObject("key");
         assertNotNull(pool.toString());
         pool.returnObject("key",obj);
         assertNotNull(pool.toString());
     }
 
     public void testBorrowFromEmptyPoolWithNullFactory() throws Exception {
-        KeyedObjectPool pool = new StackKeyedObjectPool();
+        KeyedObjectPool<String, Object> pool = new StackKeyedObjectPool<String, Object>();
         try {
             pool.borrowObject("x");
             fail("Expected NoSuchElementException");
@@ -200,7 +200,7 @@ public class TestStackKeyedObjectPool ex
     }
 
     public void testSetFactory() throws Exception {
-        KeyedObjectPool pool = new StackKeyedObjectPool();
+        KeyedObjectPool<String, String> pool = new StackKeyedObjectPool<String, String>();
         try {
             pool.borrowObject("x");
             fail("Expected NoSuchElementException");
@@ -208,13 +208,13 @@ public class TestStackKeyedObjectPool ex
             // expected
         }
         pool.setFactory(new SimpleFactory());
-        Object obj = pool.borrowObject("x");
+        String obj = pool.borrowObject("x");
         assertNotNull(obj);
         pool.returnObject("x",obj);
     }
 
     public void testCantResetFactoryWithActiveObjects() throws Exception {
-        KeyedObjectPool pool = new StackKeyedObjectPool();
+        KeyedObjectPool<String, String> pool = new StackKeyedObjectPool<String, String>();
         pool.setFactory(new SimpleFactory());
         Object obj = pool.borrowObject("x");
         assertNotNull(obj);
@@ -228,50 +228,42 @@ public class TestStackKeyedObjectPool ex
     }
 
     public void testCanResetFactoryWithoutActiveObjects() throws Exception {
-        KeyedObjectPool pool = new StackKeyedObjectPool();
+        KeyedObjectPool<String, String> pool = new StackKeyedObjectPool<String, String>();
         {
             pool.setFactory(new SimpleFactory());
-            Object obj = pool.borrowObject("x");
+            String obj = pool.borrowObject("x");
             assertNotNull(obj);
             pool.returnObject("x",obj);
         }
         {
             pool.setFactory(new SimpleFactory());
-            Object obj = pool.borrowObject("x");
+            String obj = pool.borrowObject("x");
             assertNotNull(obj);
             pool.returnObject("x",obj);
         }
     }
 
     public void testBorrowReturnWithSometimesInvalidObjects() throws Exception {
-        KeyedObjectPool pool = new StackKeyedObjectPool(
-            new KeyedPoolableObjectFactory() {
+        KeyedObjectPool<String, Integer> pool = new StackKeyedObjectPool<String, Integer>(
+            new KeyedPoolableObjectFactory<String, Integer>() {
                 int counter = 0;
-                public Object makeObject(Object key) { return new Integer(counter++); }
-                public void destroyObject(Object key, Object obj) { }
-                public boolean validateObject(Object key, Object obj) {
-                    if(obj instanceof Integer) {
-                        return ((((Integer)obj).intValue() % 2) == 1);
-                    } else {
-                        return false;
-                    }
+                public Integer makeObject(String key) { return new Integer(counter++); }
+                public void destroyObject(String key, Integer obj) { }
+                public boolean validateObject(String key, Integer obj) {
+                    return ((obj.intValue() % 2) == 1);
                 }
-                public void activateObject(Object key, Object obj) { }
-                public void passivateObject(Object key, Object obj) {
-                    if(obj instanceof Integer) {
-                        if((((Integer)obj).intValue() % 3) == 0) {
-                            throw new RuntimeException("Couldn't passivate");
-                        }
-                    } else {
+                public void activateObject(String key, Integer obj) { }
+                public void passivateObject(String key, Integer obj) {
+                    if((obj.intValue() % 3) == 0) {
                         throw new RuntimeException("Couldn't passivate");
                     }
                 }
             }
         );
 
-        Object[] obj = new Object[10];
+        Integer[] obj = new Integer[10];
         for(int i=0;i<10;i++) {
-            Object object = null;
+            Integer object = null;
             int k = 0;
             while (object == null && k < 100) { // bound not really needed
                 try {
@@ -300,21 +292,21 @@ public class TestStackKeyedObjectPool ex
         assertEquals(new Integer(1), pool.borrowObject("key"));   
     }
 
-    class SimpleFactory implements KeyedPoolableObjectFactory {
-        HashMap map = new HashMap();
-        public Object makeObject(Object key) {
+    class SimpleFactory implements KeyedPoolableObjectFactory<String, String> {
+        HashMap<String, Integer> map = new HashMap<String, Integer>();
+        public String makeObject(String key) {
             int counter = 0;
-            Integer Counter = (Integer)(map.get(key));
+            Integer Counter = map.get(key);
             if(null != Counter) {
                 counter = Counter.intValue();
             }
             map.put(key,new Integer(counter + 1));
             return String.valueOf(key) + String.valueOf(counter);
         }
-        public void destroyObject(Object key, Object obj) { }
-        public boolean validateObject(Object key, Object obj) { return true; }
-        public void activateObject(Object key, Object obj) { }
-        public void passivateObject(Object key, Object obj) { }
+        public void destroyObject(String key, String obj) { }
+        public boolean validateObject(String key, String obj) { return true; }
+        public void activateObject(String key, String obj) { }
+        public void passivateObject(String key, String obj) { }
     }
 
     protected boolean isLifo() {

Modified: commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPoolFactory.java?rev=1221705&r1=1221704&r2=1221705&view=diff
==============================================================================
--- commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPoolFactory.java (original)
+++ commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPoolFactory.java Wed Dec 21 13:03:54 2011
@@ -32,36 +32,36 @@ public class TestStackKeyedObjectPoolFac
         super(name);
     }
 
-    protected KeyedObjectPoolFactory makeFactory(final KeyedPoolableObjectFactory objectFactory) throws UnsupportedOperationException {
-        return new StackKeyedObjectPoolFactory(objectFactory);
+    protected KeyedObjectPoolFactory<Object, Integer> makeFactory(final KeyedPoolableObjectFactory<Object, Integer> objectFactory) throws UnsupportedOperationException {
+        return new StackKeyedObjectPoolFactory<Object, Integer>(objectFactory);
     }
 
     public void testConstructors() throws Exception {
-        StackKeyedObjectPoolFactory factory = new StackKeyedObjectPoolFactory();
+        StackKeyedObjectPoolFactory<Object, Integer> factory = new StackKeyedObjectPoolFactory<Object, Integer>();
         factory.createPool().close();
 
-        factory = new StackKeyedObjectPoolFactory(1);
-        StackKeyedObjectPool pool = (StackKeyedObjectPool)factory.createPool();
+        factory = new StackKeyedObjectPoolFactory<Object, Integer>(1);
+        StackKeyedObjectPool<Object, Integer> pool = (StackKeyedObjectPool<Object, Integer>)factory.createPool();
         assertEquals(1,pool._maxSleeping);
         pool.close();
 
-        factory = new StackKeyedObjectPoolFactory(1, 2);
-        pool = (StackKeyedObjectPool)factory.createPool();
+        factory = new StackKeyedObjectPoolFactory<Object, Integer>(1, 2);
+        pool = (StackKeyedObjectPool<Object, Integer>)factory.createPool();
         assertEquals(1,pool._maxSleeping);
         assertEquals(2,pool._initSleepingCapacity);
         pool.close();
 
-        factory = new StackKeyedObjectPoolFactory(createObjectFactory());
-        pool = (StackKeyedObjectPool)factory.createPool();
+        factory = new StackKeyedObjectPoolFactory<Object, Integer>(createObjectFactory());
+        pool = (StackKeyedObjectPool<Object, Integer>)factory.createPool();
         pool.close();
 
-        factory = new StackKeyedObjectPoolFactory(createObjectFactory(),  1);
-        pool = (StackKeyedObjectPool)factory.createPool();
+        factory = new StackKeyedObjectPoolFactory<Object, Integer>(createObjectFactory(),  1);
+        pool = (StackKeyedObjectPool<Object, Integer>)factory.createPool();
         assertEquals(1,pool._maxSleeping);
         pool.close();
 
-        factory = new StackKeyedObjectPoolFactory(createObjectFactory(),  1, 2);
-        pool = (StackKeyedObjectPool)factory.createPool();
+        factory = new StackKeyedObjectPoolFactory<Object, Integer>(createObjectFactory(),  1, 2);
+        pool = (StackKeyedObjectPool<Object, Integer>)factory.createPool();
         assertEquals(1,pool._maxSleeping);
         assertEquals(2,pool._initSleepingCapacity);
         pool.close();



Mime
View raw message