commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sandy...@apache.org
Subject svn commit: r389997 - in /jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool: ./ composite/ impl/
Date Thu, 30 Mar 2006 05:44:14 GMT
Author: sandymac
Date: Wed Mar 29 21:44:13 2006
New Revision: 389997

URL: http://svn.apache.org/viewcvs?rev=389997&view=rev
Log:
Reworked and created unit tests for KeyedObjectPool and implementations.

Added:
    jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPool.java
  (with props)
    jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPool2.java
  (with props)
Modified:
    jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseKeyedObjectPool.java
    jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseObjectPool.java
    jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestKeyedObjectPool.java
    jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestAll.java
    jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeObjectPool.java
    jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestWaitLimitManager.java
    jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
    jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java

Modified: jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseKeyedObjectPool.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseKeyedObjectPool.java?rev=389997&r1=389996&r2=389997&view=diff
==============================================================================
--- jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseKeyedObjectPool.java
(original)
+++ jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseKeyedObjectPool.java
Wed Mar 29 21:44:13 2006
@@ -16,7 +16,6 @@
 package org.apache.commons.pool;
 
 import junit.framework.Test;
-import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
 /**
@@ -24,17 +23,71 @@
  * @author Sandy McArthur
  * @version $Revision$ $Date$
  */
