commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1096374 - in /commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl: TestGenericKeyedObjectPool.java TestGenericKeyedObjectPoolFactory.java TestGenericObjectPool.java TestGenericObjectPoolFactory.java
Date Sun, 24 Apr 2011 20:12:16 GMT
Author: simonetripodi
Date: Sun Apr 24 20:12:16 2011
New Revision: 1096374

URL: http://svn.apache.org/viewvc?rev=1096374&view=rev
Log:
added generics to TestGeneric(Keyed)ObjectPool(Factory) test classes

Modified:
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPoolFactory.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java?rev=1096374&r1=1096373&r2=1096374&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java Sun Apr 24 20:12:16 2011
@@ -28,6 +28,7 @@ import org.apache.commons.pool2.KeyedPoo
 import org.apache.commons.pool2.TestBaseKeyedObjectPool;
 import org.apache.commons.pool2.VisitTracker;
 import org.apache.commons.pool2.VisitTrackerFactory;
+import org.apache.commons.pool2.Waiter;
 import org.apache.commons.pool2.WaiterFactory;
 import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
 import org.apache.commons.pool2.impl.GenericObjectPool;
@@ -41,13 +42,14 @@ public class TestGenericKeyedObjectPool 
         super(testName);
     }
 
-    protected KeyedObjectPool makeEmptyPool(int mincapacity) {
-        GenericKeyedObjectPool pool = new GenericKeyedObjectPool(
-            new KeyedPoolableObjectFactory()  {
-                HashMap map = new HashMap();
+    @Override
+    protected KeyedObjectPool<Object,Object> makeEmptyPool(int mincapacity) {
+        GenericKeyedObjectPool<Object,Object> pool = new GenericKeyedObjectPool<Object,Object>(
+            new 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();
                     }
@@ -65,26 +67,29 @@ public class TestGenericKeyedObjectPool 
         return pool;
     }
 
-    protected KeyedObjectPool makeEmptyPool(KeyedPoolableObjectFactory factory) {
-        return new GenericKeyedObjectPool(factory);
+    @Override
+    protected KeyedObjectPool<Object,Object> makeEmptyPool(KeyedPoolableObjectFactory<Object,Object> factory) {
+        return new GenericKeyedObjectPool<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 GenericKeyedObjectPool pool = null;
+    private GenericKeyedObjectPool<String,String> pool = null;
     private final Integer zero = new Integer(0);
     private final Integer one = new Integer(1);
     private final Integer two = new Integer(2);
 
     public void setUp() throws Exception {
         super.setUp();
-        pool = new GenericKeyedObjectPool(new SimpleFactory());
+        pool = new GenericKeyedObjectPool<String,String>(new SimpleFactory<String>());
     }
 
     public void tearDown() throws Exception {
@@ -97,7 +102,7 @@ public class TestGenericKeyedObjectPool 
     public void testNegativeMaxActive() throws Exception {
         pool.setMaxActive(-1);
         pool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_FAIL);
-        Object obj = pool.borrowObject("");
+        String obj = pool.borrowObject("");
         assertEquals("0",obj);
         pool.returnObject("",obj);
     }
@@ -110,8 +115,8 @@ public class TestGenericKeyedObjectPool 
         assertEquals(0,pool.getNumActive("B"));
         assertEquals(0,pool.getNumIdle("B"));
 
-        Object objA0 = pool.borrowObject("A");
-        Object objB0 = pool.borrowObject("B");
+        String objA0 = pool.borrowObject("A");
+        String objB0 = pool.borrowObject("B");
 
         assertEquals(2,pool.getNumActive());
         assertEquals(0,pool.getNumIdle());
@@ -120,8 +125,8 @@ public class TestGenericKeyedObjectPool 
         assertEquals(1,pool.getNumActive("B"));
         assertEquals(0,pool.getNumIdle("B"));
 
-        Object objA1 = pool.borrowObject("A");
-        Object objB1 = pool.borrowObject("B");
+        String objA1 = pool.borrowObject("A");
+        String objB1 = pool.borrowObject("B");
 
         assertEquals(4,pool.getNumActive());
         assertEquals(0,pool.getNumIdle());
@@ -154,7 +159,7 @@ public class TestGenericKeyedObjectPool 
     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("");
         }
@@ -226,11 +231,11 @@ public class TestGenericKeyedObjectPool 
         pool.setMaxTotal(3);
         pool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_FAIL);
 
-        Object o1 = pool.borrowObject("a");
+        String o1 = pool.borrowObject("a");
         assertNotNull(o1);
-        Object o2 = pool.borrowObject("a");
+        String o2 = pool.borrowObject("a");
         assertNotNull(o2);
-        Object o3 = pool.borrowObject("b");
+        String o3 = pool.borrowObject("b");
         assertNotNull(o3);
         try {
             pool.borrowObject("c");
@@ -279,22 +284,22 @@ public class TestGenericKeyedObjectPool 
         pool.setMaxTotal(3);
 //        pool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW);
 
-        Object o1 = pool.borrowObject("a");
+        String o1 = pool.borrowObject("a");
         assertNotNull(o1);
         pool.returnObject("a", o1);
         Thread.sleep(25);
 
-        Object o2 = pool.borrowObject("b");
+        String o2 = pool.borrowObject("b");
         assertNotNull(o2);
         pool.returnObject("b", o2);
         Thread.sleep(25);
 
-        Object o3 = pool.borrowObject("c");
+        String o3 = pool.borrowObject("c");
         assertNotNull(o3);
         pool.returnObject("c", o3);
         Thread.sleep(25);
 
-        Object o4 = pool.borrowObject("a");
+        String o4 = pool.borrowObject("a");
         assertNotNull(o4);
         pool.returnObject("a", o4);
         Thread.sleep(25);
@@ -302,21 +307,21 @@ public class TestGenericKeyedObjectPool 
         assertSame(o1, o4);
 
         // this should cause b to be bumped out of the pool
-        Object o5 = pool.borrowObject("d");
+        String o5 = pool.borrowObject("d");
         assertNotNull(o5);
         pool.returnObject("d", o5);
         Thread.sleep(25);
 
         // now re-request b, we should get a different object because it should
         // have been expelled from pool (was oldest because a was requested after b)
-        Object o6 = pool.borrowObject("b");
+        String o6 = pool.borrowObject("b");
         assertNotNull(o6);
         pool.returnObject("b", o6);
 
         assertNotSame(o1, o6);
 
         // second a is still in there
-        Object o7 = pool.borrowObject("a");
+        String o7 = pool.borrowObject("a");
         assertNotNull(o7);
         pool.returnObject("a", o7);
 
@@ -324,9 +329,9 @@ public class TestGenericKeyedObjectPool 
     }
 
     public void testSettersAndGetters() throws Exception {
-        GenericKeyedObjectPool pool = new GenericKeyedObjectPool();
+        GenericKeyedObjectPool<String,String> pool = new GenericKeyedObjectPool<String,String>(new SimpleFactory<String>());
         {
-            pool.setFactory(new SimpleFactory());
+            pool.setFactory(new SimpleFactory<String>());
         }
         {
             pool.setMaxActive(123);
@@ -387,7 +392,7 @@ public class TestGenericKeyedObjectPool 
         pool.setMinEvictableIdleTimeMillis(250L);
         pool.setTimeBetweenEvictionRunsMillis(500L);
 
-        Object[] active = new Object[500];
+        String[] active = new String[500];
         for(int i=0;i<500;i++) {
             active[i] = pool.borrowObject("");
         }
@@ -436,8 +441,8 @@ public class TestGenericKeyedObjectPool 
         pool.setMinEvictableIdleTimeMillis(500L);
         pool.setTimeBetweenEvictionRunsMillis(500L);
 
-        Object[] active = new Object[500];
-        Object[] active2 = new Object[500];
+        String[] active = new String[500];
+        String[] active2 = new String[500];
         for(int i=0;i<500;i++) {
             active[i] = pool.borrowObject("");
             active2[i] = pool.borrowObject("2");
@@ -511,12 +516,12 @@ public class TestGenericKeyedObjectPool 
      */
     public void testMaxTotalInvariant() throws Exception {
         int maxTotal = 15;
-        SimpleFactory factory = new SimpleFactory();
+        SimpleFactory<String> factory = new SimpleFactory<String>();
         factory.setEvenValid(false);     // Every other validation fails
         factory.setDestroyLatency(100);  // Destroy takes 100 ms
         factory.setMaxActive(maxTotal);  // (makes - destroys) bound
         factory.setValidationEnabled(true);
-        pool = new GenericKeyedObjectPool(factory);
+        pool = new GenericKeyedObjectPool<String,String>(factory);
         pool.setMaxTotal(maxTotal);
         pool.setMaxIdle(-1);
         pool.setTestOnReturn(true);
@@ -542,7 +547,7 @@ public class TestGenericKeyedObjectPool 
         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(key);
 
         try { Thread.sleep(150L); } catch(InterruptedException e) { }
@@ -581,7 +586,7 @@ public class TestGenericKeyedObjectPool 
         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);
@@ -661,7 +666,7 @@ public class TestGenericKeyedObjectPool 
 
     public void testFIFO() throws Exception {
         pool.setLifo(false);
-        final Object key = "key";
+        final String key = "key";
         pool.addObject(key); // "key0"
         pool.addObject(key); // "key1"
         pool.addObject(key); // "key2"
@@ -676,7 +681,7 @@ public class TestGenericKeyedObjectPool 
     
     public void testLIFO() throws Exception {
         pool.setLifo(true);
-        final Object key = "key";
+        final String key = "key";
         pool.addObject(key); // "key0"
         pool.addObject(key); // "key1"
         pool.addObject(key); // "key2"
@@ -701,8 +706,8 @@ public class TestGenericKeyedObjectPool 
     }
     
     private void checkEvictionOrder(boolean lifo) throws Exception {
-        SimpleFactory factory = new SimpleFactory();
-        GenericKeyedObjectPool pool = new GenericKeyedObjectPool(factory);
+        SimpleFactory<Integer> factory = new SimpleFactory<Integer>();
+        GenericKeyedObjectPool<Integer,String> pool = new GenericKeyedObjectPool<Integer,String>(factory);
         pool.setNumTestsPerEvictionRun(2);
         pool.setMinEvictableIdleTimeMillis(100);
         pool.setLifo(lifo);
@@ -727,20 +732,20 @@ public class TestGenericKeyedObjectPool 
         
         pool.evict(); // Kill (0,0),(0,1)
         assertEquals(3, pool.getNumIdle(zero));
-        Object objZeroA = pool.borrowObject(zero);
+        String objZeroA = pool.borrowObject(zero);
         assertTrue(lifo ? objZeroA.equals("04") : objZeroA.equals("02"));
         assertEquals(2, pool.getNumIdle(zero));
-        Object objZeroB = pool.borrowObject(zero);
+        String objZeroB = pool.borrowObject(zero);
         assertTrue(objZeroB.equals("03"));
         assertEquals(1, pool.getNumIdle(zero));
         
         pool.evict(); // Kill remaining 0 survivor and (1,5)
         assertEquals(0, pool.getNumIdle(zero));
         assertEquals(4, pool.getNumIdle(one));
-        Object objOneA = pool.borrowObject(one);
+        String objOneA = pool.borrowObject(one);
         assertTrue(lifo ? objOneA.equals("19") : objOneA.equals("16"));
         assertEquals(3, pool.getNumIdle(one));
-        Object objOneB = pool.borrowObject(one);
+        String objOneB = pool.borrowObject(one);
         assertTrue(lifo ? objOneB.equals("18") : objOneB.equals("17"));
         assertEquals(2, pool.getNumIdle(one));
         
@@ -748,7 +753,7 @@ public class TestGenericKeyedObjectPool 
         assertEquals(0, pool.getNumIdle(one));
         pool.evict(); // Kill (2,10), (2,11)
         assertEquals(3, pool.getNumIdle(two));
-        Object objTwoA = pool.borrowObject(two);
+        String objTwoA = pool.borrowObject(two);
         assertTrue(lifo ? objTwoA.equals("214") : objTwoA.equals("212"));
         assertEquals(2, pool.getNumIdle(two));
         pool.evict(); // All dead now
@@ -803,7 +808,7 @@ public class TestGenericKeyedObjectPool 
         pool.evict(); // kill (1,6), (1,7) - (1,5) missed
         assertEquals(3, pool.getNumIdle(one));
         assertEquals(5, pool.getNumIdle(two));
-        Object obj = pool.borrowObject(one);
+        String obj = pool.borrowObject(one);
         if (lifo) {
             assertEquals("19", obj);
         } else {
@@ -822,8 +827,8 @@ public class TestGenericKeyedObjectPool 
     }
     
     private void checkEvictorVisiting(boolean lifo) throws Exception {
-        VisitTrackerFactory factory = new VisitTrackerFactory();
-        GenericKeyedObjectPool pool = new GenericKeyedObjectPool(factory);
+        VisitTrackerFactory<Integer> factory = new VisitTrackerFactory<Integer>();
+        GenericKeyedObjectPool<Integer,VisitTracker<Integer>> pool = new GenericKeyedObjectPool<Integer,VisitTracker<Integer>>(factory);
         pool.setNumTestsPerEvictionRun(2);
         pool.setMinEvictableIdleTimeMillis(-1);
         pool.setTestWhileIdle(true);
@@ -838,7 +843,7 @@ public class TestGenericKeyedObjectPool 
             }
         }
         pool.evict(); // Visit oldest 2 - 00 and 01
-        Object obj = pool.borrowObject(zero);
+        VisitTracker<Integer> obj = pool.borrowObject(zero);
         pool.returnObject(zero, obj);
         obj = pool.borrowObject(zero);
         pool.returnObject(zero, obj);
@@ -847,7 +852,7 @@ public class TestGenericKeyedObjectPool 
         //  LIFO, 7 out, then in, then out, then in - 7,6,5,4,3,2,1,0
         pool.evict();  // Should visit 02 and 03 in either case
         for (int i = 0; i < 8; i++) {
-            VisitTracker tracker = (VisitTracker) pool.borrowObject(zero);    
+            VisitTracker<Integer> tracker = pool.borrowObject(zero);    
             if (tracker.getId() >= 4) {
                 assertEquals("Unexpected instance visited " + tracker.getId(),
                         0, tracker.getValidateCount());
@@ -887,7 +892,7 @@ public class TestGenericKeyedObjectPool 
         // LIFO - 27, skip, 10
         // FIFO - 24, 25, 26
         for (int i = 0; i < 8; i++) {
-            VisitTracker tracker = (VisitTracker) pool.borrowObject(one);    
+            VisitTracker<Integer> tracker = pool.borrowObject(one);    
             if ((lifo && tracker.getId() > 0) || 
                     (!lifo && tracker.getId() > 2)) {
                 assertEquals("Instance " +  tracker.getId() + 
@@ -939,10 +944,10 @@ public class TestGenericKeyedObjectPool 
                 
                 // Look at elements and make sure they are visited cycleCount
                 // or cycleCount + 1 times
-                VisitTracker tracker = null;
+                VisitTracker<Integer> tracker = null;
                 int visitCount = 0;
                 for (int k = 0; k < zeroLength; k++) {
-                    tracker = (VisitTracker) pool.borrowObject(zero); 
+                    tracker = pool.borrowObject(zero); 
                     visitCount = tracker.getValidateCount();
                     if (visitCount < cycleCount || visitCount > cycleCount + 1){
                         fail(formatSettings("ZERO", "runs", runs, "lifo", lifo, "i", i, "j", j,
@@ -951,7 +956,7 @@ public class TestGenericKeyedObjectPool 
                     }
                 }
                 for (int k = 0; k < oneLength; k++) {
-                    tracker = (VisitTracker) pool.borrowObject(one); 
+                    tracker = pool.borrowObject(one); 
                     visitCount = tracker.getValidateCount();
                     if (visitCount < cycleCount || visitCount > cycleCount + 1){
                         fail(formatSettings("ONE", "runs", runs, "lifo", lifo, "i", i, "j", j,
@@ -961,7 +966,7 @@ public class TestGenericKeyedObjectPool 
                 }
                 int visits[] = new int[twoLength];
                 for (int k = 0; k < twoLength; k++) {
-                    tracker = (VisitTracker) pool.borrowObject(two); 
+                    tracker = pool.borrowObject(two); 
                     visitCount = tracker.getValidateCount();
                     visits[k] = visitCount;
                     if (visitCount < cycleCount || visitCount > cycleCount + 1){
@@ -995,7 +1000,7 @@ public class TestGenericKeyedObjectPool 
         byte whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;
         boolean lifo = false;
         
-        GenericKeyedObjectPool pool = new GenericKeyedObjectPool();
+        GenericKeyedObjectPool<Object,Object> pool = new GenericKeyedObjectPool<Object,Object>();
         assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_ACTIVE, pool.getMaxActive());
         assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_IDLE, pool.getMaxIdle());
         assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_WAIT, pool.getMaxWait());
@@ -1031,7 +1036,7 @@ public class TestGenericKeyedObjectPool 
         config.testWhileIdle = testWhileIdle;
         config.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
         config.whenExhaustedAction = whenExhaustedAction;
-        pool = new GenericKeyedObjectPool(null, config);
+        pool = new GenericKeyedObjectPool<Object,Object>(null, config);
         assertEquals(maxActive, pool.getMaxActive());
         assertEquals(maxIdle, pool.getMaxIdle());
         assertEquals(maxWait, pool.getMaxWait());
@@ -1048,7 +1053,7 @@ public class TestGenericKeyedObjectPool 
         assertEquals(whenExhaustedAction,pool.getWhenExhaustedAction());
         assertEquals(lifo, pool.getLifo());
         
-        pool = new GenericKeyedObjectPool(null, maxActive);
+        pool = new GenericKeyedObjectPool<Object,Object>(null, maxActive);
         assertEquals(maxActive, pool.getMaxActive());
         assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_IDLE, pool.getMaxIdle());
         assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_WAIT, pool.getMaxWait());
@@ -1070,7 +1075,7 @@ public class TestGenericKeyedObjectPool 
                 pool.getWhenExhaustedAction());
         assertEquals(GenericKeyedObjectPool.DEFAULT_LIFO, pool.getLifo());
         
-        pool = new GenericKeyedObjectPool(null, maxActive, whenExhaustedAction, maxWait);
+        pool = new GenericKeyedObjectPool<Object,Object>(null, maxActive, whenExhaustedAction, maxWait);
         assertEquals(maxActive, pool.getMaxActive());
         assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_IDLE, pool.getMaxIdle());
         assertEquals(maxWait, pool.getMaxWait());
@@ -1091,7 +1096,7 @@ public class TestGenericKeyedObjectPool 
         assertEquals(whenExhaustedAction,pool.getWhenExhaustedAction());
         assertEquals(GenericKeyedObjectPool.DEFAULT_LIFO, pool.getLifo());
         
-        pool = new GenericKeyedObjectPool(null, maxActive, whenExhaustedAction,
+        pool = new GenericKeyedObjectPool<Object,Object>(null, maxActive, whenExhaustedAction,
                    maxWait, testOnBorrow, testOnReturn);
         assertEquals(maxActive, pool.getMaxActive());
         assertEquals(GenericKeyedObjectPool.DEFAULT_MAX_IDLE, pool.getMaxIdle());
@@ -1111,7 +1116,7 @@ public class TestGenericKeyedObjectPool 
         assertEquals(whenExhaustedAction,pool.getWhenExhaustedAction());
         assertEquals(GenericKeyedObjectPool.DEFAULT_LIFO, pool.getLifo());
         
-        pool = new GenericKeyedObjectPool(null, maxActive, whenExhaustedAction,
+        pool = new GenericKeyedObjectPool<Object,Object>(null, maxActive, whenExhaustedAction,
                 maxWait, maxIdle);
         assertEquals(maxActive, pool.getMaxActive());
         assertEquals(maxIdle, pool.getMaxIdle());
@@ -1133,7 +1138,7 @@ public class TestGenericKeyedObjectPool 
         assertEquals(whenExhaustedAction,pool.getWhenExhaustedAction());
         assertEquals(GenericKeyedObjectPool.DEFAULT_LIFO, pool.getLifo());
 
-        pool = new GenericKeyedObjectPool(null, maxActive, whenExhaustedAction,
+        pool = new GenericKeyedObjectPool<Object,Object>(null, maxActive, whenExhaustedAction,
                 maxWait, maxIdle, testOnBorrow, testOnReturn);
         assertEquals(maxActive, pool.getMaxActive());
         assertEquals(maxIdle, pool.getMaxIdle());
@@ -1153,7 +1158,7 @@ public class TestGenericKeyedObjectPool 
         assertEquals(whenExhaustedAction,pool.getWhenExhaustedAction());
         assertEquals(GenericKeyedObjectPool.DEFAULT_LIFO, pool.getLifo());
 
-        pool = new GenericKeyedObjectPool(null, maxActive, whenExhaustedAction,
+        pool = new GenericKeyedObjectPool<Object,Object>(null, maxActive, whenExhaustedAction,
                 maxWait, maxIdle, testOnBorrow, testOnReturn,
                 timeBetweenEvictionRunsMillis, numTestsPerEvictionRun,
                 minEvictableIdleTimeMillis, testWhileIdle);
@@ -1175,7 +1180,7 @@ public class TestGenericKeyedObjectPool 
         assertEquals(whenExhaustedAction,pool.getWhenExhaustedAction());
         assertEquals(GenericKeyedObjectPool.DEFAULT_LIFO, pool.getLifo());
         
-        pool = new GenericKeyedObjectPool(null, maxActive, whenExhaustedAction,
+        pool = new GenericKeyedObjectPool<Object,Object>(null, maxActive, whenExhaustedAction,
                 maxWait, maxIdle, maxTotal, testOnBorrow, testOnReturn,
                 timeBetweenEvictionRunsMillis, numTestsPerEvictionRun,
                 minEvictableIdleTimeMillis, testWhileIdle);
@@ -1197,7 +1202,7 @@ public class TestGenericKeyedObjectPool 
         assertEquals(whenExhaustedAction,pool.getWhenExhaustedAction());
         assertEquals(GenericKeyedObjectPool.DEFAULT_LIFO, pool.getLifo());
         
-        pool = new GenericKeyedObjectPool(null, maxActive, whenExhaustedAction,
+        pool = new GenericKeyedObjectPool<Object,Object>(null, maxActive, whenExhaustedAction,
                 maxWait, maxIdle, maxTotal, minIdle, testOnBorrow, testOnReturn,
                 timeBetweenEvictionRunsMillis, numTestsPerEvictionRun,
                 minEvictableIdleTimeMillis, testWhileIdle);
@@ -1219,7 +1224,7 @@ public class TestGenericKeyedObjectPool 
         assertEquals(whenExhaustedAction,pool.getWhenExhaustedAction());
         assertEquals(GenericKeyedObjectPool.DEFAULT_LIFO, pool.getLifo());
         
-        pool = new GenericKeyedObjectPool(null, maxActive, whenExhaustedAction,
+        pool = new GenericKeyedObjectPool<Object,Object>(null, maxActive, whenExhaustedAction,
                 maxWait, maxIdle, maxTotal, minIdle, testOnBorrow, testOnReturn,
                 timeBetweenEvictionRunsMillis, numTestsPerEvictionRun,
                 minEvictableIdleTimeMillis, testWhileIdle, lifo);
@@ -1243,9 +1248,9 @@ public class TestGenericKeyedObjectPool 
     }
     
     public void testExceptionOnPassivateDuringReturn() throws Exception {
-        SimpleFactory factory = new SimpleFactory();        
-        GenericKeyedObjectPool pool = new GenericKeyedObjectPool(factory);
-        Object obj = pool.borrowObject("one");
+        SimpleFactory<String> factory = new SimpleFactory<String>();
+        GenericKeyedObjectPool<String,String> pool = new GenericKeyedObjectPool<String,String>(factory);
+        String obj = pool.borrowObject("one");
         factory.setThrowExceptionOnPassivate(true);
         pool.returnObject("one", obj);
         assertEquals(0,pool.getNumIdle());
@@ -1253,10 +1258,10 @@ public class TestGenericKeyedObjectPool 
     }
     
     public void testExceptionOnDestroyDuringBorrow() throws Exception {
-        SimpleFactory factory = new SimpleFactory(); 
+        SimpleFactory<String> factory = new SimpleFactory<String>(); 
         factory.setThrowExceptionOnDestroy(true);
         factory.setValidationEnabled(true);
-        GenericKeyedObjectPool pool = new GenericKeyedObjectPool(factory);
+        GenericKeyedObjectPool<String,String> pool = new GenericKeyedObjectPool<String,String>(factory);
         pool.setTestOnBorrow(true);
         pool.borrowObject("one");
         factory.setValid(false); // Make validation fail on next borrow attempt
@@ -1273,12 +1278,12 @@ public class TestGenericKeyedObjectPool 
     }
     
     public void testExceptionOnDestroyDuringReturn() throws Exception {
-        SimpleFactory factory = new SimpleFactory(); 
+        SimpleFactory<String> factory = new SimpleFactory<String>(); 
         factory.setThrowExceptionOnDestroy(true);
         factory.setValidationEnabled(true);
-        GenericKeyedObjectPool pool = new GenericKeyedObjectPool(factory);
+        GenericKeyedObjectPool<String,String> pool = new GenericKeyedObjectPool<String,String>(factory);
         pool.setTestOnReturn(true);
-        Object obj1 = pool.borrowObject("one");
+        String obj1 = pool.borrowObject("one");
         pool.borrowObject("one");
         factory.setValid(false); // Make validation fail
         pool.returnObject("one", obj1);
@@ -1289,17 +1294,17 @@ public class TestGenericKeyedObjectPool 
     }
     
     public void testExceptionOnActivateDuringBorrow() throws Exception {
-        SimpleFactory factory = new SimpleFactory(); 
-        GenericKeyedObjectPool pool = new GenericKeyedObjectPool(factory);
-        Object obj1 = pool.borrowObject("one");
-        Object obj2 = pool.borrowObject("one");
+        SimpleFactory<String> factory = new SimpleFactory<String>(); 
+        GenericKeyedObjectPool<String,String> pool = new GenericKeyedObjectPool<String,String>(factory);
+        String obj1 = pool.borrowObject("one");
+        String obj2 = pool.borrowObject("one");
         pool.returnObject("one", obj1);
         pool.returnObject("one", 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("one");
+        String obj = pool.borrowObject("one");
         assertEquals(1, pool.getNumActive("one"));
         assertEquals(0, pool.getNumIdle("one"));
         assertEquals(1, pool.getNumActive());
@@ -1322,8 +1327,8 @@ public class TestGenericKeyedObjectPool 
     }
     
     public void testBlockedKeyDoesNotBlockPool() throws Exception {
-        SimpleFactory factory = new SimpleFactory();
-        GenericKeyedObjectPool pool = new GenericKeyedObjectPool(factory);
+        SimpleFactory<String> factory = new SimpleFactory<String>();
+        GenericKeyedObjectPool<String,String> pool = new GenericKeyedObjectPool<String,String>(factory);
         pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK);
         pool.setMaxWait(5000);
         pool.setMaxActive(1);
@@ -1366,8 +1371,8 @@ public class TestGenericKeyedObjectPool 
         final long holdTime = 2 * maxWait; // how long to hold connection
         final int keyCount = 4; // number of different keys
         final int threadsPerKey = 5; // number of threads to grab the key initially
-        SimpleFactory factory = new SimpleFactory();
-        GenericKeyedObjectPool pool = new GenericKeyedObjectPool(factory);
+        SimpleFactory<String> factory = new SimpleFactory<String>();
+        GenericKeyedObjectPool<String,String> pool = new GenericKeyedObjectPool<String,String>(factory);
         pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK);
         pool.setMaxWait(maxWait);
         pool.setMaxActive(threadsPerKey);
@@ -1416,8 +1421,8 @@ public class TestGenericKeyedObjectPool 
      * Test case for POOL-180.
      */
     public void testMaxActivePerKeyExceeded() {
-        WaiterFactory factory = new WaiterFactory(0, 20, 0, 0, 0, 0, 8, 5, 0);
-        pool = new GenericKeyedObjectPool(factory);
+        WaiterFactory<String> factory = new WaiterFactory<String>(0, 20, 0, 0, 0, 0, 8, 5, 0);
+        GenericKeyedObjectPool<String,Waiter> pool = new GenericKeyedObjectPool<String,Waiter>(factory);
         pool.setMaxActive(5);
         pool.setMaxTotal(8);
         pool.setTestOnBorrow(true);
@@ -1431,17 +1436,17 @@ public class TestGenericKeyedObjectPool 
      * the provided pool with the specified key and returns it
      */
     static class SimpleTestThread implements Runnable {
-        private final KeyedObjectPool _pool;
+        private final KeyedObjectPool<String,String> _pool;
         private final String _key;
         
-        public SimpleTestThread(KeyedObjectPool pool, String key) {
+        public SimpleTestThread(KeyedObjectPool<String,String> pool, String key) {
             _pool = pool;
             _key = key;
         }
 
         public void run() {
             try {
-                Object obj = _pool.borrowObject(_key);
+                String obj = _pool.borrowObject(_key);
                 _pool.returnObject(_key, obj);
             } catch (Exception e) {
                 // Ignore
@@ -1454,7 +1459,7 @@ public class TestGenericKeyedObjectPool 
      * the provided pool with the specified key and returns it after a wait
      */
     static class WaitingTestThread extends Thread {
-        private final KeyedObjectPool _pool;
+        private final KeyedObjectPool<String,String> _pool;
         private final String _key;
         private final long _pause;
         private Throwable _thrown;
@@ -1465,17 +1470,18 @@ public class TestGenericKeyedObjectPool 
         private long ended;
         private String objectId;
 
-        public WaitingTestThread(KeyedObjectPool pool, String key, long pause) {
+        public WaitingTestThread(KeyedObjectPool<String,String> pool, String key, long pause) {
             _pool = pool;
             _key = key;
             _pause = pause;
             _thrown = null;
         }
 
+        @Override
         public void run() {
             try {
                 preborrow = System.currentTimeMillis();
-                Object obj = _pool.borrowObject(_key);
+                String obj = _pool.borrowObject(_key);
                 objectId=obj.toString();
                 postborrow = System.currentTimeMillis();
                 Thread.sleep(_pause);
@@ -1493,7 +1499,7 @@ public class TestGenericKeyedObjectPool 
         private final java.util.Random _random = new java.util.Random();
         
         // Thread config items
-        private final KeyedObjectPool _pool;
+        private final KeyedObjectPool<String,String> _pool;
         private final int _iter;
         private final int _delay;
 
@@ -1501,15 +1507,15 @@ public class TestGenericKeyedObjectPool 
         private volatile boolean _failed = false;
         private volatile Exception _exception;
 
-        public TestThread(KeyedObjectPool pool) {
+        public TestThread(KeyedObjectPool<String,String> pool) {
             this(pool, 100, 50);
         }
 
-        public TestThread(KeyedObjectPool pool, int iter) {
+        public TestThread(KeyedObjectPool<String,String> pool, int iter) {
             this(pool, iter, 50);
         }
 
-        public TestThread(KeyedObjectPool pool, int iter, int delay) {
+        public TestThread(KeyedObjectPool<String,String> pool, int iter, int delay) {
             _pool = pool;
             _iter = iter;
             _delay = delay;
@@ -1531,7 +1537,7 @@ public class TestGenericKeyedObjectPool 
                 } catch(InterruptedException e) {
                     // ignored
                 }
-                Object obj = null;
+                String obj = null;
                 try {
                     obj = _pool.borrowObject(key);
                 } catch(Exception e) {
@@ -1559,14 +1565,14 @@ public class TestGenericKeyedObjectPool 
         }
     }
 
-    static class SimpleFactory implements KeyedPoolableObjectFactory {
+    static class SimpleFactory<K> implements KeyedPoolableObjectFactory<K,String> {
         public SimpleFactory() {
             this(true);
         }
         public SimpleFactory(boolean valid) {
             this.valid = valid;
         }
-        public Object makeObject(Object key) {
+        public String makeObject(K key) {
             synchronized(this) {
                 activeCount++;
                 if (activeCount > maxActive) {
@@ -1576,7 +1582,7 @@ public class TestGenericKeyedObjectPool 
             }
             return String.valueOf(key) + String.valueOf(counter++);
         }
-        public void destroyObject(Object key, Object obj) throws Exception {
+        public void destroyObject(K key, String obj) throws Exception {
             doWait(destroyLatency);
             synchronized(this) {
                 activeCount--;
@@ -1585,21 +1591,21 @@ public class TestGenericKeyedObjectPool 
                 throw new Exception();
             }
         }
-        public boolean validateObject(Object key, Object obj) {
+        public boolean validateObject(K key, String obj) {
             if (enableValidation) { 
                 return validateCounter++%2 == 0 ? evenValid : oddValid; 
             } else {
                 return valid;
             }
         }
-        public void activateObject(Object key, Object obj) throws Exception {
+        public void activateObject(K key, String obj) throws Exception {
             if (exceptionOnActivate) {
                 if (!(validateCounter++%2 == 0 ? evenValid : oddValid)) {
                     throw new Exception();
                 }
             }
         }
-        public void passivateObject(Object key, Object obj) throws Exception {
+        public void passivateObject(K key, String obj) throws Exception {
             if (exceptionOnPassivate) {
                 throw new Exception();
             }
@@ -1657,10 +1663,12 @@ public class TestGenericKeyedObjectPool 
         }
     }
 
+    @Override
     protected boolean isLifo() {
         return true;
     }
 
+    @Override
     protected boolean isFifo() {
         return false;
     }

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPoolFactory.java?rev=1096374&r1=1096373&r2=1096374&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPoolFactory.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPoolFactory.java Sun Apr 24 20:12:16 2011
@@ -35,14 +35,15 @@ public class TestGenericKeyedObjectPoolF
         super(name);
     }
 
-    protected KeyedObjectPoolFactory makeFactory(final KeyedPoolableObjectFactory objectFactory) {
-        return new GenericKeyedObjectPoolFactory(objectFactory);
+    @Override
+    protected KeyedObjectPoolFactory<Object,Object> makeFactory(final KeyedPoolableObjectFactory<Object,Object> objectFactory) {
+        return new GenericKeyedObjectPoolFactory<Object,Object>(objectFactory);
     }
 
     public void testConstructors() throws Exception {
-        GenericKeyedObjectPoolFactory factory = new GenericKeyedObjectPoolFactory(createObjectFactory());
+        GenericKeyedObjectPoolFactory<Object,Object> factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory());
         factory.createPool().close();
-        GenericKeyedObjectPool pool;
+        GenericKeyedObjectPool<Object,Object> pool;
 
 
         final GenericKeyedObjectPool.Config config = new GenericKeyedObjectPool.Config();
@@ -58,8 +59,8 @@ public class TestGenericKeyedObjectPoolF
         config.timeBetweenEvictionRunsMillis = 8;
         config.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;
         config.lifo = false;
-        factory = new GenericKeyedObjectPoolFactory(createObjectFactory(), config);
-        pool = (GenericKeyedObjectPool)factory.createPool();
+        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), config);
+        pool = (GenericKeyedObjectPool<Object,Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxIdle());
         assertEquals(3, pool.getMaxWait());
@@ -75,22 +76,22 @@ public class TestGenericKeyedObjectPoolF
         pool.close();
 
 
-        factory = new GenericKeyedObjectPoolFactory(createObjectFactory(), 1);
-        pool = (GenericKeyedObjectPool)factory.createPool();
+        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1);
+        pool = (GenericKeyedObjectPool<Object,Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         pool.close();
 
 
-        factory = new GenericKeyedObjectPoolFactory(createObjectFactory(), 1, GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK, 125);
-        pool = (GenericKeyedObjectPool)factory.createPool();
+        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK, 125);
+        pool = (GenericKeyedObjectPool<Object,Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK, pool.getWhenExhaustedAction());
         assertEquals(125, pool.getMaxWait());
         pool.close();
 
 
-        factory = new GenericKeyedObjectPoolFactory(createObjectFactory(), 1, GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW, 2, true, false);
-        pool = (GenericKeyedObjectPool)factory.createPool();
+        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW, 2, true, false);
+        pool = (GenericKeyedObjectPool<Object,Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(true, pool.getTestOnBorrow());
@@ -99,8 +100,8 @@ public class TestGenericKeyedObjectPoolF
         pool.close();
 
 
-        factory = new GenericKeyedObjectPoolFactory(createObjectFactory(), 1, GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW, 2, 3);
-        pool = (GenericKeyedObjectPool)factory.createPool();
+        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW, 2, 3);
+        pool = (GenericKeyedObjectPool<Object,Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());
@@ -108,8 +109,8 @@ public class TestGenericKeyedObjectPoolF
         pool.close();
 
 
-        factory = new GenericKeyedObjectPoolFactory(createObjectFactory(), 1, GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, 4);
-        pool = (GenericKeyedObjectPool)factory.createPool();
+        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, 4);
+        pool = (GenericKeyedObjectPool<Object,Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());
@@ -118,8 +119,8 @@ public class TestGenericKeyedObjectPoolF
         pool.close();
 
 
-        factory = new GenericKeyedObjectPoolFactory(createObjectFactory(), 1, GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, true, false);
-        pool = (GenericKeyedObjectPool)factory.createPool();
+        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, true, false);
+        pool = (GenericKeyedObjectPool<Object,Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());
@@ -129,8 +130,8 @@ public class TestGenericKeyedObjectPoolF
         pool.close();
 
 
-        factory = new GenericKeyedObjectPoolFactory(createObjectFactory(), 1, GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, true, false, 4, 5, 6, false);
-        pool = (GenericKeyedObjectPool)factory.createPool();
+        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, true, false, 4, 5, 6, false);
+        pool = (GenericKeyedObjectPool<Object,Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());
@@ -144,8 +145,8 @@ public class TestGenericKeyedObjectPoolF
         pool.close();
 
 
-        factory = new GenericKeyedObjectPoolFactory(createObjectFactory(), 1, GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, 4, true, false, 5, 6, 7, true);
-        pool = (GenericKeyedObjectPool)factory.createPool();
+        factory = new GenericKeyedObjectPoolFactory<Object,Object>(createObjectFactory(), 1, GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, 4, true, false, 5, 6, 7, true);
+        pool = (GenericKeyedObjectPool<Object,Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java?rev=1096374&r1=1096373&r2=1096374&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java Sun Apr 24 20:12:16 2011
@@ -40,24 +40,27 @@ public class TestGenericObjectPool exten
         super(testName);
     }
 
-    protected ObjectPool makeEmptyPool(int mincap) {
-       GenericObjectPool pool = new GenericObjectPool(new SimpleFactory());
+    @Override
+    protected ObjectPool<Object> makeEmptyPool(int mincap) {
+       GenericObjectPool<Object> pool = new GenericObjectPool<Object>(new SimpleFactory());
        pool.setMaxActive(mincap);
        pool.setMaxIdle(mincap);
        return pool;
     }
 
-    protected ObjectPool makeEmptyPool(final PoolableObjectFactory factory) {
-        return new GenericObjectPool(factory);
+    @Override
+    protected ObjectPool<Object> makeEmptyPool(final PoolableObjectFactory<Object> factory) {
+        return new GenericObjectPool<Object>(factory);
     }
 
+    @Override
     protected Object getNthObject(int n) {
         return String.valueOf(n);
     }
 
     public void setUp() throws Exception {
         super.setUp();
-        pool = new GenericObjectPool(new SimpleFactory());
+        pool = new GenericObjectPool<Object>(new SimpleFactory());
     }
 
     public void tearDown() throws Exception {
@@ -228,7 +231,7 @@ public class TestGenericObjectPool exten
     
     private void checkEvictionOrder(boolean lifo) throws Exception {
         SimpleFactory factory = new SimpleFactory();
-        GenericObjectPool pool = new GenericObjectPool(factory);
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
         pool.setNumTestsPerEvictionRun(2);
         pool.setMinEvictableIdleTimeMillis(100);
         pool.setLifo(lifo);
@@ -246,7 +249,7 @@ public class TestGenericObjectPool exten
         
         // Two eviction runs in sequence
         factory = new SimpleFactory();
-        pool = new GenericObjectPool(factory);
+        pool = new GenericObjectPool<Object>(factory);
         pool.setNumTestsPerEvictionRun(2);
         pool.setMinEvictableIdleTimeMillis(100);
         pool.setLifo(lifo);
@@ -270,8 +273,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);
@@ -282,7 +285,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);
@@ -291,7 +294,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());
@@ -302,8 +305,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);
@@ -328,7 +331,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.",
@@ -347,7 +350,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);
@@ -373,10 +376,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 && 
@@ -388,7 +391,7 @@ public class TestGenericObjectPool exten
 
     public void testExceptionOnPassivateDuringReturn() throws Exception {
         SimpleFactory factory = new SimpleFactory();        
-        GenericObjectPool pool = new GenericObjectPool(factory);
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
         Object obj = pool.borrowObject();
         factory.setThrowExceptionOnPassivate(true);
         pool.returnObject(obj);
@@ -399,7 +402,7 @@ public class TestGenericObjectPool exten
     public void testExceptionOnDestroyDuringBorrow() throws Exception {
         SimpleFactory factory = new SimpleFactory(); 
         factory.setThrowExceptionOnDestroy(true);
-        GenericObjectPool pool = new GenericObjectPool(factory);
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
         pool.setTestOnBorrow(true);
         pool.borrowObject();
         factory.setValid(false); // Make validation fail on next borrow attempt
@@ -416,7 +419,7 @@ public class TestGenericObjectPool exten
     public void testExceptionOnDestroyDuringReturn() throws Exception {
         SimpleFactory factory = new SimpleFactory(); 
         factory.setThrowExceptionOnDestroy(true);
-        GenericObjectPool pool = new GenericObjectPool(factory);
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
         pool.setTestOnReturn(true);
         Object obj1 = pool.borrowObject();
         pool.borrowObject();
@@ -428,7 +431,7 @@ public class TestGenericObjectPool exten
     
     public void testExceptionOnActivateDuringBorrow() throws Exception {
         SimpleFactory factory = new SimpleFactory(); 
-        GenericObjectPool pool = new GenericObjectPool(factory);
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
         Object obj1 = pool.borrowObject();
         Object obj2 = pool.borrowObject();
         pool.returnObject(obj1);
@@ -1342,7 +1345,7 @@ public class TestGenericObjectPool exten
         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.");
@@ -1352,9 +1355,9 @@ public class TestGenericObjectPool exten
         op.close();
     }
     
-    protected GenericObjectPool pool = null;
+    protected GenericObjectPool<Object> 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());
@@ -1367,7 +1370,7 @@ public class TestGenericObjectPool exten
         assertEquals("timeBetweenEvictionRunsMillis",expected.timeBetweenEvictionRunsMillis,actual.getTimeBetweenEvictionRunsMillis());
     }
 
-    public class SimpleFactory implements PoolableObjectFactory {
+    public class SimpleFactory implements PoolableObjectFactory<Object> {
         public SimpleFactory() {
             this(true);
         }
@@ -1534,10 +1537,12 @@ public class TestGenericObjectPool exten
             }
         }
     }
+    @Override
     protected boolean isLifo() {
         return true;
     }
 
+    @Override
     protected boolean isFifo() {
         return false;
     }
@@ -1640,7 +1645,7 @@ public class TestGenericObjectPool exten
      * the provided pool returns it after a wait
      */
     static class WaitingTestThread extends Thread {
-        private final GenericObjectPool _pool;
+        private final GenericObjectPool<Object> _pool;
         private final long _pause;
         private Throwable _thrown;
         
@@ -1650,12 +1655,13 @@ public class TestGenericObjectPool exten
         private long ended;
         private String objectId;
 
-        public WaitingTestThread(GenericObjectPool pool, long pause) {
+        public WaitingTestThread(GenericObjectPool<Object> pool, long pause) {
             _pool = pool;
             _pause = pause;
             _thrown = null;
         }
 
+        @Override
         public void run() {
             try {
                 preborrow = System.currentTimeMillis();
@@ -1692,7 +1698,7 @@ 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<Object> pool = new GenericObjectPool<Object>(factory);
         pool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_BLOCK);
         pool.setMaxWait(maxWait);
         pool.setMaxActive(threads);
@@ -1744,7 +1750,7 @@ public class TestGenericObjectPool exten
      */
     public void testMakeConcurrentWithReturn() throws Exception {
         SimpleFactory factory = new SimpleFactory();
-        GenericObjectPool pool = new GenericObjectPool(factory); 
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory); 
         pool.setTestOnBorrow(true);
         factory.setValid(true);
         // Borrow and return an instance, with a short wait

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java?rev=1096374&r1=1096373&r2=1096374&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java Sun Apr 24 20:12:16 2011
@@ -37,13 +37,13 @@ public class TestGenericObjectPoolFactor
         super(name);
     }
 
-    protected ObjectPoolFactory makeFactory(final PoolableObjectFactory objectFactory) throws UnsupportedOperationException {
-        return new GenericObjectPoolFactory(objectFactory);
+    protected ObjectPoolFactory<Object> makeFactory(final PoolableObjectFactory<Object> objectFactory) throws UnsupportedOperationException {
+        return new GenericObjectPoolFactory<Object>(objectFactory);
     }
 
     public void testConstructors() throws Exception {
-        GenericObjectPoolFactory factory = new GenericObjectPoolFactory(new MethodCallPoolableObjectFactory());
-        GenericObjectPool pool;
+        GenericObjectPoolFactory<Object> factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory());
+        GenericObjectPool<Object> pool;
         factory.createPool().close();
 
         final GenericObjectPool.Config config = new GenericObjectPool.Config();
@@ -60,8 +60,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<Object>(new MethodCallPoolableObjectFactory(), config);
+        pool = (GenericObjectPool<Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxIdle());
         assertEquals(3, pool.getMaxWait());
@@ -79,15 +79,15 @@ public class TestGenericObjectPoolFactor
         pool.close();
 
 
-        factory = new GenericObjectPoolFactory(new MethodCallPoolableObjectFactory(), 1);
-        pool = (GenericObjectPool)factory.createPool();
+        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1);
+        pool = (GenericObjectPool<Object>)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<Object>(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_BLOCK, 125);
+        pool = (GenericObjectPool<Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(GenericObjectPool.WHEN_EXHAUSTED_BLOCK, pool.getWhenExhaustedAction());
         assertEquals(125, pool.getMaxWait());
@@ -104,8 +104,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<Object>(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_GROW, 2, true, false);
+        pool = (GenericObjectPool<Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(true, pool.getTestOnBorrow());
@@ -115,8 +115,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<Object>(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_GROW, 2, 3);
+        pool = (GenericObjectPool<Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());
@@ -125,8 +125,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<Object>(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, true, false);
+        pool = (GenericObjectPool<Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());
@@ -137,8 +137,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<Object>(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, true, false, 4, 5, 6, false);
+        pool = (GenericObjectPool<Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());
@@ -153,8 +153,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<Object>(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, 4, true, false, 5, 6, 7, true);
+        pool = (GenericObjectPool<Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());
@@ -170,8 +170,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<Object>(new MethodCallPoolableObjectFactory(), 1, GenericObjectPool.WHEN_EXHAUSTED_GROW, 2, 3, 4, true, false, 5, 6, 7, true, 8, false);
+        pool = (GenericObjectPool<Object>)factory.createPool();
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxWait());
         assertEquals(3, pool.getMaxIdle());



Mime
View raw message