You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sa...@apache.org on 2006/03/20 02:48:51 UTC

svn commit: r387103 - /jakarta/commons/proper/pool/branches/1_3_RELEASE_BRANCH/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java

Author: sandymac
Date: Sun Mar 19 17:48:49 2006
New Revision: 387103

URL: http://svn.apache.org/viewcvs?rev=387103&view=rev
Log:
Make testEvictionSoftMinIdle unit test reliable.

Modified:
    jakarta/commons/proper/pool/branches/1_3_RELEASE_BRANCH/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java

Modified: jakarta/commons/proper/pool/branches/1_3_RELEASE_BRANCH/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/pool/branches/1_3_RELEASE_BRANCH/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java?rev=387103&r1=387102&r2=387103&view=diff
==============================================================================
--- jakarta/commons/proper/pool/branches/1_3_RELEASE_BRANCH/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java (original)
+++ jakarta/commons/proper/pool/branches/1_3_RELEASE_BRANCH/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java Sun Mar 19 17:48:49 2006
@@ -637,11 +637,9 @@
         pool.setMaxActive(5);
         pool.setNumTestsPerEvictionRun(5);
         pool.setMinEvictableIdleTimeMillis(3000L);
-        pool.setTimeBetweenEvictionRunsMillis(250L);
-        pool.setTestWhileIdle(true);
         pool.setSoftMinEvictableIdleTimeMillis(1000L);
         pool.setMinIdle(2);
-        
+
         Object[] active = new Object[5];
         Long[] creationTime = new Long[5] ;
         for(int i=0;i<5;i++) {
@@ -652,16 +650,16 @@
         for(int i=0;i<5;i++) {
             pool.returnObject(active[i]);
         }
-        
-        try { Thread.sleep(1500L); } catch(Exception e) { }
-        assertTrue("Should be 2 OLD idle, found " + pool.getNumIdle(),pool.getNumIdle() == 2 &&
-                ((TimeTest)pool.borrowObject()).getCreateTime() == creationTime[3].longValue() &&
-                ((TimeTest)pool.borrowObject()).getCreateTime() == creationTime[4].longValue());
-        
-        try { Thread.sleep(2000L); } catch(Exception e) { }
-        assertTrue("Should be 2 NEW idle , found " + pool.getNumIdle(),pool.getNumIdle() == 2 &&
-                ((TimeTest)pool.borrowObject()).getCreateTime() != creationTime[0].longValue() &&
-                ((TimeTest)pool.borrowObject()).getCreateTime() != creationTime[1].longValue());
+
+        // Soft evict all but minIdle(2)
+        Thread.sleep(1500L);
+        pool.evict();
+        assertEquals("Idle count different than expected.", 2, pool.getNumIdle());
+
+        // Hard evict the rest.
+        Thread.sleep(2000L);
+        pool.evict();
+        assertEquals("Idle count different than expected.", 0, pool.getNumIdle());
     }
 
     public void testMinIdle() throws Exception {



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