Author: fhanik Date: Mon Jun 29 14:36:57 2009 New Revision: 789345 URL: http://svn.apache.org/viewvc?rev=789345&view=rev Log: Make properties configurable and resolve https://issues.apache.org/bugzilla/show_bug.cgi?id=47440
Modified: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultProperties.java tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java Modified: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java?rev=789345&r1=789344&r2=789345&view=diff ============================================================================== --- tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java (original) +++ tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java Mon Jun 29 14:36:57 2009 @@ -202,7 +202,6 @@ 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 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 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 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 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 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 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 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(); Modified: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultProperties.java URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultProperties.java?rev=789345&r1=789344&r2=789345&view=diff ============================================================================== --- tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultProperties.java (original) +++ tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultProperties.java Mon Jun 29 14:36:57 2009 @@ -28,10 +28,13 @@ 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 @@ maxIdle = initialSize; minIdle = initialSize; maxWait = 10000; - validationQuery = "SELECT 1"; + testOnBorrow = true; testOnReturn = false; testWhileIdle = true; Modified: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java?rev=789345&r1=789344&r2=789345&view=diff ============================================================================== --- tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java (original) +++ tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestSlowQueryReport.java Mon Jun 29 14:36:57 2009 @@ -80,10 +80,10 @@ 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<count; i++) { Statement st = con.createStatement(); - ResultSet rs = st.executeQuery(slowSql); + ResultSet rs = st.executeQuery(fastSql); rs.close(); st.close(); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org