commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwaldh...@apache.org
Subject cvs commit: jakarta-commons/pool/src/test/org/apache/commons/pool/impl TestGenericObjectPool.java
Date Fri, 14 Mar 2003 00:56:58 GMT
rwaldhoff    2003/03/13 16:56:58

  Modified:    pool/src/java/org/apache/commons/pool/impl
                        GenericObjectPool.java
               pool/src/test/org/apache/commons/pool/impl
                        TestGenericObjectPool.java
  Log:
  apply Lee Breisacher's patch adding an addObject method and test
  see <http://issues.apache.org/bugzilla/show_bug.cgi?id=14983>
  
  Revision  Changes    Path
  1.17      +14 -4     jakarta-commons/pool/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
  
  Index: GenericObjectPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/pool/src/java/org/apache/commons/pool/impl/GenericObjectPool.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- GenericObjectPool.java	13 Mar 2003 18:52:44 -0000	1.16
  +++ GenericObjectPool.java	14 Mar 2003 00:56:57 -0000	1.17
  @@ -901,6 +901,16 @@
           }
       }
   
  +    /**
  +     * Create an object, and place it into the pool.
  +     * addObject() is useful for "pre-loading" a pool with idle objects.
  +     */
  +    public synchronized void addObject() throws Exception {
  +        Object obj = _factory.makeObject();
  +        _numActive++;   // A little slimy - must do this because returnObject decrements
it.
  +        this.returnObject(obj);
  +    }
  +    
       //--- non-public methods ----------------------------------------
   
       /**
  
  
  
  1.11      +16 -4     jakarta-commons/pool/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java
  
  Index: TestGenericObjectPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/pool/src/test/org/apache/commons/pool/impl/TestGenericObjectPool.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TestGenericObjectPool.java	7 Mar 2003 20:28:36 -0000	1.10
  +++ TestGenericObjectPool.java	14 Mar 2003 00:56:58 -0000	1.11
  @@ -373,6 +373,18 @@
           }
       }
       
  +    public void testAddObject() throws Exception {
  +    	pool.addObject();
  +		assertEquals("should be one idle", 1, pool.getNumIdle());
  +		assertEquals("should be zero active", 0, pool.getNumActive());
  +		Object obj = pool.borrowObject();
  +		assertEquals("should be zero idle", 0, pool.getNumIdle());
  +		assertEquals("should be one active", 1, pool.getNumActive());
  +		pool.returnObject(obj);
  +		assertEquals("should be one idle", 1, pool.getNumIdle());
  +		assertEquals("should be zero active", 0, pool.getNumActive());
  +    }
  +    
       private GenericObjectPool pool = null;
   
       static class SimpleFactory implements PoolableObjectFactory {
  
  
  

---------------------------------------------------------------------
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