commons-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=884192&view=rev
Log:
Added test case to ensure prepareCall resets connection last used property.

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=884192&r1=884191&r2=884192&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 16:49:02 2009
@@ -133,4 +133,25 @@
         ds.getConnection(); // trigger abandoned cleanup again
         conn1.createStatement();         
     }
+    
+    /**
+     * Verify that lastUsed property is updated when a connection
+     * prepares a callable statement.
+     */
+    public void testlastUsedPrepareCall() throws Exception {
+        ds.setRemoveAbandonedTimeout(1);
+        ds.setMaxActive(2);
+        Connection conn1 = ds.getConnection();
+        Thread.sleep(500);
+        conn1.prepareCall("{call home}"); // Should reset lastUsed
+        Thread.sleep(800);
+        Connection conn2 = ds.getConnection(); // triggers abandoned cleanup
+        conn1.prepareCall("{call home}"); // Should still be OK
+        conn2.close();
+        Thread.sleep(500);
+        conn1.prepareCall("{call home}"); // reset
+        Thread.sleep(800);
+        ds.getConnection(); // trigger abandoned cleanup again
+        conn1.createStatement();         
+    }
 }



Mime
View raw message