commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r606718 - /commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
Date Mon, 24 Dec 2007 17:55:14 GMT
Author: psteitz
Date: Mon Dec 24 09:55:10 2007
New Revision: 606718

URL: http://svn.apache.org/viewvc?rev=606718&view=rev
Log:
Added more tests for maxActive, maxTotal, preparePool.

Modified:
    commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java

Modified: commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java?rev=606718&r1=606717&r2=606718&view=diff
==============================================================================
--- commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
(original)
+++ commons/proper/pool/branches/1_4_RELEASE_BRANCH/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
Mon Dec 24 09:55:10 2007
@@ -165,6 +165,24 @@
             assertEquals(99 - i,pool.getNumActive(""));
             assertEquals((i < 8 ? i+1 : 8),pool.getNumIdle(""));
         }
+        
+        for(int i=0;i<100;i++) {
+            active[i] = pool.borrowObject("a");
+        }
+        assertEquals(100,pool.getNumActive("a"));
+        assertEquals(0,pool.getNumIdle("a"));
+        for(int i=0;i<100;i++) {
+            pool.returnObject("a",active[i]);
+            assertEquals(99 - i,pool.getNumActive("a"));
+            assertEquals((i < 8 ? i+1 : 8),pool.getNumIdle("a"));
+        }
+        
+        // total number of idle instances is twice maxIdle
+        assertEquals(16, pool.getNumIdle());
+        // Each pool is at the sup
+        assertEquals(8, pool.getNumIdle(""));
+        assertEquals(8, pool.getNumIdle("a"));
+             
     }
 
     public void testMaxActive() throws Exception {
@@ -222,6 +240,17 @@
         assertNotNull(o4);
         assertEquals(0, pool.getNumIdle());
         assertEquals(0, pool.getNumIdle("b"));
+        
+        pool.setMaxTotal(4);
+        Object o5 = pool.borrowObject("b");
+        assertNotNull(o5);
+        
+        assertEquals(2, pool.getNumActive("a"));
+        assertEquals(2, pool.getNumActive("b"));
+        assertEquals(pool.getMaxTotal(),
+                pool.getNumActive("b") + pool.getNumActive("b"));
+        assertEquals(pool.getNumActive(),
+                pool.getMaxTotal());
     }
 
     public void testMaxTotalZero() throws Exception {
@@ -537,6 +566,8 @@
         String key = "A";
 
         pool.preparePool(key, true);
+        assertTrue("Should be 5 idle, found " + 
+                pool.getNumIdle(),pool.getNumIdle() == 5);
 
         try { Thread.sleep(150L); } catch(Exception e) { }
         assertTrue("Should be 5 idle, found " + pool.getNumIdle(),pool.getNumIdle() == 5);



Mime
View raw message