commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r828639 - in /commons/proper/dbcp/trunk/src: java/org/apache/commons/dbcp/BasicDataSourceFactory.java test/org/apache/commons/dbcp/TestBasicDataSourceFactory.java
Date Thu, 22 Oct 2009 10:27:43 GMT
Author: psteitz
Date: Thu Oct 22 10:27:43 2009
New Revision: 828639

URL: http://svn.apache.org/viewvc?rev=828639&view=rev
Log:
Added validationQueryTimeout to properties set by BasicDataSourceFactory (should have been
included in r756628).  Thanks to Roshan Gunasekara. JIRA: DBCP-226.

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

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSourceFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSourceFactory.java?rev=828639&r1=828638&r2=828639&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSourceFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSourceFactory.java
Thu Oct 22 10:27:43 2009
@@ -65,6 +65,7 @@
     private final static String PROP_URL = "url";
     private final static String PROP_USERNAME = "username";
     private final static String PROP_VALIDATIONQUERY = "validationQuery";
+    private final static String PROP_VALIDATIONQUERY_TIMEOUT = "validationQueryTimeout";
     /**
      * The property name for initConnectionSqls.
      * The associated value String must be of the form [query;]*
@@ -100,6 +101,7 @@
         PROP_URL,
         PROP_USERNAME,
         PROP_VALIDATIONQUERY,
+        PROP_VALIDATIONQUERY_TIMEOUT,
         PROP_INITCONNECTIONSQLS,
         PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWED,
         PROP_REMOVEABANDONED,
@@ -291,6 +293,11 @@
             dataSource.setValidationQuery(value);
         }
 
+        value = properties.getProperty(PROP_VALIDATIONQUERY_TIMEOUT);
+        if (value != null) {
+            dataSource.setValidationQueryTimeout(Integer.parseInt(value));
+        }
+        
         value = properties.getProperty(PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWED);
         if (value != null) {
             dataSource.setAccessToUnderlyingConnectionAllowed(Boolean.valueOf(value).booleanValue());

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSourceFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSourceFactory.java?rev=828639&r1=828638&r2=828639&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSourceFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSourceFactory.java
Thu Oct 22 10:27:43 2009
@@ -17,6 +17,7 @@
 
 package org.apache.commons.dbcp;
 
+import java.sql.Connection;
 import java.util.Properties;
 
 import javax.sql.DataSource;
@@ -53,24 +54,64 @@
         properties.setProperty("driverClassName", "org.apache.commons.dbcp.TesterDriver");
         properties.setProperty("url", "jdbc:apache:commons:testdriver");
         properties.setProperty("maxActive", "10");
+        properties.setProperty("maxIdle", "8");
+        properties.setProperty("minIdle", "0");
         properties.setProperty("maxWait", "500");
+        properties.setProperty("initialSize", "5");
         properties.setProperty("defaultAutoCommit", "true");
         properties.setProperty("defaultReadOnly", "false");
         properties.setProperty("defaultTransactionIsolation", "READ_COMMITTED");
         properties.setProperty("defaultCatalog", "test");
+        properties.setProperty("testOnBorrow", "true");
+        properties.setProperty("testOnReturn", "false");
         properties.setProperty("username", "username");
         properties.setProperty("password", "password");
         properties.setProperty("validationQuery", "SELECT DUMMY FROM DUAL");
+        properties.setProperty("validationQueryTimeout", "100");
         properties.setProperty("initConnectionSqls", "SELECT 1;SELECT 2");
+        properties.setProperty("timeBetweenEvictionRunsMillis", "1000");
+        properties.setProperty("minEvictableIdleTimeMillis", "2000");
+        properties.setProperty("numTestsPerEvictionRun", "2");
+        properties.setProperty("testWhileIdle", "true");
+        properties.setProperty("accessToUnderlyingConnectionAllowed", "true");
+        properties.setProperty("removeAbandoned", "true");
+        properties.setProperty("removeAbandonedTimeout", "3000");
+        properties.setProperty("logAbandoned", "true");
+        properties.setProperty("poolPreparedStatements", "true");
+        properties.setProperty("maxOpenPreparedStatements", "10");
 
         BasicDataSource ds = (BasicDataSource) BasicDataSourceFactory.createDataSource(properties);
         
+        assertEquals("org.apache.commons.dbcp.TesterDriver", ds.getDriverClassName());
         assertEquals("jdbc:apache:commons:testdriver", ds.getUrl());
         assertEquals(10, ds.getMaxActive());
+        assertEquals(8, ds.getMaxIdle());
+        assertEquals(0, ds.getMinIdle());
+        assertEquals(500, ds.getMaxWait());
+        assertEquals(5, ds.getInitialSize());
+        assertEquals(5, ds.getNumIdle());
         assertEquals(true, ds.getDefaultAutoCommit());
-
+        assertEquals(false, ds.getDefaultReadOnly());
+        assertEquals(Connection.TRANSACTION_READ_COMMITTED, ds.getDefaultTransactionIsolation());
+        assertEquals("test", ds.getDefaultCatalog());
+        assertEquals(true, ds.getTestOnBorrow());
+        assertEquals(false, ds.getTestOnReturn());
+        assertEquals("username", ds.getUsername());
+        assertEquals("password", ds.getPassword());
+        assertEquals("SELECT DUMMY FROM DUAL", ds.getValidationQuery());
+        assertEquals(100, ds.getValidationQueryTimeout());
         assertEquals(2, ds.connectionInitSqls.size());
         assertEquals("SELECT 1", ds.connectionInitSqls.get(0));
         assertEquals("SELECT 2", ds.connectionInitSqls.get(1));
+        assertEquals(1000, ds.getTimeBetweenEvictionRunsMillis());
+        assertEquals(2000, ds.getMinEvictableIdleTimeMillis());
+        assertEquals(2, ds.getNumTestsPerEvictionRun());
+        assertEquals(true, ds.getTestWhileIdle());
+        assertEquals(true, ds.isAccessToUnderlyingConnectionAllowed());
+        assertEquals(true, ds.getRemoveAbandoned());
+        assertEquals(3000, ds.getRemoveAbandonedTimeout());
+        assertEquals(true, ds.getLogAbandoned());
+        assertEquals(true, ds.isPoolPreparedStatements());
+        assertEquals(10, ds.getMaxOpenPreparedStatements());
     }
 }



Mime
View raw message