From 0b58596c909785ebc718a637a867c15c318b11d2 Mon Sep 17 00:00:00 2001 From: fhanik Date: Sat, 2 May 2009 04:24:59 +0000 Subject: [PATCH] Fix closure of connections in test cases git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@770888 13f79535-47bb-0310-9956-ffa450edef68 --- .../test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java | 1 + .../test/org/apache/tomcat/jdbc/test/DefaultTestCase.java | 7 +++++++ 2 files changed, 8 insertions(+) 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 aa587a9fb..6e2aedf42 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 @@ -58,6 +58,7 @@ public class CheckOutThreadTest extends DefaultTestCase { public void testPoolThreads10Connections10() throws Exception { init(); this.datasource.getPoolProperties().setMaxActive(10); + this.datasource.getPoolProperties().setFairQueue(false); this.threadcount = 10; this.transferProperties(); this.datasource.getConnection().close(); diff --git a/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultTestCase.java b/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultTestCase.java index 251f413a9..ae1b95aa7 100644 --- a/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultTestCase.java +++ b/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultTestCase.java @@ -29,6 +29,8 @@ import org.apache.tomcat.jdbc.pool.PoolProperties; import org.apache.tomcat.jdbc.pool.DataSourceProxy; import com.mchange.v2.c3p0.ComboPooledDataSource; +import com.mchange.v2.log.MLevel; +import com.mchange.v2.log.MLog; /** * @author Filip Hanik @@ -103,6 +105,7 @@ public class DefaultTestCase extends TestCase { protected void transferPropertiesToC3P0() throws Exception { System.setProperty("com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL", "WARNING"); + MLog.getLogger().setLevel(MLevel.WARNING); //http://www.mchange.com/projects/c3p0/index.html#automaticTestTable ComboPooledDataSource c3p0 = new ComboPooledDataSource(); c3p0.setAcquireIncrement(1); @@ -126,6 +129,7 @@ public class DefaultTestCase extends TestCase { c3p0.setJdbcUrl(datasource.getPoolProperties().getUrl()); c3p0.setDriverClass(datasource.getPoolProperties().getDriverClassName()); this.c3p0Datasource = c3p0; + /** acquireIncrement acquireRetryAttempts @@ -166,8 +170,11 @@ public class DefaultTestCase extends TestCase { protected void tearDown() throws Exception { try {datasource.close();}catch(Exception ignore){} + try {tDatasource.close();}catch(Exception ignore){} + try {((ComboPooledDataSource)c3p0Datasource).close(true);}catch(Exception ignore){} datasource = null; tDatasource = null; + c3p0Datasource = null; System.gc(); } -- 2.11.0