commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r443253 - /jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSource.java
Date Thu, 14 Sep 2006 06:02:31 GMT
Author: psteitz
Date: Wed Sep 13 23:02:30 2006
New Revision: 443253

URL: http://svn.apache.org/viewvc?view=rev&rev=443253
Log:
Added test case demonstrating DBCP-93. Upgrade to pool 1.3 eliminates the bug.

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

Modified: jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSource.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSource.java?view=diff&rev=443253&r1=443252&r2=443253
==============================================================================
--- jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSource.java
(original)
+++ jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSource.java
Wed Sep 13 23:02:30 2006
@@ -300,4 +300,36 @@
             // test OK
         }
     }
+    /**
+     * JIRA DBCP-93: If an SQLException occurs after the GenericObjectPool is
+     * initialized in createDataSource, the evictor task is not cleaned up.
+     */
+    public void testCreateDataSourceCleanupThreads() throws Exception {
+        ds.close();
+        ds = null;
+        ds = new BasicDataSource();
+        ds.setDriverClassName("org.apache.commons.dbcp.TesterDriver");
+        ds.setUrl("jdbc:apache:commons:testdriver");
+        ds.setMaxActive(getMaxActive());
+        ds.setMaxWait(getMaxWait());
+        ds.setDefaultAutoCommit(true);
+        ds.setDefaultReadOnly(false);
+        ds.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
+        ds.setDefaultCatalog(CATALOG);
+        ds.setUsername("username");
+        // Set timeBetweenEvictionRuns > 0, so evictor is created
+        ds.setTimeBetweenEvictionRunsMillis(100);
+        // Make password incorrect, so createDataSource will throw
+        ds.setPassword("wrong");
+        ds.setValidationQuery("SELECT DUMMY FROM DUAL");
+        int threadCount = Thread.activeCount();
+        for (int i = 0; i < 10; i++) {
+            try {
+                Connection con = ds.getConnection();
+            } catch (SQLException ex) {
+                // ignore
+            }
+        }
+        assertEquals(threadCount, Thread.activeCount());
+    }
 }



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