commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1096369 - in /commons/proper/pool/trunk/src/test/org/apache/commons/pool2: TestKeyedObjectPool.java TestKeyedObjectPoolFactory.java TestObjectPool.java TestObjectPoolFactory.java
Date Sun, 24 Apr 2011 20:08:19 GMT
Author: simonetripodi
Date: Sun Apr 24 20:08:19 2011
New Revision: 1096369

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

Modified:
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestKeyedObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestKeyedObjectPoolFactory.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestObjectPoolFactory.java

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestKeyedObjectPool.java?rev=1096369&r1=1096368&r2=1096369&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestKeyedObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestKeyedObjectPool.java Sun
Apr 24 20:08:19 2011
@@ -47,14 +47,15 @@ public abstract class TestKeyedObjectPoo
      * behaviors described in {@link KeyedObjectPool}.
      * Generally speaking there should be no limits on the various object counts.
      */
-    protected abstract KeyedObjectPool makeEmptyPool(KeyedPoolableObjectFactory factory);
+    protected abstract KeyedObjectPool<Object,Object> makeEmptyPool(KeyedPoolableObjectFactory<Object,Object>
factory);
 
     protected final String KEY = "key";
 
     public void testClosedPoolBehavior() throws Exception {
-        final KeyedObjectPool pool;
+        final KeyedObjectPool<Object,Object> pool;
         try {
-            pool = makeEmptyPool(new BaseKeyedPoolableObjectFactory() {
+            pool = makeEmptyPool(new BaseKeyedPoolableObjectFactory<Object,Object>()
{
+                @Override
                 public Object makeObject(final Object key) throws Exception {
                     return new Object();
                 }
@@ -101,13 +102,13 @@ public abstract class TestKeyedObjectPoo
 
     public void testKPOFAddObjectUsage() throws Exception {
         final FailingKeyedPoolableObjectFactory factory = new FailingKeyedPoolableObjectFactory();
-        final KeyedObjectPool pool;
+        final KeyedObjectPool<Object,Object> pool;
         try {
             pool = makeEmptyPool(factory);
         } catch(UnsupportedOperationException uoe) {
             return; // test not supported
         }
-        final List expectedMethods = new ArrayList();
+        final List<MethodCall> expectedMethods = new ArrayList<MethodCall>();
 
         // addObject should make a new object, pasivate it and put it in the pool
         pool.addObject(KEY);
@@ -155,17 +156,17 @@ public abstract class TestKeyedObjectPoo
 
     public void testKPOFBorrowObjectUsages() throws Exception {
         final FailingKeyedPoolableObjectFactory factory = new FailingKeyedPoolableObjectFactory();
-        final KeyedObjectPool pool;
+        final KeyedObjectPool<Object,Object> pool;
         try {
             pool = makeEmptyPool(factory);
         } catch(UnsupportedOperationException uoe) {
             return; // test not supported
         }
-        final List expectedMethods = new ArrayList();
+        final List<MethodCall> expectedMethods = new ArrayList<MethodCall>();
         Object obj;
         
         if (pool instanceof GenericKeyedObjectPool) {
-            ((GenericKeyedObjectPool) pool).setTestOnBorrow(true);
+            ((GenericKeyedObjectPool<Object,Object>) pool).setTestOnBorrow(true);
         }
 
         /// Test correct behavior code paths
@@ -241,13 +242,13 @@ public abstract class TestKeyedObjectPoo
 
     public void testKPOFReturnObjectUsages() throws Exception {
         final FailingKeyedPoolableObjectFactory factory = new FailingKeyedPoolableObjectFactory();
-        final KeyedObjectPool pool;
+        final KeyedObjectPool<Object,Object> pool;
         try {
             pool = makeEmptyPool(factory);
         } catch(UnsupportedOperationException uoe) {
             return; // test not supported
         }
-        final List expectedMethods = new ArrayList();
+        final List<MethodCall> expectedMethods = new ArrayList<MethodCall>();
         Object obj;
 
         /// Test correct behavior code paths
@@ -305,13 +306,13 @@ public abstract class TestKeyedObjectPoo
 
     public void testKPOFInvalidateObjectUsages() throws Exception {
         final FailingKeyedPoolableObjectFactory factory = new FailingKeyedPoolableObjectFactory();
-        final KeyedObjectPool pool;
+        final KeyedObjectPool<Object,Object> pool;
         try {
             pool = makeEmptyPool(factory);
         } catch(UnsupportedOperationException uoe) {
             return; // test not supported
         }
-        final List expectedMethods = new ArrayList();
+        final List<MethodCall> expectedMethods = new ArrayList<MethodCall>();
         Object obj;
 
         /// Test correct behavior code paths
@@ -342,13 +343,13 @@ public abstract class TestKeyedObjectPoo
 
     public void testKPOFClearUsages() throws Exception {
         final FailingKeyedPoolableObjectFactory factory = new FailingKeyedPoolableObjectFactory();
-        final KeyedObjectPool pool;
+        final KeyedObjectPool<Object,Object> pool;
         try {
             pool = makeEmptyPool(factory);
         } catch(UnsupportedOperationException uoe) {
             return; // test not supported
         }
-        final List expectedMethods = new ArrayList();
+        final List<MethodCall> expectedMethods = new ArrayList<MethodCall>();
 
         /// Test correct behavior code paths
         PoolUtils.prefill(pool, KEY, 5);
@@ -363,13 +364,13 @@ public abstract class TestKeyedObjectPoo
 
     public void testKPOFCloseUsages() throws Exception {
         final FailingKeyedPoolableObjectFactory factory = new FailingKeyedPoolableObjectFactory();
-        KeyedObjectPool pool;
+        KeyedObjectPool<Object,Object> pool;
         try {
             pool = makeEmptyPool(factory);
         } catch(UnsupportedOperationException uoe) {
             return; // test not supported
         }
-        final List expectedMethods = new ArrayList();
+        final List<MethodCall> expectedMethods = new ArrayList<MethodCall>();
 
         /// Test correct behavior code paths
         PoolUtils.prefill(pool, KEY, 5);
@@ -393,19 +394,19 @@ public abstract class TestKeyedObjectPoo
         }
     }
 
-    private void reset(final KeyedObjectPool pool, final FailingKeyedPoolableObjectFactory
factory, final List expectedMethods) throws Exception {
+    private void reset(final KeyedObjectPool<Object,Object> pool, final FailingKeyedPoolableObjectFactory
factory, final List<MethodCall> expectedMethods) throws Exception {
         pool.clear();
         clear(factory, expectedMethods);
         factory.reset();
     }
 
-    private void clear(final FailingKeyedPoolableObjectFactory factory, final List expectedMethods)
{
+    private void clear(final FailingKeyedPoolableObjectFactory factory, final List<MethodCall>
expectedMethods) {
         factory.getMethodCalls().clear();
         expectedMethods.clear();
     }
 
-    protected static class FailingKeyedPoolableObjectFactory implements KeyedPoolableObjectFactory
{
-        private final List methodCalls = new ArrayList();
+    protected static class FailingKeyedPoolableObjectFactory implements KeyedPoolableObjectFactory<Object,Object>
{
+        private final List<MethodCall> methodCalls = new ArrayList<MethodCall>();
         private int count = 0;
         private boolean makeObjectFail;
         private boolean activateObjectFail;
@@ -426,7 +427,7 @@ public abstract class TestKeyedObjectPoo
             setDestroyObjectFail(false);
         }
 
-        public List getMethodCalls() {
+        public List<MethodCall> getMethodCalls() {
             return methodCalls;
         }
 

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestKeyedObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestKeyedObjectPoolFactory.java?rev=1096369&r1=1096368&r2=1096369&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestKeyedObjectPoolFactory.java
(original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestKeyedObjectPoolFactory.java
Sun Apr 24 20:08:19 2011
@@ -38,32 +38,32 @@ public abstract class TestKeyedObjectPoo
     /**
      * @throws UnsupportedOperationException when this is unsupported by this KeyedPoolableObjectFactory
type.
      */
-    protected KeyedObjectPoolFactory makeFactory() throws UnsupportedOperationException {
+    protected KeyedObjectPoolFactory<Object,Object> makeFactory() throws UnsupportedOperationException
{
         return makeFactory(createObjectFactory());
     }
 
     /**
      * @throws UnsupportedOperationException when this is unsupported by this KeyedPoolableObjectFactory
type.
      */
-    protected abstract KeyedObjectPoolFactory makeFactory(KeyedPoolableObjectFactory objectFactory)
throws UnsupportedOperationException;
+    protected abstract KeyedObjectPoolFactory<Object,Object> makeFactory(KeyedPoolableObjectFactory<Object,Object>
objectFactory) throws UnsupportedOperationException;
 
-    protected static KeyedPoolableObjectFactory createObjectFactory() {
+    protected static KeyedPoolableObjectFactory<Object,Object> createObjectFactory()
{
         return PoolUtils.adapt(new MethodCallPoolableObjectFactory());
     }
 
     public void testCreatePool() throws Exception {
-        final KeyedObjectPoolFactory factory;
+        final KeyedObjectPoolFactory<Object,Object> factory;
         try {
             factory = makeFactory();
         } catch (UnsupportedOperationException uoe) {
             return;
         }
-        final KeyedObjectPool pool = factory.createPool();
+        final KeyedObjectPool<Object,Object> pool = factory.createPool();
         pool.close();
     }
 
     public void testToString() {
-        final KeyedObjectPoolFactory factory;
+        final KeyedObjectPoolFactory<Object,Object> factory;
         try {
             factory = makeFactory();
         } catch (UnsupportedOperationException uoe) {

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestObjectPool.java?rev=1096369&r1=1096368&r2=1096369&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestObjectPool.java Sun Apr
24 20:08:19 2011
@@ -48,10 +48,10 @@ public abstract class TestObjectPool ext
      * Generally speaking there should be no limits on the various object counts.
      * @throws UnsupportedOperationException if the pool being tested does not follow pool
contracts.
      */
-    protected abstract ObjectPool makeEmptyPool(PoolableObjectFactory factory) throws UnsupportedOperationException;
+    protected abstract ObjectPool<Object> makeEmptyPool(PoolableObjectFactory<Object>
factory) throws UnsupportedOperationException;
 
     public void testClosedPoolBehavior() throws Exception {
-        final ObjectPool pool;
+        final ObjectPool<Object> pool;
         try {
             pool = makeEmptyPool(new MethodCallPoolableObjectFactory());
         } catch (UnsupportedOperationException uoe) {
@@ -106,13 +106,13 @@ public abstract class TestObjectPool ext
 
     public void testPOFAddObjectUsage() throws Exception {
         final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory();
-        final ObjectPool pool;
+        final ObjectPool<Object> pool;
         try {
             pool = makeEmptyPool(factory);
         } catch(UnsupportedOperationException uoe) {
             return; // test not supported
         }
-        final List expectedMethods = new ArrayList();
+        final List<MethodCall> expectedMethods = new ArrayList<MethodCall>();
 
         assertEquals(0, pool.getNumActive());
         assertEquals(0, pool.getNumIdle());
@@ -168,16 +168,16 @@ public abstract class TestObjectPool ext
 
     public void testPOFBorrowObjectUsages() throws Exception {
         final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory();
-        final ObjectPool pool;
+        final ObjectPool<Object> pool;
         try {
             pool = makeEmptyPool(factory);
         } catch (UnsupportedOperationException uoe) {
             return; // test not supported
         }
         if (pool instanceof GenericObjectPool) {
-            ((GenericObjectPool) pool).setTestOnBorrow(true);
+            ((GenericObjectPool<Object>) pool).setTestOnBorrow(true);
         }
-        final List expectedMethods = new ArrayList();
+        final List<MethodCall> expectedMethods = new ArrayList<MethodCall>();
         Object obj;
 
         /// Test correct behavior code paths
@@ -250,13 +250,13 @@ public abstract class TestObjectPool ext
 
     public void testPOFReturnObjectUsages() throws Exception {
         final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory();
-        final ObjectPool pool;
+        final ObjectPool<Object> pool;
         try {
             pool = makeEmptyPool(factory);
         } catch (UnsupportedOperationException uoe) {
             return; // test not supported
         }
-        final List expectedMethods = new ArrayList();
+        final List<MethodCall> expectedMethods = new ArrayList<MethodCall>();
         Object obj;
 
         /// Test correct behavior code paths
@@ -311,13 +311,13 @@ public abstract class TestObjectPool ext
 
     public void testPOFInvalidateObjectUsages() throws Exception {
         final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory();
-        final ObjectPool pool;
+        final ObjectPool<Object> pool;
         try {
             pool = makeEmptyPool(factory);
         } catch (UnsupportedOperationException uoe) {
             return; // test not supported
         }
-        final List expectedMethods = new ArrayList();
+        final List<MethodCall> expectedMethods = new ArrayList<MethodCall>();
         Object obj;
 
         /// Test correct behavior code paths
@@ -348,13 +348,13 @@ public abstract class TestObjectPool ext
 
     public void testPOFClearUsages() throws Exception {
         final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory();
-        final ObjectPool pool;
+        final ObjectPool<Object> pool;
         try {
             pool = makeEmptyPool(factory);
         } catch (UnsupportedOperationException uoe) {
             return; // test not supported
         }
-        final List expectedMethods = new ArrayList();
+        final List<MethodCall> expectedMethods = new ArrayList<MethodCall>();
 
         /// Test correct behavior code paths
         PoolUtils.prefill(pool, 5);
@@ -369,13 +369,13 @@ public abstract class TestObjectPool ext
 
     public void testPOFCloseUsages() throws Exception {
         final MethodCallPoolableObjectFactory factory = new MethodCallPoolableObjectFactory();
-        ObjectPool pool;
+        ObjectPool<Object> pool;
         try {
             pool = makeEmptyPool(factory);
         } catch (UnsupportedOperationException uoe) {
             return; // test not supported
         }
-        final List expectedMethods = new ArrayList();
+        final List<MethodCall> expectedMethods = new ArrayList<MethodCall>();
 
         /// Test correct behavior code paths
         PoolUtils.prefill(pool, 5);
@@ -395,7 +395,7 @@ public abstract class TestObjectPool ext
     }
 
     public void testSetFactory() throws Exception {
-        ObjectPool pool;
+        ObjectPool<Object> pool;
         try {
             pool = makeEmptyPool(new MethodCallPoolableObjectFactory());
         } catch (UnsupportedOperationException uoe) {
@@ -410,7 +410,7 @@ public abstract class TestObjectPool ext
     }
 
     public void testToString() {
-        ObjectPool pool;
+        ObjectPool<Object> pool;
         try {
             pool = makeEmptyPool(new MethodCallPoolableObjectFactory());
         } catch (UnsupportedOperationException uoe) {
@@ -419,23 +419,23 @@ public abstract class TestObjectPool ext
         pool.toString();
     }
 
-    static void removeDestroyObjectCall(List calls) {
-        Iterator iter = calls.iterator();
+    static void removeDestroyObjectCall(List<MethodCall> calls) {
+        Iterator<MethodCall> iter = calls.iterator();
         while (iter.hasNext()) {
-            MethodCall call = (MethodCall)iter.next();
+            MethodCall call = iter.next();
             if ("destroyObject".equals(call.getName())) {
                 iter.remove();
             }
         }
     }
 
-    private static void reset(final ObjectPool pool, final MethodCallPoolableObjectFactory
factory, final List expectedMethods) throws Exception {
+    private static void reset(final ObjectPool<Object> pool, final MethodCallPoolableObjectFactory
factory, final List<MethodCall> expectedMethods) throws Exception {
         pool.clear();
         clear(factory, expectedMethods);
         factory.reset();
     }
 
-    private static void clear(final MethodCallPoolableObjectFactory factory, final List expectedMethods)
{
+    private static void clear(final MethodCallPoolableObjectFactory factory, final List<MethodCall>
expectedMethods) {
         factory.getMethodCalls().clear();
         expectedMethods.clear();
     }

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestObjectPoolFactory.java?rev=1096369&r1=1096368&r2=1096369&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestObjectPoolFactory.java
(original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestObjectPoolFactory.java
Sun Apr 24 20:08:19 2011
@@ -37,28 +37,28 @@ public abstract class TestObjectPoolFact
     /**
      * @throws UnsupportedOperationException when this is unsupported by this PoolableObjectFactory
type.
      */
-    protected ObjectPoolFactory makeFactory() throws UnsupportedOperationException {
+    protected ObjectPoolFactory<Object> makeFactory() throws UnsupportedOperationException
{
         return makeFactory(new MethodCallPoolableObjectFactory());
     }
 
     /**
      * @throws UnsupportedOperationException when this is unsupported by this PoolableObjectFactory
type.
      */
-    protected abstract ObjectPoolFactory makeFactory(PoolableObjectFactory objectFactory)
throws UnsupportedOperationException;
+    protected abstract ObjectPoolFactory<Object> makeFactory(PoolableObjectFactory<Object>
objectFactory) throws UnsupportedOperationException;
 
     public void testCreatePool() throws Exception {
-        final ObjectPoolFactory factory;
+        final ObjectPoolFactory<Object> factory;
         try {
             factory = makeFactory();
         } catch (UnsupportedOperationException uoe) {
             return;
         }
-        final ObjectPool pool = factory.createPool();
+        final ObjectPool<Object> pool = factory.createPool();
         pool.close();
     }
 
     public void testToString() {
-        final ObjectPoolFactory factory;
+        final ObjectPoolFactory<Object> factory;
         try {
             factory = makeFactory();
         } catch (UnsupportedOperationException uoe) {



Mime
View raw message