Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 20424 invoked from network); 9 Apr 2006 04:42:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 9 Apr 2006 04:42:51 -0000 Received: (qmail 53799 invoked by uid 500); 9 Apr 2006 04:42:48 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 53703 invoked by uid 500); 9 Apr 2006 04:42:48 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 53692 invoked by uid 500); 9 Apr 2006 04:42:47 -0000 Received: (qmail 53689 invoked by uid 99); 9 Apr 2006 04:42:47 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Apr 2006 21:42:47 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Sat, 08 Apr 2006 21:42:46 -0700 Received: (qmail 20314 invoked by uid 65534); 9 Apr 2006 04:42:26 -0000 Message-ID: <20060409044226.20313.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r392677 - in /jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp: TestBasicDataSource.java TestConnectionPool.java TestJOCLed.java Date: Sun, 09 Apr 2006 04:42:25 -0000 To: commons-cvs@jakarta.apache.org From: psteitz@apache.org X-Mailer: svnmailer-1.0.7 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: psteitz Date: Sat Apr 8 21:42:24 2006 New Revision: 392677 URL: http://svn.apache.org/viewcvs?rev=392677&view=rev Log: Modified TestConnectionPool to ensure connections opened by test cases are closed in tearDown. Also changed testPooling to make it independent of underlying pool borrow / return semantics. Modified: jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSource.java jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestJOCLed.java Modified: jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSource.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSource.java?rev=392677&r1=392676&r2=392677&view=diff ============================================================================== --- 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 Sat Apr 8 21:42:24 2006 @@ -63,6 +63,7 @@ public void tearDown() throws Exception { super.tearDown(); + ds.close(); ds = null; } Modified: jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java?rev=392677&r1=392676&r2=392677&view=diff ============================================================================== --- jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java (original) +++ jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java Sat Apr 8 21:42:24 2006 @@ -21,6 +21,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.util.Stack; import junit.framework.TestCase; @@ -50,6 +51,17 @@ public void tearDown() throws Exception { super.tearDown(); + // Close any connections opened by the test + while (!connections.isEmpty()) { + Connection conn = (Connection) connections.pop(); + try { + conn.close(); + } catch (Exception ex) { + // ignore + } finally { + conn = null; + } + } } protected abstract Connection getConnection() throws Exception; @@ -61,6 +73,16 @@ protected long getMaxWait() { return 100L; } + + /** Connections opened during the course of a test */ + protected Stack connections = new Stack(); + + /** Acquire a connection and push it onto the connections stack */ + protected Connection newConnection() throws Exception { + Connection connection = getConnection(); + connections.push(connection); + return connection; + } // ----------- Utility Methods --------------------------------- @@ -78,7 +100,7 @@ public void testClearWarnings() throws Exception { Connection[] c = new Connection[getMaxActive()]; for (int i = 0; i < c.length; i++) { - c[i] = getConnection(); + c[i] = newConnection(); assertTrue(c[i] != null); // generate SQLWarning on connection @@ -94,7 +116,7 @@ } for (int i = 0; i < c.length; i++) { - c[i] = getConnection(); + c[i] = newConnection(); } for (int i = 0; i < c.length; i++) { @@ -109,7 +131,7 @@ public void testIsClosed() throws Exception { for(int i=0;i