commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r1221613 - /commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
Date Wed, 21 Dec 2011 05:11:24 GMT
Author: psteitz
Date: Wed Dec 21 05:11:23 2011
New Revision: 1221613

URL: http://svn.apache.org/viewvc?rev=1221613&view=rev
Log:
Added test for POOL-192.

Modified:
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.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=1221613&r1=1221612&r2=1221613&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
Wed Dec 21 05:11:23 2011
@@ -1338,6 +1338,35 @@ public class TestGenericKeyedObjectPool 
         pool.borrowObject("2");   
     }
     
+    /**
+     * POOL-192
+     * Verify that clear(key) does not leak capacity.
+     */
+    public void testClear() throws Exception {
+        SimpleFactory<String> factory = new SimpleFactory<String>();
+        GenericKeyedObjectPool<String,String> pool =
+            new GenericKeyedObjectPool<String,String>(factory);
+        pool.setMaxTotal(2);
+        pool.setMaxTotalPerKey(2);
+        pool.setBlockWhenExhausted(false);
+        pool.addObject("one");
+        pool.addObject("one");
+        assertEquals(2, pool.getNumIdle());
+        pool.clear("one");
+        assertEquals(0, pool.getNumIdle());
+        assertEquals(0, pool.getNumIdle("one"));
+        String obj1 = pool.borrowObject("one");
+        String obj2 = pool.borrowObject("one");
+        pool.returnObject("one", obj1);
+        pool.returnObject("one", obj2);
+        pool.clear();
+        assertEquals(0, pool.getNumIdle());
+        assertEquals(0, pool.getNumIdle("one"));
+        pool.borrowObject("one");
+        pool.borrowObject("one");
+        pool.close();
+    }
+    
     /*
      * Very simple test thread that just tries to borrow an object from
      * the provided pool with the specified key and returns it



Mime
View raw message