commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From di...@apache.org
Subject cvs commit: jakarta-commons/pool/src/test/org/apache/commons/pool/impl TestGenericKeyedObjectPool.java
Date Tue, 26 Aug 2003 14:15:02 GMT
dirkv       2003/08/26 07:15:02

  Modified:    pool/src/test/org/apache/commons/pool/impl
                        TestGenericKeyedObjectPool.java
  Log:
  test for the new maxTotal feature
  
  Revision  Changes    Path
  1.16      +35 -4     jakarta-commons/pool/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java
  
  Index: TestGenericKeyedObjectPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/pool/src/test/org/apache/commons/pool/impl/TestGenericKeyedObjectPool.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- TestGenericKeyedObjectPool.java	22 Aug 2003 14:33:30 -0000	1.15
  +++ TestGenericKeyedObjectPool.java	26 Aug 2003 14:15:02 -0000	1.16
  @@ -236,6 +236,37 @@
           }
       }
   
  +    public void testMaxTotal() throws Exception {
  +        pool.setMaxActive(2);
  +        pool.setMaxTotal(3);
  +        pool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_FAIL);
  +
  +        Object o1 = pool.borrowObject("a");
  +        assertNotNull(o1);
  +        Object o2 = pool.borrowObject("a");
  +        assertNotNull(o2);
  +        Object o3 = pool.borrowObject("b");
  +        assertNotNull(o3);
  +        try {
  +            pool.borrowObject("c");
  +            fail("Expected NoSuchElementException");
  +        } catch(NoSuchElementException e) {
  +            // expected
  +        }
  +        
  +        assertEquals(0, pool.getNumIdle());
  +
  +        pool.returnObject("b", o3);
  +        assertEquals(1, pool.getNumIdle());
  +        assertEquals(1, pool.getNumIdle("b"));
  +
  +        Object o4 = pool.borrowObject("b");
  +        assertNotNull(o4);
  +        assertEquals(0, pool.getNumIdle());
  +        assertEquals(0, pool.getNumIdle("b"));
  +    }
  +
  +
       public void testSettersAndGetters() throws Exception {
           GenericKeyedObjectPool pool = new GenericKeyedObjectPool();
           {
  
  
  

Mime
View raw message