From: | Mikko Tiihonen <mikko(dot)tiihonen(at)iki(dot)fi> |
---|---|
To: | pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Fix more unit test connection leaks |
Date: | 2007-07-22 00:02:49 |
Message-ID: | 1185062569.1632.80.camel@dual.local |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Hi,
I found some more connection leaks from the test cases.
Index: org/postgresql/test/jdbc2/MiscTest.java
===================================================================
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/jdbc2/MiscTest.java,v
retrieving revision 1.20
diff -u -r1.20 MiscTest.java
--- org/postgresql/test/jdbc2/MiscTest.java 2 Dec 2005 03:05:10 -0000 1.20
+++ org/postgresql/test/jdbc2/MiscTest.java 21 Jul 2007 21:08:18 -0000
@@ -66,6 +66,7 @@
rs.close();
stmt.cancel();
}
+ TestUtil.closeDB(con);
}
public void testError() throws Exception
@@ -130,5 +131,6 @@
con.commit();
TestUtil.dropTable(con, "test_lock");
con.close();
+ con2.close();
}
}
Index: org/postgresql/test/jdbc2/ConnectionTest.java
===================================================================
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/jdbc2/ConnectionTest.java,v
retrieving revision 1.21
diff -u -r1.21 ConnectionTest.java
--- org/postgresql/test/jdbc2/ConnectionTest.java 24 Nov 2005 02:31:43 -0000 1.21
+++ org/postgresql/test/jdbc2/ConnectionTest.java 21 Jul 2007 21:08:17 -0000
@@ -22,6 +22,8 @@
public class ConnectionTest extends TestCase
{
+ private Connection con;
+
/*
* Constructor
*/
@@ -33,7 +35,7 @@
// Set up the fixture for this testcase: the tables for this test.
protected void setUp() throws Exception
{
- Connection con = TestUtil.openDB();
+ con = TestUtil.openDB();
TestUtil.createTable(con, "test_a", "imagename name,image oid,id int4");
TestUtil.createTable(con, "test_c", "source text,cost money,imageid int4");
@@ -44,7 +46,9 @@
// Tear down the fixture for this test case.
protected void tearDown() throws Exception
{
- Connection con = TestUtil.openDB();
+ TestUtil.closeDB(con);
+
+ con = TestUtil.openDB();
TestUtil.dropTable(con, "test_a");
TestUtil.dropTable(con, "test_c");
@@ -57,15 +61,15 @@
*/
public void testCreateStatement() throws Exception
{
- Connection conn = TestUtil.openDB();
+ con = TestUtil.openDB();
// A standard Statement
- Statement stat = conn.createStatement();
+ Statement stat = con.createStatement();
assertNotNull(stat);
stat.close();
// Ask for Updateable ResultSets
- stat = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
+ stat = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
assertNotNull(stat);
stat.close();
}
@@ -75,17 +79,17 @@
*/
public void testPrepareStatement() throws Exception
{
- Connection conn = TestUtil.openDB();
+ con = TestUtil.openDB();
String sql = "select source,cost,imageid from test_c";
// A standard Statement
- PreparedStatement stat = conn.prepareStatement(sql);
+ PreparedStatement stat = con.prepareStatement(sql);
assertNotNull(stat);
stat.close();
// Ask for Updateable ResultSets
- stat = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
+ stat = con.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
assertNotNull(stat);
stat.close();
}
@@ -103,7 +107,7 @@
public void testNativeSQL() throws Exception
{
// test a simple escape
- Connection con = TestUtil.openDB();
+ con = TestUtil.openDB();
assertEquals("DATE '2005-01-24'",con.nativeSQL("{d '2005-01-24'}"));
}
@@ -112,7 +116,7 @@
*/
public void testTransactions() throws Exception
{
- Connection con = TestUtil.openDB();
+ con = TestUtil.openDB();
Statement st;
ResultSet rs;
@@ -154,7 +158,7 @@
*/
public void testIsClosed() throws Exception
{
- Connection con = TestUtil.openDB();
+ con = TestUtil.openDB();
// Should not say closed
assertTrue(!con.isClosed());
@@ -170,7 +174,7 @@
*/
public void testWarnings() throws Exception
{
- Connection con = TestUtil.openDB();
+ con = TestUtil.openDB();
String testStr = "This Is OuR TeSt message";
@@ -200,7 +204,7 @@
*/
public void testTransactionIsolation() throws Exception
{
- Connection con = TestUtil.openDB();
+ con = TestUtil.openDB();
// PostgreSQL defaults to READ COMMITTED
assertEquals(Connection.TRANSACTION_READ_COMMITTED,
@@ -274,7 +278,7 @@
*/
public void testTypeMaps() throws Exception
{
- Connection con = TestUtil.openDB();
+ con = TestUtil.openDB();
// preserve the current map
java.util.Map oldmap = con.getTypeMap();
@@ -296,7 +300,7 @@
*/
public void testDoubleClose() throws Exception
{
- Connection con = TestUtil.openDB();
+ con = TestUtil.openDB();
con.close();
con.close();
}
Index: org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
===================================================================
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java,v
retrieving revision 1.38
diff -u -r1.38 DatabaseMetaDataTest.java
--- org/postgresql/test/jdbc2/DatabaseMetaDataTest.java 15 Jul 2007 15:33:33 -0000 1.38
+++ org/postgresql/test/jdbc2/DatabaseMetaDataTest.java 21 Jul 2007 21:08:18 -0000
@@ -167,6 +167,7 @@
TestUtil.dropTable( con1, "vv" );
TestUtil.dropTable( con1, "ww" );
+ TestUtil.closeDB(con1);
}
public void testForeignKeyActions() throws Exception
@@ -192,6 +193,7 @@
TestUtil.dropTable(conn, "fkt2");
TestUtil.dropTable(conn, "fkt1");
TestUtil.dropTable(conn, "pkt");
+ TestUtil.closeDB(conn);
}
public void testForeignKeysToUniqueIndexes() throws Exception
@@ -310,7 +312,7 @@
TestUtil.dropTable( con1, "users" );
TestUtil.dropTable( con1, "people" );
TestUtil.dropTable( con1, "policy" );
-
+ TestUtil.closeDB(con1);
}
public void testColumns() throws SQLException
From | Date | Subject | |
---|---|---|---|
Next Message | Kris Jurka | 2007-07-22 01:31:54 | Re: Fix more unit test connection leaks |
Previous Message | Mikko Tiihonen | 2007-07-21 20:12:35 | Re: Fix resultset results after updateBinaryStream |