-public class TestBaseKeyedObjectPool extends TestCase {
-    public TestBaseKeyedObjectPool(String testName) {
+public class TestBaseKeyedObjectPool extends TestKeyedObjectPool {
+    private KeyedObjectPool _pool = null;
+
+    public TestBaseKeyedObjectPool(final String testName) {
         super(testName);
     }
 
+    protected KeyedObjectPool makeEmptyPool(KeyedPoolableObjectFactory factory) {
+        if (this.getClass() != TestBaseKeyedObjectPool.class) {
+            throw new AssertionError("Subclasses of TestBaseKeyedObjectPool must reimplement
this method.");
+        }
+        throw new UnsupportedOperationException("BaseKeyedObjectPool isn't a complete implementation.");
+    }
+
+    /**
+     * Create an {@link KeyedObjectPool} instance
+     * that can contain at least <i>mincapacity</i>
+     * idle and active objects, or
+     * throw {@link IllegalArgumentException}
+     * if such a pool cannot be created.
+     */
+    protected KeyedObjectPool makeEmptyPool(int mincapacity) {
+        if (this.getClass() != TestBaseKeyedObjectPool.class) {
+            throw new AssertionError("Subclasses of TestBaseKeyedObjectPool must reimplement
this method.");
+        }
+        throw new UnsupportedOperationException("BaseKeyedObjectPool isn't a complete implementation.");
+    }
+
+    /**
+     * Return what we expect to be the n<sup>th</sup>
+     * object (zero indexed) created by the pool
+     * for the given key.
+     */
+    protected Object getNthObject(Object key, int n) {
+        if (this.getClass() != TestBaseKeyedObjectPool.class) {
+            throw new AssertionError("Subclasses of TestBaseKeyedObjectPool must reimplement
this method.");
+        }
+        throw new UnsupportedOperationException("BaseKeyedObjectPool isn't a complete implementation.");
+    }
+
+    protected Object makeKey(int n) {
+        if (this.getClass() != TestBaseKeyedObjectPool.class) {
+            throw new AssertionError("Subclasses of TestBaseKeyedObjectPool must reimplement
this method.");
+        }
+        throw new UnsupportedOperationException("BaseKeyedObjectPool isn't a complete implementation.");
+    }
+
     public static Test suite() {
         return new TestSuite(TestBaseKeyedObjectPool.class);
     }
-    
+
     // tests
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+
+    public void tearDown() throws Exception {
+        _pool = null;
+        super.tearDown();
+    }
+
     public void testUnsupportedOperations() throws Exception {
+        if (!getClass().equals(TestBaseKeyedObjectPool.class)) {
+            return; // skip redundant tests
+        }
         KeyedObjectPool pool = new BaseKeyedObjectPool() { 
             public Object borrowObject(Object key) throws Exception {
                 return null;
@@ -43,7 +96,7 @@
             }
             public void invalidateObject(Object key, Object obj) throws Exception {     
          
             }            
-        };   
+        };
         
         try {
             pool.addObject("key");
@@ -80,5 +133,232 @@
 
         pool.close(); // a no-op, probably should be remove
 
+    }
+
+    protected boolean isLifo() {
+        if (getClass() != TestBaseKeyedObjectPool.class) {
+            throw new AssertionError("Subclasses of TestBaseKeyedObjectPool must reimplement
this method.");
+        }
+        return false;
+    }
+
+    protected boolean isFifo() {
+        if (getClass() != TestBaseKeyedObjectPool.class) {
+            throw new AssertionError("Subclasses of TestBaseKeyedObjectPool must reimplement
this method.");
+        }
+        return false;
+    }
+
+    public void testBaseBorrowReturn() throws Exception {
+        try {
+            _pool = makeEmptyPool(3);
+        } catch(UnsupportedOperationException uoe) {
+            return; // skip this test if unsupported
+        }
+        Object keya = makeKey(0);
+        Object obj0 = _pool.borrowObject(keya);
+        assertEquals(getNthObject(keya,0),obj0);
+        Object obj1 = _pool.borrowObject(keya);
+        assertEquals(getNthObject(keya,1),obj1);
+        Object obj2 = _pool.borrowObject(keya);
+        assertEquals(getNthObject(keya,2),obj2);
+        _pool.returnObject(keya,obj2);
+        obj2 = _pool.borrowObject(keya);
+        assertEquals(getNthObject(keya,2),obj2);
+        _pool.returnObject(keya,obj1);
+        obj1 = _pool.borrowObject(keya);
+        assertEquals(getNthObject(keya,1),obj1);
+        _pool.returnObject(keya,obj0);
+        _pool.returnObject(keya,obj2);
+        obj2 = _pool.borrowObject(keya);
+        if (isLifo()) {
+            assertEquals(getNthObject(keya,2),obj2);
+        }
+        if (isFifo()) {
+            assertEquals(getNthObject(keya,0),obj2);
+        }
+        obj0 = _pool.borrowObject(keya);
+        if (isLifo()) {
+            assertEquals(getNthObject(keya,0),obj0);
+        }
+        if (isFifo()) {
+            assertEquals(getNthObject(keya,2),obj0);
+        }
+    }
+
+    public void testBaseBorrow() throws Exception {
+        try {
+            _pool = makeEmptyPool(3);
+        } catch(UnsupportedOperationException uoe) {
+            return; // skip this test if unsupported
+        }
+        Object keya = makeKey(0);
+        Object keyb = makeKey(1);
+        assertEquals("1",getNthObject(keya,0),_pool.borrowObject(keya));
+        assertEquals("2",getNthObject(keyb,0),_pool.borrowObject(keyb));
+        assertEquals("3",getNthObject(keyb,1),_pool.borrowObject(keyb));
+        assertEquals("4",getNthObject(keya,1),_pool.borrowObject(keya));
+        assertEquals("5",getNthObject(keyb,2),_pool.borrowObject(keyb));
+        assertEquals("6",getNthObject(keya,2),_pool.borrowObject(keya));
+    }
+
+    public void testBaseNumActiveNumIdle() throws Exception {
+        try {
+            _pool = makeEmptyPool(3);
+        } catch(UnsupportedOperationException uoe) {
+            return; // skip this test if unsupported
+        }
+        Object keya = makeKey(0);
+        assertEquals(0,_pool.getNumActive(keya));
+        assertEquals(0,_pool.getNumIdle(keya));
+        Object obj0 = _pool.borrowObject(keya);
+        assertEquals(1,_pool.getNumActive(keya));
+        assertEquals(0,_pool.getNumIdle(keya));
+        Object obj1 = _pool.borrowObject(keya);
+        assertEquals(2,_pool.getNumActive(keya));
+        assertEquals(0,_pool.getNumIdle(keya));
+        _pool.returnObject(keya,obj1);
+        assertEquals(1,_pool.getNumActive(keya));
+        assertEquals(1,_pool.getNumIdle(keya));
+        _pool.returnObject(keya,obj0);
+        assertEquals(0,_pool.getNumActive(keya));
+        assertEquals(2,_pool.getNumIdle(keya));
+
+        assertEquals(0,_pool.getNumActive("xyzzy12345"));
+        assertEquals(0,_pool.getNumIdle("xyzzy12345"));
+    }
+
+    public void testBaseNumActiveNumIdle2() throws Exception {
+        try {
+            _pool = makeEmptyPool(6);
+        } catch(UnsupportedOperationException uoe) {
+            return; // skip this test if unsupported
+        }
+        Object keya = makeKey(0);
+        Object keyb = makeKey(1);
+        assertEquals(0,_pool.getNumActive());
+        assertEquals(0,_pool.getNumIdle());
+        assertEquals(0,_pool.getNumActive(keya));
+        assertEquals(0,_pool.getNumIdle(keya));
+        assertEquals(0,_pool.getNumActive(keyb));
+        assertEquals(0,_pool.getNumIdle(keyb));
+
+        Object objA0 = _pool.borrowObject(keya);
+        Object objB0 = _pool.borrowObject(keyb);
+
+        assertEquals(2,_pool.getNumActive());
+        assertEquals(0,_pool.getNumIdle());
+        assertEquals(1,_pool.getNumActive(keya));
+        assertEquals(0,_pool.getNumIdle(keya));
+        assertEquals(1,_pool.getNumActive(keyb));
+        assertEquals(0,_pool.getNumIdle(keyb));
+
+        Object objA1 = _pool.borrowObject(keya);
+        Object objB1 = _pool.borrowObject(keyb);
+
+        assertEquals(4,_pool.getNumActive());
+        assertEquals(0,_pool.getNumIdle());
+        assertEquals(2,_pool.getNumActive(keya));
+        assertEquals(0,_pool.getNumIdle(keya));
+        assertEquals(2,_pool.getNumActive(keyb));
+        assertEquals(0,_pool.getNumIdle(keyb));
+
+        _pool.returnObject(keya,objA0);
+        _pool.returnObject(keyb,objB0);
+
+        assertEquals(2,_pool.getNumActive());
+        assertEquals(2,_pool.getNumIdle());
+        assertEquals(1,_pool.getNumActive(keya));
+        assertEquals(1,_pool.getNumIdle(keya));
+        assertEquals(1,_pool.getNumActive(keyb));
+        assertEquals(1,_pool.getNumIdle(keyb));
+
+        _pool.returnObject(keya,objA1);
+        _pool.returnObject(keyb,objB1);
+
+        assertEquals(0,_pool.getNumActive());
+        assertEquals(4,_pool.getNumIdle());
+        assertEquals(0,_pool.getNumActive(keya));
+        assertEquals(2,_pool.getNumIdle(keya));
+        assertEquals(0,_pool.getNumActive(keyb));
+        assertEquals(2,_pool.getNumIdle(keyb));
+    }
+
+    public void testBaseClear() throws Exception {
+        try {
+            _pool = makeEmptyPool(3);
+        } catch(UnsupportedOperationException uoe) {
+            return; // skip this test if unsupported
+        }
+        Object keya = makeKey(0);
+        assertEquals(0,_pool.getNumActive(keya));
+        assertEquals(0,_pool.getNumIdle(keya));
+        Object obj0 = _pool.borrowObject(keya);
+        Object obj1 = _pool.borrowObject(keya);
+        assertEquals(2,_pool.getNumActive(keya));
+        assertEquals(0,_pool.getNumIdle(keya));
+        _pool.returnObject(keya,obj1);
+        _pool.returnObject(keya,obj0);
+        assertEquals(0,_pool.getNumActive(keya));
+        assertEquals(2,_pool.getNumIdle(keya));
+        _pool.clear(keya);
+        assertEquals(0,_pool.getNumActive(keya));
+        assertEquals(0,_pool.getNumIdle(keya));
+        Object obj2 = _pool.borrowObject(keya);
+        assertEquals(getNthObject(keya,2),obj2);
+    }
+
+    public void testBaseInvalidateObject() throws Exception {
+        try {
+            _pool = makeEmptyPool(3);
+        } catch(UnsupportedOperationException uoe) {
+            return; // skip this test if unsupported
+        }
+        Object keya = makeKey(0);
+        assertEquals(0,_pool.getNumActive(keya));
+        assertEquals(0,_pool.getNumIdle(keya));
+        Object obj0 = _pool.borrowObject(keya);
+        Object obj1 = _pool.borrowObject(keya);
+        assertEquals(2,_pool.getNumActive(keya));
+        assertEquals(0,_pool.getNumIdle(keya));
+        _pool.invalidateObject(keya,obj0);
+        assertEquals(1,_pool.getNumActive(keya));
+        assertEquals(0,_pool.getNumIdle(keya));
+        _pool.invalidateObject(keya,obj1);
+        assertEquals(0,_pool.getNumActive(keya));
+        assertEquals(0,_pool.getNumIdle(keya));
+    }
+
+    public void testBaseAddObject() throws Exception {
+        try {
+            _pool = makeEmptyPool(3);
+        } catch(UnsupportedOperationException uoe) {
+            return; // skip this test if unsupported
+        }
+        Object key = makeKey(0);
+        try {
+            assertEquals(0,_pool.getNumIdle());
+            assertEquals(0,_pool.getNumActive());
+            assertEquals(0,_pool.getNumIdle(key));
+            assertEquals(0,_pool.getNumActive(key));
+            _pool.addObject(key);
+            assertEquals(1,_pool.getNumIdle());
+            assertEquals(0,_pool.getNumActive());
+            assertEquals(1,_pool.getNumIdle(key));
+            assertEquals(0,_pool.getNumActive(key));
+            Object obj = _pool.borrowObject(key);
+            assertEquals(getNthObject(key,0),obj);
+            assertEquals(0,_pool.getNumIdle());
+            assertEquals(1,_pool.getNumActive());
+            assertEquals(0,_pool.getNumIdle(key));
+            assertEquals(1,_pool.getNumActive(key));
+            _pool.returnObject(key,obj);
+            assertEquals(1,_pool.getNumIdle());
+            assertEquals(0,_pool.getNumActive());
+            assertEquals(1,_pool.getNumIdle(key));
+            assertEquals(0,_pool.getNumActive(key));
+        } catch(UnsupportedOperationException e) {
+            return; // skip this test if one of those calls is unsupported
+        }
     }
 }

Modified: jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseObjectPool.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseObjectPool.java?rev=389997&r1=389996&r2=389997&view=diff
==============================================================================
--- jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseObjectPool.java
(original)
+++ jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestBaseObjectPool.java
Wed Mar 29 21:44:13 2006
@@ -71,6 +71,9 @@
 
     // tests
     public void testUnsupportedOperations() throws Exception {
+        if (!getClass().equals(TestBaseObjectPool.class)) {
+            return; // skip redundant tests
+        }
         ObjectPool pool = new BaseObjectPool() { 
             public Object borrowObject() throws Exception {
                 return null;

Modified: jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestKeyedObjectPool.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestKeyedObjectPool.java?rev=389997&r1=389996&r2=389997&view=diff
==============================================================================
--- jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestKeyedObjectPool.java
(original)
+++ jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/TestKeyedObjectPool.java
Wed Mar 29 21:44:13 2006
@@ -32,15 +32,6 @@
     }
 
     /**
-     * Create an {@link KeyedObjectPool} instance
-     * that can contain at least <i>mincapacity</i>
-     * idle and active objects, or
-     * throw {@link IllegalArgumentException}
-     * if such a pool cannot be created.
-     */
-    protected abstract KeyedObjectPool makeEmptyPool(int mincapacity);
-
-    /**
      * Create an <code>KeyedObjectPool</code> with the specified factory.
      * The pool should be in a default configuration and conform to the expected
      * behaviors described in {@link KeyedObjectPool}.
@@ -48,253 +39,20 @@
      */
     protected abstract KeyedObjectPool makeEmptyPool(KeyedPoolableObjectFactory factory);
 
-    /**
-     * Return what we expect to be the n<sup>th</sup>
-     * object (zero indexed) created by the pool
-     * for the given key.
-     */
-    protected abstract Object getNthObject(Object key, int n);
-
-    protected abstract Object makeKey(int n);
-
-    /**
-     * Is the implementations LIFO?
-     */
-    protected abstract boolean isLifo();
-
-    /**
-     * Is the implementationn FIFO?
-     */
-    protected abstract boolean isFifo();
-
-    public void setUp() throws Exception {
-    }
-
-    public void tearDown() throws Exception {
-        _pool = null;
-    }
-
-    public void testBaseBorrow() throws Exception {
-        try {
-            _pool = makeEmptyPool(3);
-        } catch(IllegalArgumentException e) {
-            return; // skip this test if unsupported
-        }
-        Object keya = makeKey(0);
-        Object keyb = makeKey(1);
-        assertEquals("1",getNthObject(keya,0),_pool.borrowObject(keya));
-        assertEquals("2",getNthObject(keyb,0),_pool.borrowObject(keyb));
-        assertEquals("3",getNthObject(keyb,1),_pool.borrowObject(keyb));
-        assertEquals("4",getNthObject(keya,1),_pool.borrowObject(keya));
-        assertEquals("5",getNthObject(keyb,2),_pool.borrowObject(keyb));
-        assertEquals("6",getNthObject(keya,2),_pool.borrowObject(keya));
-    }
+    protected final String KEY = "key";
 
-    public void testBaseBorrowReturn() throws Exception {
-        try {
-            _pool = makeEmptyPool(3);
-        } catch(IllegalArgumentException e) {
-            return; // skip this test if unsupported
-        }
-        Object keya = makeKey(0);
-        Object obj0 = _pool.borrowObject(keya);
-        assertEquals(getNthObject(keya,0),obj0);
-        Object obj1 = _pool.borrowObject(keya);
-        assertEquals(getNthObject(keya,1),obj1);
-        Object obj2 = _pool.borrowObject(keya);
-        assertEquals(getNthObject(keya,2),obj2);
-        _pool.returnObject(keya,obj2);
-        obj2 = _pool.borrowObject(keya);
-        assertEquals(getNthObject(keya,2),obj2);
-        _pool.returnObject(keya,obj1);
-        obj1 = _pool.borrowObject(keya);
-        assertEquals(getNthObject(keya,1),obj1);
-        _pool.returnObject(keya,obj0);
-        _pool.returnObject(keya,obj2);
-        obj2 = _pool.borrowObject(keya);
-        if (isLifo()) {
-            assertEquals(getNthObject(keya,2),obj2);
-        }
-        if (isFifo()) {
-            assertEquals(getNthObject(keya,0),obj2);
-        }
-        obj0 = _pool.borrowObject(keya);
-        if (isLifo()) {
-            assertEquals(getNthObject(keya,0),obj0);
-        }
-        if (isFifo()) {
-            assertEquals(getNthObject(keya,2),obj0);
-        }
-    }
-
-    public void testBaseNumActiveNumIdle() throws Exception {
-        try {
-            _pool = makeEmptyPool(3);
-        } catch(IllegalArgumentException e) {
-            return; // skip this test if unsupported
-        }
-        Object keya = makeKey(0);
-        assertEquals(0,_pool.getNumActive(keya));
-        assertEquals(0,_pool.getNumIdle(keya));
-        Object obj0 = _pool.borrowObject(keya);
-        assertEquals(1,_pool.getNumActive(keya));
-        assertEquals(0,_pool.getNumIdle(keya));
-        Object obj1 = _pool.borrowObject(keya);
-        assertEquals(2,_pool.getNumActive(keya));
-        assertEquals(0,_pool.getNumIdle(keya));
-        _pool.returnObject(keya,obj1);
-        assertEquals(1,_pool.getNumActive(keya));
-        assertEquals(1,_pool.getNumIdle(keya));
-        _pool.returnObject(keya,obj0);
-        assertEquals(0,_pool.getNumActive(keya));
-        assertEquals(2,_pool.getNumIdle(keya));
-
-        assertEquals(0,_pool.getNumActive("xyzzy12345"));
-        assertEquals(0,_pool.getNumIdle("xyzzy12345"));
-    }
-
-    public void testBaseNumActiveNumIdle2() throws Exception {
-        try {
-            _pool = makeEmptyPool(6);
-        } catch(IllegalArgumentException e) {
-            return; // skip this test if unsupported
-        }
-        Object keya = makeKey(0);
-        Object keyb = makeKey(1);
-        assertEquals(0,_pool.getNumActive());
-        assertEquals(0,_pool.getNumIdle());
-        assertEquals(0,_pool.getNumActive(keya));
-        assertEquals(0,_pool.getNumIdle(keya));
-        assertEquals(0,_pool.getNumActive(keyb));
-        assertEquals(0,_pool.getNumIdle(keyb));
-
-        Object objA0 = _pool.borrowObject(keya);
-        Object objB0 = _pool.borrowObject(keyb);
-
-        assertEquals(2,_pool.getNumActive());
-        assertEquals(0,_pool.getNumIdle());
-        assertEquals(1,_pool.getNumActive(keya));
-        assertEquals(0,_pool.getNumIdle(keya));
-        assertEquals(1,_pool.getNumActive(keyb));
-        assertEquals(0,_pool.getNumIdle(keyb));
-
-        Object objA1 = _pool.borrowObject(keya);
-        Object objB1 = _pool.borrowObject(keyb);
-
-        assertEquals(4,_pool.getNumActive());
-        assertEquals(0,_pool.getNumIdle());
-        assertEquals(2,_pool.getNumActive(keya));
-        assertEquals(0,_pool.getNumIdle(keya));
-        assertEquals(2,_pool.getNumActive(keyb));
-        assertEquals(0,_pool.getNumIdle(keyb));
-
-        _pool.returnObject(keya,objA0);
-        _pool.returnObject(keyb,objB0);
-
-        assertEquals(2,_pool.getNumActive());
-        assertEquals(2,_pool.getNumIdle());
-        assertEquals(1,_pool.getNumActive(keya));
-        assertEquals(1,_pool.getNumIdle(keya));
-        assertEquals(1,_pool.getNumActive(keyb));
-        assertEquals(1,_pool.getNumIdle(keyb));
-
-        _pool.returnObject(keya,objA1);
-        _pool.returnObject(keyb,objB1);
-
-        assertEquals(0,_pool.getNumActive());
-        assertEquals(4,_pool.getNumIdle());
-        assertEquals(0,_pool.getNumActive(keya));
-        assertEquals(2,_pool.getNumIdle(keya));
-        assertEquals(0,_pool.getNumActive(keyb));
-        assertEquals(2,_pool.getNumIdle(keyb));
-    }
-
-    public void testBaseClear() throws Exception {
-        try {
-            _pool = makeEmptyPool(3);
-        } catch(IllegalArgumentException e) {
-            return; // skip this test if unsupported
-        }
-        Object keya = makeKey(0);
-        assertEquals(0,_pool.getNumActive(keya));
-        assertEquals(0,_pool.getNumIdle(keya));
-        Object obj0 = _pool.borrowObject(keya);
-        Object obj1 = _pool.borrowObject(keya);
-        assertEquals(2,_pool.getNumActive(keya));
-        assertEquals(0,_pool.getNumIdle(keya));
-        _pool.returnObject(keya,obj1);
-        _pool.returnObject(keya,obj0);
-        assertEquals(0,_pool.getNumActive(keya));
-        assertEquals(2,_pool.getNumIdle(keya));
-        _pool.clear(keya);
-        assertEquals(0,_pool.getNumActive(keya));
-        assertEquals(0,_pool.getNumIdle(keya));
-        Object obj2 = _pool.borrowObject(keya);
-        assertEquals(getNthObject(keya,2),obj2);
-    }
-
-    public void testBaseInvalidateObject() throws Exception {
-        try {
-            _pool = makeEmptyPool(3);
-        } catch(IllegalArgumentException e) {
-            return; // skip this test if unsupported
-        }
-        Object keya = makeKey(0);
-        assertEquals(0,_pool.getNumActive(keya));
-        assertEquals(0,_pool.getNumIdle(keya));
-        Object obj0 = _pool.borrowObject(keya);
-        Object obj1 = _pool.borrowObject(keya);
-        assertEquals(2,_pool.getNumActive(keya));
-        assertEquals(0,_pool.getNumIdle(keya));
-        _pool.invalidateObject(keya,obj0);
-        assertEquals(1,_pool.getNumActive(keya));
-        assertEquals(0,_pool.getNumIdle(keya));
-        _pool.invalidateObject(keya,obj1);
-        assertEquals(0,_pool.getNumActive(keya));
-        assertEquals(0,_pool.getNumIdle(keya));
-    }
-
-    public void testBaseAddObject() throws Exception {
+    public void testClosedPoolBehavior() throws Exception {
+        final KeyedObjectPool pool;
         try {
-            _pool = makeEmptyPool(3);
-        } catch(IllegalArgumentException e) {
-            return; // skip this test if unsupported
-        }
-        Object key = makeKey(0);
-        try {
-            assertEquals(0,_pool.getNumIdle());
-            assertEquals(0,_pool.getNumActive());
-            assertEquals(0,_pool.getNumIdle(key));
-            assertEquals(0,_pool.getNumActive(key));
-            _pool.addObject(key);
-            assertEquals(1,_pool.getNumIdle());
-            assertEquals(0,_pool.getNumActive());
-            assertEquals(1,_pool.getNumIdle(key));
-            assertEquals(0,_pool.getNumActive(key));
-            Object obj = _pool.borrowObject(key);
-            assertEquals(getNthObject(key,0),obj);
-            assertEquals(0,_pool.getNumIdle());
-            assertEquals(1,_pool.getNumActive());
-            assertEquals(0,_pool.getNumIdle(key));
-            assertEquals(1,_pool.getNumActive(key));
-            _pool.returnObject(key,obj);
-            assertEquals(1,_pool.getNumIdle());
-            assertEquals(0,_pool.getNumActive());
-            assertEquals(1,_pool.getNumIdle(key));
-            assertEquals(0,_pool.getNumActive(key));
-        } catch(UnsupportedOperationException e) {
-            return; // skip this test if one of those calls is unsupported
+            pool = makeEmptyPool(new BaseKeyedPoolableObjectFactory() {
+                public Object makeObject(final Object key) throws Exception {
+                    return new Object();
+                }
+            });
+        } catch(UnsupportedOperationException uoe) {
+            return; // test not supported
         }
-    }
-
-    private final String KEY = "key";
 
-    public void testClosedPoolBehavior() throws Exception {
-        final KeyedObjectPool pool = makeEmptyPool(new BaseKeyedPoolableObjectFactory() {
-            public Object makeObject(final Object key) throws Exception {
-                return new Object();
-            }
-        });
         Object o1 = pool.borrowObject(KEY);
         Object o2 = pool.borrowObject(KEY);
 
@@ -333,7 +91,12 @@
 
     public void testKPOFAddObjectUsage() throws Exception {
         final FailingKeyedPoolableObjectFactory factory = new FailingKeyedPoolableObjectFactory();
-        final KeyedObjectPool pool = makeEmptyPool(factory);
+        final KeyedObjectPool pool;
+        try {
+            pool = makeEmptyPool(factory);
+        } catch(UnsupportedOperationException uoe) {
+            return; // test not supported
+        }
         final List expectedMethods = new ArrayList();
 
         // addObject should make a new object, pasivate it and put it in the pool
@@ -374,7 +137,12 @@
 
     public void testKPOFBorrowObjectUsages() throws Exception {
         final FailingKeyedPoolableObjectFactory factory = new FailingKeyedPoolableObjectFactory();
-        final KeyedObjectPool pool = makeEmptyPool(factory);
+        final KeyedObjectPool pool;
+        try {
+            pool = makeEmptyPool(factory);
+        } catch(UnsupportedOperationException uoe) {
+            return; // test not supported
+        }
         final List expectedMethods = new ArrayList();
         Object obj;
 
@@ -434,7 +202,12 @@
 
     public void testKPOFReturnObjectUsages() throws Exception {
         final FailingKeyedPoolableObjectFactory factory = new FailingKeyedPoolableObjectFactory();
-        final KeyedObjectPool pool = makeEmptyPool(factory);
+        final KeyedObjectPool pool;
+        try {
+            pool = makeEmptyPool(factory);
+        } catch(UnsupportedOperationException uoe) {
+            return; // test not supported
+        }
         final List expectedMethods = new ArrayList();
         Object obj;
         int idleCount;
@@ -473,7 +246,12 @@
 
     public void testKPOFInvalidateObjectUsages() throws Exception {
         final FailingKeyedPoolableObjectFactory factory = new FailingKeyedPoolableObjectFactory();
-        final KeyedObjectPool pool = makeEmptyPool(factory);
+        final KeyedObjectPool pool;
+        try {
+            pool = makeEmptyPool(factory);
+        } catch(UnsupportedOperationException uoe) {
+            return; // test not supported
+        }
         final List expectedMethods = new ArrayList();
         Object obj;
 
@@ -500,7 +278,12 @@
 
     public void testKPOFClearUsages() throws Exception {
         final FailingKeyedPoolableObjectFactory factory = new FailingKeyedPoolableObjectFactory();
-        final KeyedObjectPool pool = makeEmptyPool(factory);
+        final KeyedObjectPool pool;
+        try {
+            pool = makeEmptyPool(factory);
+        } catch(UnsupportedOperationException uoe) {
+            return; // test not supported
+        }
         final List expectedMethods = new ArrayList();
 
         /// Test correct behavior code paths
@@ -516,7 +299,12 @@
 
     public void testKPOFCloseUsages() throws Exception {
         final FailingKeyedPoolableObjectFactory factory = new FailingKeyedPoolableObjectFactory();
-        KeyedObjectPool pool = makeEmptyPool(factory);
+        KeyedObjectPool pool;
+        try {
+            pool = makeEmptyPool(factory);
+        } catch(UnsupportedOperationException uoe) {
+            return; // test not supported
+        }
         final List expectedMethods = new ArrayList();
 
         /// Test correct behavior code paths
@@ -532,6 +320,15 @@
         pool.close();
     }
 
+    public void testToString() throws Exception {
+        final FailingKeyedPoolableObjectFactory factory = new FailingKeyedPoolableObjectFactory();
+        try {
+            makeEmptyPool(factory).toString();
+        } catch(UnsupportedOperationException uoe) {
+            return; // test not supported
+        }
+    }
+
     private void reset(final KeyedObjectPool pool, final FailingKeyedPoolableObjectFactory
factory, final List expectedMethods) throws Exception {
         pool.clear();
         clear(factory, expectedMethods);
@@ -543,9 +340,7 @@
         expectedMethods.clear();
     }
 
-    private KeyedObjectPool _pool = null;
-
-    private static class FailingKeyedPoolableObjectFactory implements KeyedPoolableObjectFactory
{
+    protected static class FailingKeyedPoolableObjectFactory implements KeyedPoolableObjectFactory
{
         private final List methodCalls = new ArrayList();
         private int count = 0;
         private boolean makeObjectFail;
@@ -553,6 +348,9 @@
         private boolean validateObjectFail;
         private boolean passivateObjectFail;
         private boolean destroyObjectFail;
+
+        public FailingKeyedPoolableObjectFactory() {
+        }
 
         public void reset() {
             count = 0;

Modified: jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestAll.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestAll.java?rev=389997&r1=389996&r2=389997&view=diff
==============================================================================
--- jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestAll.java
(original)
+++ jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestAll.java
Wed Mar 29 21:44:13 2006
@@ -62,7 +62,8 @@
 
         // Remaining unit tests
         suite.addTest(TestCompositeObjectPool.suite());
-        //suite.addTest(TestCompositeKeyedObjectPool.suite());
+        suite.addTest(TestCompositeKeyedObjectPool.suite());
+        suite.addTest(TestCompositeKeyedObjectPool2.suite());
         //suite.addTest(TestCompositeObjectPoolFactory.suite());
         //suite.addTest(TestCompositeKeyedObjectPoolFactory.suite());
         return suite;

Added: jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPool.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPool.java?rev=389997&view=auto
==============================================================================
--- jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPool.java
(added)
+++ jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPool.java
Wed Mar 29 21:44:13 2006
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.pool.composite;
+
+import junit.framework.TestCase;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.commons.pool.TestKeyedObjectPool;
+import org.apache.commons.pool.KeyedObjectPool;
+import org.apache.commons.pool.KeyedPoolableObjectFactory;
+import org.apache.commons.pool.MethodCallPoolableObjectFactory;
+import org.apache.commons.pool.impl.GenericObjectPoolFactory;
+
+/**
+ * Tests for {@link CompositeKeyedObjectPool}
+ * when backed by a {@link CompositeObjectPool}.
+ *
+ * @author Sandy McArthur
+ * @version $Revision$ $Date$
+ */
+public class TestCompositeKeyedObjectPool extends TestKeyedObjectPool {
+    public TestCompositeKeyedObjectPool(final String name) {
+        super(name);
+    }
+
+    public static Test suite() {
+        return new TestSuite(TestCompositeKeyedObjectPool.class);
+    }
+
+    protected KeyedObjectPool makeEmptyPool(final KeyedPoolableObjectFactory factory) {
+        final CompositeKeyedObjectPoolFactory ckopf = new CompositeKeyedObjectPoolFactory(factory);
+        return ckopf.createPool();
+    }
+
+    public void testConstructors() {
+        try {
+            new CompositeKeyedObjectPool(null);
+        } catch (IllegalArgumentException iae) {
+            // expected
+        }
+    }
+
+    public void testSetFactory() {
+        final KeyedObjectPool pool;
+        try {
+            pool = makeEmptyPool(new FailingKeyedPoolableObjectFactory());
+        } catch (UnsupportedOperationException uoe) {
+            return;
+        }
+        try {
+            pool.setFactory(new FailingKeyedPoolableObjectFactory());
+            fail("Expected setFactory to throw an UnsupportedOperationException.");
+        } catch (UnsupportedOperationException uoe) {
+            // expected
+        }
+    }
+}

Propchange: jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPool.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPool.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPool2.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPool2.java?rev=389997&view=auto
==============================================================================
--- jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPool2.java
(added)
+++ jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPool2.java
Wed Mar 29 21:44:13 2006
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.pool.composite;
+
+import org.apache.commons.pool.TestKeyedObjectPool;
+import org.apache.commons.pool.KeyedObjectPool;
+import org.apache.commons.pool.KeyedPoolableObjectFactory;
+import org.apache.commons.pool.MethodCallPoolableObjectFactory;
+import org.apache.commons.pool.ObjectPool;
+import org.apache.commons.pool.PoolUtils;
+import org.apache.commons.pool.impl.GenericObjectPoolFactory;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Tests for {@link CompositeKeyedObjectPool}
+ * when backed by a generic {@link ObjectPool} implementation.
+ *
+ * @author Sandy McArthur
+ * @version $Revision$ $Date$
+ */
+public class TestCompositeKeyedObjectPool2 extends TestCompositeKeyedObjectPool {
+    public TestCompositeKeyedObjectPool2(final String name) {
+        super(name);
+    }
+
+    public static Test suite() {
+        return new TestSuite(TestCompositeKeyedObjectPool2.class);
+    }
+
+    protected KeyedObjectPool makeEmptyPool(final KeyedPoolableObjectFactory factory) {
+        return CompositeKeyedObjectPoolFactory.createPool(new GenericObjectPoolFactory(PoolUtils.adapt(factory,
KEY)));
+    }
+
+    public void testConstructors() {
+        new CompositeKeyedObjectPool(new GenericObjectPoolFactory(new MethodCallPoolableObjectFactory()));
+    }
+}

Propchange: jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPool2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeKeyedObjectPool2.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeObjectPool.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeObjectPool.java?rev=389997&r1=389996&r2=389997&view=diff
==============================================================================
--- jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeObjectPool.java
(original)
+++ jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestCompositeObjectPool.java
Wed Mar 29 21:44:13 2006
@@ -52,9 +52,11 @@
     }
 
     public void setUp() throws Exception {
+        super.setUp();
     }
 
     public void tearDown() throws Exception {
+        super.tearDown();
         if (pool != null) {
             pool.close();
             pool = null;

Modified: jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestWaitLimitManager.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestWaitLimitManager.java?rev=389997&r1=389996&r2=389997&view=diff
==============================================================================
--- jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestWaitLimitManager.java
(original)
+++ jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/composite/TestWaitLimitManager.java
Wed Mar 29 21:44:13 2006
@@ -34,7 +34,7 @@
      * Because {@link System#currentTimeMillis()} or {@link Object#wait} aren't perfectly
granular,
      * allow a little leeway.
      */
-    private static long FUZZ = 5L;
+    private static long FUZZ = 10L;
 
     /**
      * Constructs a test case with the given name.

Modified: jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java?rev=389997&r1=389996&r2=389997&view=diff
==============================================================================
--- jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
(original)
+++ jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
Wed Mar 29 21:44:13 2006
@@ -25,12 +25,13 @@
 import org.apache.commons.pool.KeyedObjectPool;
 import org.apache.commons.pool.KeyedPoolableObjectFactory;
 import org.apache.commons.pool.TestKeyedObjectPool;
+import org.apache.commons.pool.TestBaseKeyedObjectPool;
 
 /**
  * @author Rodney Waldhoff
  * @version $Revision$ $Date$
  */
-public class TestGenericKeyedObjectPool extends TestKeyedObjectPool {
+public class TestGenericKeyedObjectPool extends TestBaseKeyedObjectPool {
     public TestGenericKeyedObjectPool(String testName) {
         super(testName);
     }
@@ -539,7 +540,7 @@
         try { Thread.sleep(150L); } catch(Exception e) { }
         assertTrue("Should be 10 idle, found " + pool.getNumIdle(),pool.getNumIdle() == 10);
     }
-    
+
     public void testMinIdleNoPopulateImmediately() throws Exception {
         pool.setMaxIdle(500);
         pool.setMinIdle(5);
@@ -552,15 +553,15 @@
 
         //Generate a random key
         String key = "A";
-        
+
         pool.preparePool(key, false);
-        
+
         assertTrue("Should be 0 idle, found " + pool.getNumIdle(),pool.getNumIdle() == 0);
-        
+
         try { Thread.sleep(1500L); } catch(Exception e) { }
         assertTrue("Should be 5 idle, found " + pool.getNumIdle(),pool.getNumIdle() == 5);
     }
-    
+
     public void testMinIdleNoPreparePool() throws Exception {
         pool.setMaxIdle(500);
         pool.setMinIdle(5);
@@ -583,7 +584,7 @@
         try { Thread.sleep(150L); } catch(Exception e) { }
         assertTrue("Should be 5 idle, found " + pool.getNumIdle(),pool.getNumIdle() == 5);
     }
-    
+
     public void testFIFO() throws Exception {
         final Object key = "key";
         pool.addObject(key); // "key0"

Modified: jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java?rev=389997&r1=389996&r2=389997&view=diff
==============================================================================
--- jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java
(original)
+++ jakarta/commons/proper/pool/trunk/src/test/org/apache/commons/pool/impl/TestStackKeyedObjectPool.java
Wed Mar 29 21:44:13 2006
@@ -26,12 +26,13 @@
 import org.apache.commons.pool.KeyedObjectPool;
 import org.apache.commons.pool.KeyedPoolableObjectFactory;
 import org.apache.commons.pool.TestKeyedObjectPool;
+import org.apache.commons.pool.TestBaseKeyedObjectPool;
 
 /**
  * @author Rodney Waldhoff
  * @version $Revision$ $Date$
  */
-public class TestStackKeyedObjectPool extends TestKeyedObjectPool {
+public class TestStackKeyedObjectPool extends TestBaseKeyedObjectPool {
     public TestStackKeyedObjectPool(String testName) {
         super(testName);
     }
@@ -52,7 +53,7 @@
     protected Object getNthObject(Object key, int n) {
         return String.valueOf(key) + String.valueOf(n);
     }
-    
+
     protected Object makeKey(int n) {
         return String.valueOf(n);
     }
@@ -73,7 +74,7 @@
             );
     }
 
-    
+
     public void tearDown() throws Exception {
         super.tearDown();
         pool = null;
@@ -116,7 +117,7 @@
             assertEquals((i < 8 ? i+1 : 8),pool.getNumIdle(""));
         }
     }
-    
+
     public void testPoolWithNullFactory() throws Exception {
         KeyedObjectPool pool = new StackKeyedObjectPool(10);
         for(int i=0;i<10;i++) {
@@ -137,10 +138,10 @@
         }
         pool.invalidateObject("X",pool.borrowObject("X"));
         pool.invalidateObject("X",pool.borrowObject("X"));
-        pool.clear("X");        
-        pool.clear();        
+        pool.clear("X");
+        pool.clear();
     }
-    
+
     public void testVariousConstructors() throws Exception {
         {
             StackKeyedObjectPool pool = new StackKeyedObjectPool();
@@ -167,7 +168,7 @@
             assertNotNull(pool);
         }
     }
-    
+
     public void testToString() throws Exception {
         StackKeyedObjectPool pool = new StackKeyedObjectPool(new SimpleFactory());
         assertNotNull(pool.toString());
@@ -176,7 +177,7 @@
         pool.returnObject("key",obj);
         assertNotNull(pool.toString());
     }
-        
+
     public void testBorrowFromEmptyPoolWithNullFactory() throws Exception {
         KeyedObjectPool pool = new StackKeyedObjectPool();
         try {
@@ -186,7 +187,7 @@
             // expected
         }
     }
-    
+
     public void testSetFactory() throws Exception {
         KeyedObjectPool pool = new StackKeyedObjectPool();
         try {
@@ -212,20 +213,20 @@
             fail("Expected IllegalStateException");
         } catch(IllegalStateException e) {
             // expected
-        }        
+        }
     }
-    
+
     public void testCanResetFactoryWithoutActiveObjects() throws Exception {
         KeyedObjectPool pool = new StackKeyedObjectPool();
         {
             pool.setFactory(new SimpleFactory());
-            Object obj = pool.borrowObject("x");        
+            Object obj = pool.borrowObject("x");
             assertNotNull(obj);
             pool.returnObject("x",obj);
         }
         {
             pool.setFactory(new SimpleFactory());
-            Object obj = pool.borrowObject("x");        
+            Object obj = pool.borrowObject("x");
             assertNotNull(obj);
             pool.returnObject("x",obj);
         }
@@ -245,7 +246,7 @@
                     }
                 }
                 public void activateObject(Object key, Object obj) { }
-                public void passivateObject(Object key, Object obj) { 
+                public void passivateObject(Object key, Object obj) {
                     if(obj instanceof Integer) {
                         if((((Integer)obj).intValue() % 3) == 0) {
                             throw new RuntimeException("Couldn't passivate");
@@ -266,17 +267,17 @@
         }
         assertEquals(6,pool.getNumIdle("key"));
     }
- 
+
     class SimpleFactory implements KeyedPoolableObjectFactory {
         HashMap map = new HashMap();
-        public Object makeObject(Object key) { 
+        public Object makeObject(Object key) {
             int counter = 0;
             Integer Counter = (Integer)(map.get(key));
             if(null != Counter) {
                 counter = Counter.intValue();
             }
-            map.put(key,new Integer(counter + 1));                       
-            return String.valueOf(key) + String.valueOf(counter); 
+            map.put(key,new Integer(counter + 1));
+            return String.valueOf(key) + String.valueOf(counter);
         }
         public void destroyObject(Object key, Object obj) { }
         public boolean validateObject(Object key, Object obj) { return true; }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message