JDBC Driver - Test Suite Drop w/ Cascase + optional jdbc2 - Mailing list pgsql-patches
| From | Kris Jurka |
|---|---|
| Subject | JDBC Driver - Test Suite Drop w/ Cascase + optional jdbc2 |
| Date | |
| Msg-id | 3D7E466E.7020405@ejurka.com Whole thread Raw |
| List | pgsql-patches |
This patch replaces the original Drop Table w/ Cascade patch and allows
the jdbc2 tests to be built and run successfully.
Kris Jurka
Index: src/interfaces/jdbc/org/postgresql/test/TestUtil.java
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/test/TestUtil.java,v
retrieving revision 1.1
diff -c -r1.1 TestUtil.java
*** src/interfaces/jdbc/org/postgresql/test/TestUtil.java 2002/08/14 20:35:40 1.1
--- src/interfaces/jdbc/org/postgresql/test/TestUtil.java 2002/09/10 19:18:07
***************
*** 109,119 ****
Statement stmt = con.createStatement();
try
{
! stmt.executeUpdate("DROP TABLE " + table);
}
catch (SQLException ex)
{
! // ignore
}
}
catch (SQLException ex)
--- 109,134 ----
Statement stmt = con.createStatement();
try
{
! String sql = "DROP TABLE " + table;
! if (con instanceof org.postgresql.jdbc1.AbstractJdbc1Connection &&
((org.postgresql.jdbc1.AbstractJdbc1Connection)con).haveMinimumServerVersion("7.3")){
! sql += " CASCADE ";
! }
! stmt.executeUpdate(sql);
}
catch (SQLException ex)
{
! // Since every create table issues a drop table
! // it's easy to get a table doesn't exist error.
! // we want to ignore these, but if we're in a
! // transaction we need to restart.
! // If the test case wants to catch this error
! // itself it should issue the drop SQL directly.
! if (ex.getMessage().indexOf("does not exist") != -1) {
! if (!con.getAutoCommit()) {
! con.rollback();
! }
!
! }
}
}
catch (SQLException ex)
Index: src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/BaseDataSourceTest.java
===================================================================
RCS file:
/projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/BaseDataSourceTest.java,v
retrieving revision 1.2
diff -c -r1.2 BaseDataSourceTest.java
*** src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/BaseDataSourceTest.java 2002/09/06 21:23:06 1.2
--- src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/BaseDataSourceTest.java 2002/09/10 19:18:07
***************
*** 1,7 ****
package org.postgresql.test.jdbc2.optional;
import junit.framework.TestCase;
! import org.postgresql.test.JDBC2Tests;
import org.postgresql.jdbc2.optional.SimpleDataSource;
import org.postgresql.jdbc2.optional.BaseDataSource;
--- 1,7 ----
package org.postgresql.test.jdbc2.optional;
import junit.framework.TestCase;
! import org.postgresql.test.TestUtil;
import org.postgresql.jdbc2.optional.SimpleDataSource;
import org.postgresql.jdbc2.optional.BaseDataSource;
***************
*** 36,47 ****
*/
protected void setUp() throws Exception
{
! con = JDBC2Tests.openDB();
! JDBC2Tests.createTable(con, "poolingtest", "id int4 not null primary key, name varchar(50)");
Statement stmt = con.createStatement();
stmt.executeUpdate("INSERT INTO poolingtest VALUES (1, 'Test Row 1')");
stmt.executeUpdate("INSERT INTO poolingtest VALUES (2, 'Test Row 2')");
! JDBC2Tests.closeDB(con);
}
/**
--- 36,47 ----
*/
protected void setUp() throws Exception
{
! con = TestUtil.openDB();
! TestUtil.createTable(con, "poolingtest", "id int4 not null primary key, name varchar(50)");
Statement stmt = con.createStatement();
stmt.executeUpdate("INSERT INTO poolingtest VALUES (1, 'Test Row 1')");
stmt.executeUpdate("INSERT INTO poolingtest VALUES (2, 'Test Row 2')");
! TestUtil.closeDB(con);
}
/**
***************
*** 50,58 ****
*/
protected void tearDown() throws Exception
{
! con = JDBC2Tests.openDB();
! JDBC2Tests.dropTable(con, "poolingtest");
! JDBC2Tests.closeDB(con);
}
/**
--- 50,58 ----
*/
protected void tearDown() throws Exception
{
! con = TestUtil.openDB();
! TestUtil.dropTable(con, "poolingtest");
! TestUtil.closeDB(con);
}
/**
***************
*** 142,149 ****
try
{
con = getDataSourceConnection();
! JDBC2Tests.dropTable(con, "poolingtest");
! JDBC2Tests.createTable(con, "poolingtest", "id int4 not null primary key, name varchar(50)");
con.close();
}
catch (SQLException e)
--- 142,148 ----
try
{
con = getDataSourceConnection();
! TestUtil.createTable(con, "poolingtest", "id int4 not null primary key, name varchar(50)");
con.close();
}
catch (SQLException e)
Index: src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java
===================================================================
RCS file:
/projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java,v
retrieving revision 1.2
diff -c -r1.2 ConnectionPoolTest.java
*** src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java 2002/09/06 21:23:06 1.2
--- src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java 2002/09/10 19:18:07
***************
*** 1,7 ****
package org.postgresql.test.jdbc2.optional;
import org.postgresql.jdbc2.optional.ConnectionPool;
! import org.postgresql.test.JDBC2Tests;
import javax.sql.*;
import java.sql.*;
--- 1,7 ----
package org.postgresql.test.jdbc2.optional;
import org.postgresql.jdbc2.optional.ConnectionPool;
! import org.postgresql.test.TestUtil;
import javax.sql.*;
import java.sql.*;
***************
*** 31,37 ****
if (bds == null)
{
bds = new ConnectionPool();
! String db = JDBC2Tests.getURL();
if (db.indexOf('/') > -1)
{
db = db.substring(db.lastIndexOf('/') + 1);
--- 31,37 ----
if (bds == null)
{
bds = new ConnectionPool();
! String db = TestUtil.getURL();
if (db.indexOf('/') > -1)
{
db = db.substring(db.lastIndexOf('/') + 1);
***************
*** 41,48 ****
db = db.substring(db.lastIndexOf(':') + 1);
}
bds.setDatabaseName(db);
! bds.setUser(JDBC2Tests.getUser());
! bds.setPassword(JDBC2Tests.getPassword());
}
}
--- 41,48 ----
db = db.substring(db.lastIndexOf(':') + 1);
}
bds.setDatabaseName(db);
! bds.setUser(TestUtil.getUser());
! bds.setPassword(TestUtil.getPassword());
}
}
Index: src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/SimpleDataSourceTest.java
===================================================================
RCS file:
/projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/SimpleDataSourceTest.java,v
retrieving revision 1.2
diff -c -r1.2 SimpleDataSourceTest.java
*** src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/SimpleDataSourceTest.java 2002/09/06 21:23:06 1.2
--- src/interfaces/jdbc/org/postgresql/test/jdbc2/optional/SimpleDataSourceTest.java 2002/09/10 19:18:07
***************
*** 1,6 ****
package org.postgresql.test.jdbc2.optional;
! import org.postgresql.test.JDBC2Tests;
import org.postgresql.jdbc2.optional.SimpleDataSource;
/**
--- 1,6 ----
package org.postgresql.test.jdbc2.optional;
! import org.postgresql.test.TestUtil;
import org.postgresql.jdbc2.optional.SimpleDataSource;
/**
***************
*** 28,34 ****
if (bds == null)
{
bds = new SimpleDataSource();
! String db = JDBC2Tests.getURL();
if (db.indexOf('/') > -1)
{
db = db.substring(db.lastIndexOf('/') + 1);
--- 28,34 ----
if (bds == null)
{
bds = new SimpleDataSource();
! String db = TestUtil.getURL();
if (db.indexOf('/') > -1)
{
db = db.substring(db.lastIndexOf('/') + 1);
***************
*** 38,45 ****
db = db.substring(db.lastIndexOf(':') + 1);
}
bds.setDatabaseName(db);
! bds.setUser(JDBC2Tests.getUser());
! bds.setPassword(JDBC2Tests.getPassword());
}
}
}
--- 38,45 ----
db = db.substring(db.lastIndexOf(':') + 1);
}
bds.setDatabaseName(db);
! bds.setUser(TestUtil.getUser());
! bds.setPassword(TestUtil.getPassword());
}
}
}
pgsql-patches by date: