commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcna...@apache.org
Subject cvs commit: jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/datasources TestPerUserPoolDataSource.java
Date Sun, 19 Oct 2003 23:39:50 GMT
jmcnally    2003/10/19 16:39:50

  Modified:    dbcp/src/java/org/apache/commons/dbcp/datasources
                        PerUserPoolDataSource.java
               dbcp/src/test/org/apache/commons/dbcp/datasources
                        TestPerUserPoolDataSource.java
  Log:
  Fix bug# 23843 - wrong connection returned for usernames for which
  setPerUserMaxActive is not called.
  
  Revision  Changes    Path
  1.8       +3 -9      jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/datasources/PerUserPoolDataSource.java
  
  Index: PerUserPoolDataSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/datasources/PerUserPoolDataSource.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PerUserPoolDataSource.java	13 Oct 2003 05:06:00 -0000	1.7
  +++ PerUserPoolDataSource.java	19 Oct 2003 23:39:50 -0000	1.8
  @@ -466,12 +466,6 @@
   
       private PoolKey getPoolKey(String username) {
           PoolKey key = null;
  -
  -        if (username != null && (perUserMaxActive == null 
  -                || !perUserMaxActive.containsKey(username))) {
  -            username = null;
  -        }
  -
           String dsName = getDataSourceName();
           Map dsMap = (Map) poolKeys.get(dsName);
           if (dsMap != null) {
  
  
  
  1.8       +14 -14    jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/datasources/TestPerUserPoolDataSource.java
  
  Index: TestPerUserPoolDataSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/datasources/TestPerUserPoolDataSource.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestPerUserPoolDataSource.java	15 Oct 2003 19:55:57 -0000	1.7
  +++ TestPerUserPoolDataSource.java	19 Oct 2003 23:39:50 -0000	1.8
  @@ -550,14 +550,18 @@
           assertEquals(0, tds.getNumActive());
           assertEquals(1, tds.getNumIdle());
   
  -        conn = tds.getConnection("u1", null);
  +        conn = tds.getConnection("u1", "p1");
           assertNotNull(conn);
  -        assertEquals(1, tds.getNumActive());
  -        assertEquals(0, tds.getNumIdle());
  +        assertEquals(0, tds.getNumActive());
  +        assertEquals(1, tds.getNumIdle());
  +        assertEquals(1, tds.getNumActive("u1", "p1"));
  +        assertEquals(0, tds.getNumIdle("u1", "p1"));
   
           conn.close();
           assertEquals(0, tds.getNumActive());
           assertEquals(1, tds.getNumIdle());
  +        assertEquals(0, tds.getNumActive("u1", "p1"));
  +        assertEquals(1, tds.getNumIdle("u1", "p1"));
       }
   
       // see issue http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23843
  @@ -573,12 +577,10 @@
           Connection[] c = new Connection[users.length];
           for (int i = 0; i < users.length; i++) {
               c[i] = puds.getConnection(users[i], password);
  +            assertEquals(users[i], getUsername(c[i]));
           }
  -        System.out.println("testDefaultUser1:");
           for (int i = 0; i < users.length; i++) {
  -            System.out.println(
  -                "   Tried: " + users[i] + 
  -                "   got: " + getUsername(c[i]));
  +            c[i].close();
           }
       }
       
  @@ -595,12 +597,10 @@
           Connection[] c = new Connection[users.length];
           for (int i = 0; i < users.length; i++) {
               c[i] = puds.getConnection(users[i], password);
  +            assertEquals(users[i], getUsername(c[i]));
           }
  -        System.out.println("testDefaultUser2:");
           for (int i = 0; i < users.length; i++) {
  -            System.out.println(
  -                "   Tried: " + users[i] + 
  -                "   got: " + getUsername(c[i]));
  +            c[i].close();
           }
       }
   }
  
  
  

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