From 8baf4cd469dc8650cccaa01b6e10e26bd8a87624 Mon Sep 17 00:00:00 2001 From: fhanik Date: Mon, 29 Jun 2009 14:36:57 +0000 Subject: [PATCH] Make properties configurable and resolve https://issues.apache.org/bugzilla/show_bug.cgi?id=47440 git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@789345 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tomcat/jdbc/test/CheckOutThreadTest.java | 8 -------- .../test/org/apache/tomcat/jdbc/test/DefaultProperties.java | 13 ++++++++----- .../org/apache/tomcat/jdbc/test/TestSlowQueryReport.java | 4 ++-- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java b/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java index 7196df95e..93e7ef1c2 100644 --- a/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java +++ b/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java @@ -202,7 +202,6 @@ public class CheckOutThreadTest extends DefaultTestCase { public void testDBCPThreads10Connections10Validate() throws Exception { init(); this.datasource.getPoolProperties().setMaxActive(10); - this.datasource.getPoolProperties().setValidationQuery("SELECT 1"); this.datasource.getPoolProperties().setTestOnBorrow(true); this.threadcount = 10; this.transferProperties(); @@ -224,7 +223,6 @@ public class CheckOutThreadTest extends DefaultTestCase { public void testPoolThreads10Connections10Validate() throws Exception { init(); this.datasource.getPoolProperties().setMaxActive(10); - this.datasource.getPoolProperties().setValidationQuery("SELECT 1"); this.datasource.getPoolProperties().setTestOnBorrow(true); this.datasource.getPoolProperties().setFairQueue(false); this.threadcount = 10; @@ -247,7 +245,6 @@ public class CheckOutThreadTest extends DefaultTestCase { public void testPoolThreads10Connections10ValidateFair() throws Exception { init(); this.datasource.getPoolProperties().setMaxActive(10); - this.datasource.getPoolProperties().setValidationQuery("SELECT 1"); this.datasource.getPoolProperties().setTestOnBorrow(true); this.datasource.getPoolProperties().setFairQueue(true); this.threadcount = 10; @@ -270,7 +267,6 @@ public class CheckOutThreadTest extends DefaultTestCase { public void testC3P0Threads10Connections10Validate() throws Exception { init(); this.datasource.getPoolProperties().setMaxActive(10); - this.datasource.getPoolProperties().setValidationQuery("SELECT 1"); this.datasource.getPoolProperties().setTestOnBorrow(true); this.threadcount = 10; this.transferPropertiesToC3P0(); @@ -292,7 +288,6 @@ public class CheckOutThreadTest extends DefaultTestCase { public void testDBCPThreads20Connections10Validate() throws Exception { init(); this.datasource.getPoolProperties().setMaxActive(10); - this.datasource.getPoolProperties().setValidationQuery("SELECT 1"); this.datasource.getPoolProperties().setTestOnBorrow(true); this.threadcount = 20; this.transferProperties(); @@ -314,7 +309,6 @@ public class CheckOutThreadTest extends DefaultTestCase { public void testPoolThreads10Connections20Validate() throws Exception { init(); this.datasource.getPoolProperties().setMaxActive(10); - this.datasource.getPoolProperties().setValidationQuery("SELECT 1"); this.datasource.getPoolProperties().setTestOnBorrow(true); this.datasource.getPoolProperties().setFairQueue(false); this.threadcount = 20; @@ -337,7 +331,6 @@ public class CheckOutThreadTest extends DefaultTestCase { public void testPoolThreads10Connections20ValidateFair() throws Exception { init(); this.datasource.getPoolProperties().setMaxActive(10); - this.datasource.getPoolProperties().setValidationQuery("SELECT 1"); this.datasource.getPoolProperties().setTestOnBorrow(true); this.datasource.getPoolProperties().setFairQueue(true); this.threadcount = 20; @@ -360,7 +353,6 @@ public class CheckOutThreadTest extends DefaultTestCase { public void testC3P0Threads10Connections20Validate() throws Exception { init(); this.datasource.getPoolProperties().setMaxActive(10); - this.datasource.getPoolProperties().setValidationQuery("SELECT 1"); this.datasource.getPoolProperties().setTestOnBorrow(true); this.threadcount = 20; this.transferPropertiesToC3P0(); diff --git a/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultProperties.java b/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultProperties.java index 51399a36c..61ba2232e 100644 --- a/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultProperties.java +++ b/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultProperties.java @@ -28,10 +28,13 @@ import org.apache.tomcat.jdbc.pool.PoolProperties; public class DefaultProperties extends PoolProperties { public DefaultProperties() { dbProperties = new Properties(); - url = "jdbc:mysql://localhost:3306/mysql?autoReconnect=true"; - driverClassName = "com.mysql.jdbc.Driver"; - password = "password"; - username = "root"; + + url = System.getProperty("url","jdbc:mysql://localhost:3306/mysql?autoReconnect=true"); + driverClassName = System.getProperty("driverClassName","com.mysql.jdbc.Driver"); + password = System.getProperty("password","password"); + username = System.getProperty("username","root"); + + validationQuery = System.getProperty("validationQuery","SELECT 1"); defaultAutoCommit = true; defaultReadOnly = false; defaultTransactionIsolation = DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION; @@ -42,7 +45,7 @@ public class DefaultProperties extends PoolProperties { maxIdle = initialSize; minIdle = initialSize; maxWait = 10000; - validationQuery = "SELECT 1"; + testOnBorrow = true; testOnReturn = false; testWhileIdle = true; diff --git a/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java b/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java index 8807e2c18..cbc75a1e4 100644 --- a/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java +++ b/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java @@ -80,10 +80,10 @@ public class TestSlowQueryReport extends DefaultTestCase { this.datasource.setMaxActive(1); this.datasource.setJdbcInterceptors(SlowQueryReport.class.getName()); Connection con = this.datasource.getConnection(); - String slowSql = "select 1"; + String fastSql = this.datasource.getValidationQuery(); for (int i=0; i