commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r757135 - /commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestAbandonedBasicDataSource.java
Date Sun, 22 Mar 2009 06:43:29 GMT
Author: psteitz
Date: Sun Mar 22 06:43:28 2009
New Revision: 757135

URL: http://svn.apache.org/viewvc?rev=757135&view=rev
Log:
Added test case confirming that DelegatingStatement updates its lastUsed property when it
creates or prepares a statement. JIRA: DBCP-199

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=757135&r1=757134&r2=757135&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
Sun Mar 22 06:43:28 2009
@@ -135,4 +135,25 @@
         try { conn1.close(); } catch (SQLException ex) { }
         assertEquals(0, ds.getNumActive());
     }
+    
+    /**
+     * Verify that lastUsed property is updated when a connection
+     * creates or prepares a statement
+     */
+    public void testlastUsed() throws Exception {
+        ds.setRemoveAbandonedTimeout(1);
+        ds.setMaxActive(2);
+        Connection conn1 = ds.getConnection();
+        Thread.sleep(500);
+        conn1.createStatement(); // Should reset lastUsed
+        Thread.sleep(800);
+        Connection conn2 = ds.getConnection(); // triggers abandoned cleanup
+        conn1.createStatement(); // Should still be OK
+        conn2.close();
+        Thread.sleep(500);
+        conn1.prepareStatement("SELECT 1 FROM DUAL"); // reset
+        Thread.sleep(800);
+        conn2 = ds.getConnection(); // trigger abandoned cleanup again
+        conn1.createStatement();         
+    }
 }



Mime
View raw message