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/dbcp/src/test/org/apache/commons/dbcp/jdbc2pool TestJdbc2PoolDataSource.java
Date Mon, 11 Aug 2003 23:34:52 GMT
dirkv       2003/08/11 16:34:52

  Modified:    dbcp/src/test/org/apache/commons/dbcp/jdbc2pool
                        TestJdbc2PoolDataSource.java
  Log:
  Bugzilla Bug 1892: Per User methods not working in Jdbc2PoolDataSource
  - add junit test to make sure everything is ok
  
  Revision  Changes    Path
  1.9       +54 -4     jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/jdbc2pool/TestJdbc2PoolDataSource.java
  
  Index: TestJdbc2PoolDataSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/jdbc2pool/TestJdbc2PoolDataSource.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TestJdbc2PoolDataSource.java	2 Jun 2003 04:54:12 -0000	1.8
  +++ TestJdbc2PoolDataSource.java	11 Aug 2003 23:34:52 -0000	1.9
  @@ -76,6 +76,7 @@
   
   /**
    * @author John McNally
  + * @author Dirk Verbeeck
    * @version $Revision$ $Date$
    */
   public class TestJdbc2PoolDataSource extends TestConnectionPool {
  @@ -333,6 +334,55 @@
           {
               c[i].close();
           }
  +    }
  +    
  +    public void testPerUserMethods() throws Exception {
  +        Jdbc2PoolDataSource tds = (Jdbc2PoolDataSource) ds;
  +        
  +        // you need to set maxActive otherwise there is no accounting
  +        tds.setPerUserMaxActive("u1", new Integer(5));
  +        tds.setPerUserMaxActive("u2", new Integer(5));
  +        
  +        assertEquals(0, tds.getNumActive());
  +        assertEquals(0, tds.getNumActive("u1", "p1"));
  +        assertEquals(0, tds.getNumActive("u2", "p2"));
  +        assertEquals(0, tds.getNumIdle());
  +        assertEquals(0, tds.getNumIdle("u1", "p1"));
  +        assertEquals(0, tds.getNumIdle("u2", "p2"));
  +        
  +        Connection conn = tds.getConnection();
  +        assertNotNull(conn);
  +        assertEquals(1, tds.getNumActive());
  +        assertEquals(0, tds.getNumActive("u1", "p1"));
  +        assertEquals(0, tds.getNumActive("u2", "p2"));
  +        assertEquals(0, tds.getNumIdle());
  +        assertEquals(0, tds.getNumIdle("u1", "p1"));
  +        assertEquals(0, tds.getNumIdle("u2", "p2"));
  +
  +        conn.close();
  +        assertEquals(0, tds.getNumActive());
  +        assertEquals(0, tds.getNumActive("u1", "p1"));
  +        assertEquals(0, tds.getNumActive("u2", "p2"));
  +        assertEquals(1, tds.getNumIdle());
  +        assertEquals(0, tds.getNumIdle("u1", "p1"));
  +        assertEquals(0, tds.getNumIdle("u2", "p2"));
  +
  +        conn = tds.getConnection("u1", "p1");
  +        assertNotNull(conn);
  +        assertEquals(0, tds.getNumActive());
  +        assertEquals(1, tds.getNumActive("u1", "p1"));
  +        assertEquals(0, tds.getNumActive("u2", "p2"));
  +        assertEquals(1, tds.getNumIdle());
  +        assertEquals(0, tds.getNumIdle("u1", "p1"));
  +        assertEquals(0, tds.getNumIdle("u2", "p2"));
  +
  +        conn.close();
  +        assertEquals(0, tds.getNumActive());
  +        assertEquals(0, tds.getNumActive("u1", "p1"));
  +        assertEquals(0, tds.getNumActive("u2", "p2"));
  +        assertEquals(1, tds.getNumIdle());
  +        assertEquals(1, tds.getNumIdle("u1", "p1"));
  +        assertEquals(0, tds.getNumIdle("u2", "p2"));
       }
       
       public void testMultipleThreads() throws Exception {
  
  
  

Mime
View raw message