Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C2A4A1E3E for ; Sun, 24 Apr 2011 20:08:41 +0000 (UTC) Received: (qmail 40829 invoked by uid 500); 24 Apr 2011 20:08:41 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 40763 invoked by uid 500); 24 Apr 2011 20:08:41 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 40756 invoked by uid 99); 24 Apr 2011 20:08:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 24 Apr 2011 20:08:41 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 24 Apr 2011 20:08:39 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BDBC823889ED; Sun, 24 Apr 2011 20:08:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@commons.apache.org From: simonetripodi@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110424200819.BDBC823889ED@eris.apache.org> 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 makeEmptyPool(KeyedPoolableObjectFactory factory); protected final String KEY = "key"; public void testClosedPoolBehavior() throws Exception { - final KeyedObjectPool pool; + final KeyedObjectPool pool; try { - pool = makeEmptyPool(new BaseKeyedPoolableObjectFactory() { + pool = makeEmptyPool(new BaseKeyedPoolableObjectFactory() { + @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 pool; try { pool = makeEmptyPool(factory); } catch(UnsupportedOperationException uoe) { return; // test not supported } - final List expectedMethods = new ArrayList(); + final List expectedMethods = new ArrayList(); // 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 pool; try { pool = makeEmptyPool(factory); } catch(UnsupportedOperationException uoe) { return; // test not supported } - final List expectedMethods = new ArrayList(); + final List expectedMethods = new ArrayList(); Object obj; if (pool instanceof GenericKeyedObjectPool) { - ((GenericKeyedObjectPool) pool).setTestOnBorrow(true); + ((GenericKeyedObjectPool) 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 pool; try { pool = makeEmptyPool(factory); } catch(UnsupportedOperationException uoe) { return; // test not supported } - final List expectedMethods = new ArrayList(); + final List expectedMethods = new ArrayList(); 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 pool; try { pool = makeEmptyPool(factory); } catch(UnsupportedOperationException uoe) { return; // test not supported } - final List expectedMethods = new ArrayList(); + final List expectedMethods = new ArrayList(); 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 pool; try { pool = makeEmptyPool(factory); } catch(UnsupportedOperationException uoe) { return; // test not supported } - final List expectedMethods = new ArrayList(); + final List expectedMethods = new ArrayList(); /// 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 pool; try { pool = makeEmptyPool(factory); } catch(UnsupportedOperationException uoe) { return; // test not supported } - final List expectedMethods = new ArrayList(); + final List expectedMethods = new ArrayList(); /// 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 pool, final FailingKeyedPoolableObjectFactory factory, final List 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 expectedMethods) { factory.getMethodCalls().clear(); expectedMethods.clear(); } - protected static class FailingKeyedPoolableObjectFactory implements KeyedPoolableObjectFactory { - private final List methodCalls = new ArrayList(); + protected static class FailingKeyedPoolableObjectFactory implements KeyedPoolableObjectFactory { + private final List methodCalls = new ArrayList(); 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 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 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 makeFactory(KeyedPoolableObjectFactory objectFactory) throws UnsupportedOperationException; - protected static KeyedPoolableObjectFactory createObjectFactory() { + protected static KeyedPoolableObjectFactory createObjectFactory() { return PoolUtils.adapt(new MethodCallPoolableObjectFactory()); } public void testCreatePool() throws Exception { - final KeyedObjectPoolFactory factory; + final KeyedObjectPoolFactory factory; try { factory = makeFactory(); } catch (UnsupportedOperationException uoe) { return; } - final KeyedObjectPool pool = factory.createPool(); + final KeyedObjectPool pool = factory.createPool(); pool.close(); } public void testToString() { - final KeyedObjectPoolFactory factory; + final KeyedObjectPoolFactory 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 makeEmptyPool(PoolableObjectFactory factory) throws UnsupportedOperationException; public void testClosedPoolBehavior() throws Exception { - final ObjectPool pool; + final ObjectPool 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 pool; try { pool = makeEmptyPool(factory); } catch(UnsupportedOperationException uoe) { return; // test not supported } - final List expectedMethods = new ArrayList(); + final List expectedMethods = new ArrayList(); 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 pool; try { pool = makeEmptyPool(factory); } catch (UnsupportedOperationException uoe) { return; // test not supported } if (pool instanceof GenericObjectPool) { - ((GenericObjectPool) pool).setTestOnBorrow(true); + ((GenericObjectPool) pool).setTestOnBorrow(true); } - final List expectedMethods = new ArrayList(); + final List expectedMethods = new ArrayList(); 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 pool; try { pool = makeEmptyPool(factory); } catch (UnsupportedOperationException uoe) { return; // test not supported } - final List expectedMethods = new ArrayList(); + final List expectedMethods = new ArrayList(); 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 pool; try { pool = makeEmptyPool(factory); } catch (UnsupportedOperationException uoe) { return; // test not supported } - final List expectedMethods = new ArrayList(); + final List expectedMethods = new ArrayList(); 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 pool; try { pool = makeEmptyPool(factory); } catch (UnsupportedOperationException uoe) { return; // test not supported } - final List expectedMethods = new ArrayList(); + final List expectedMethods = new ArrayList(); /// 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 pool; try { pool = makeEmptyPool(factory); } catch (UnsupportedOperationException uoe) { return; // test not supported } - final List expectedMethods = new ArrayList(); + final List expectedMethods = new ArrayList(); /// 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 pool; try { pool = makeEmptyPool(new MethodCallPoolableObjectFactory()); } catch (UnsupportedOperationException uoe) { @@ -410,7 +410,7 @@ public abstract class TestObjectPool ext } public void testToString() { - ObjectPool pool; + ObjectPool 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 calls) { + Iterator 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 pool, final MethodCallPoolableObjectFactory factory, final List 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 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 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 makeFactory(PoolableObjectFactory objectFactory) throws UnsupportedOperationException; public void testCreatePool() throws Exception { - final ObjectPoolFactory factory; + final ObjectPoolFactory factory; try { factory = makeFactory(); } catch (UnsupportedOperationException uoe) { return; } - final ObjectPool pool = factory.createPool(); + final ObjectPool pool = factory.createPool(); pool.close(); } public void testToString() { - final ObjectPoolFactory factory; + final ObjectPoolFactory factory; try { factory = makeFactory(); } catch (UnsupportedOperationException uoe) {