commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r884205 - /commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestAbandonedBasicDataSource.java
Date Wed, 25 Nov 2009 17:25:49 GMT
Author: psteitz
Date: Wed Nov 25 17:25:48 2009
New Revision: 884205

URL: http://svn.apache.org/viewvc?rev=884205&view=rev
Log:
Added check to make sure abaondoned connection cleanup closes physical connections.

Modified:
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestAbandonedBasicDataSource.java

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestAbandonedBasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestAbandonedBasicDataSource.java?rev=884205&r1=884204&r2=884205&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestAbandonedBasicDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestAbandonedBasicDataSource.java
Wed Nov 25 17:25:48 2009
@@ -70,19 +70,25 @@
         // force abandoned
         ds.setRemoveAbandonedTimeout(0);
         ds.setMaxActive(1);
+        ds.setAccessToUnderlyingConnectionAllowed(true);
 
         Connection conn1 = getConnection();
         assertNotNull(conn1);
         assertEquals(1, ds.getNumActive());
         
-        Connection conn2 = getConnection();        
+        Connection conn2 = getConnection();
+        // Attempt to borrow object triggers abandoned cleanup
+        // conn1 should be closed by the pool to make room
         assertNotNull(conn2);
         assertEquals(1, ds.getNumActive());
+        // Verify that conn1 is closed
+        assertTrue(((DelegatingConnection) conn1).getInnermostDelegate().isClosed());
         
-        try { conn2.close(); } catch (SQLException ex) { }
+        conn2.close();
         assertEquals(0, ds.getNumActive());
         
-        try { conn1.close(); } catch (SQLException ex) { }
+        // Second close on conn1 is OK as of dbcp 1.3
+        conn1.close();
         assertEquals(0, ds.getNumActive());
     }
 



Mime
View raw message