aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/JDBC2Tests.java75
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/jdbc2/ConnectionTest.java28
-rw-r--r--src/interfaces/jdbc/org/postgresql/test/jdbc2/JBuilderTest.java22
3 files changed, 79 insertions, 46 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/test/JDBC2Tests.java b/src/interfaces/jdbc/org/postgresql/test/JDBC2Tests.java
index feeb0be5e9a..37565cfcc33 100644
--- a/src/interfaces/jdbc/org/postgresql/test/JDBC2Tests.java
+++ b/src/interfaces/jdbc/org/postgresql/test/JDBC2Tests.java
@@ -59,49 +59,38 @@ public class JDBC2Tests extends TestSuite {
}
}
- /**
- * Helper - creates a test table for use by a test
- */
- public static void createTable(Connection conn,String columns) {
- try {
- Statement st = conn.createStatement();
-
- // Ignore the drop
- try {
- st.executeUpdate("drop table "+getTableName());
- } catch(SQLException se) {
- }
-
- // Now create the table
- st.executeUpdate("create table "+getTableName()+" ("+columns+")");
-
- st.close();
- } catch(SQLException ex) {
- TestCase.assert(ex.getMessage(),false);
- }
- }
-
- /**
- * Variant used when more than one table is required
- */
- public static void createTable(Connection conn,String id,String columns) {
- try {
- Statement st = conn.createStatement();
-
- // Ignore the drop
- try {
- st.executeUpdate("drop table "+getTableName(id));
- } catch(SQLException se) {
- }
-
- // Now create the table
- st.executeUpdate("create table "+getTableName(id)+" ("+columns+")");
-
- st.close();
- } catch(SQLException ex) {
- TestCase.assert(ex.getMessage(),false);
- }
- }
+ /**
+ * Helper - creates a test table for use by a test
+ */
+ public static void createTable(
+ Connection conn, String table, String columns) {
+ try {
+ Statement st = conn.createStatement();
+ try {
+ try {
+ st.executeUpdate("drop table " + table);
+ } catch(SQLException se) {
+ // Intentionally ignore exception
+ }
+
+ // Now create the table
+ st.executeUpdate( "create table " + table + " (" + columns +
+ ")" );
+ } finally {
+ st.close();
+ }
+ } catch(SQLException ex) {
+ TestCase.assert(ex.getMessage(),false);
+ }
+ }
+
+ // Create the test table whose name is passed via the properties
+ // (see ../../../build.xml). It appears that the original author of
+ // this test suite intended to specify all test table names via the
+ // properties, but this was never fully implemented.
+ public static void createTable(Connection conn, String columns) {
+ createTable(conn, getTableName(), columns);
+ }
/**
* Helper - generates INSERT SQL - very simple
diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/ConnectionTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/ConnectionTest.java
index 58c5c7258fa..b9c2444c79c 100644
--- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/ConnectionTest.java
+++ b/src/interfaces/jdbc/org/postgresql/test/jdbc2/ConnectionTest.java
@@ -10,7 +10,7 @@ import java.sql.*;
*
* PS: Do you know how difficult it is to type on a train? ;-)
*
- * $Id: ConnectionTest.java,v 1.2 2001/02/13 16:39:05 peter Exp $
+ * $Id: ConnectionTest.java,v 1.3 2001/09/07 22:17:48 momjian Exp $
*/
public class ConnectionTest extends TestCase {
@@ -22,6 +22,30 @@ public class ConnectionTest extends TestCase {
super(name);
}
+ // Set up the fixture for this testcase: the tables for this test.
+ protected void setUp() throws Exception {
+ Connection con = JDBC2Tests.openDB();
+
+ JDBC2Tests.createTable( con, "test_a",
+ "imagename name,image oid,id int4" );
+
+ JDBC2Tests.createTable( con, "test_c",
+ "source text,cost money,imageid int4" );
+
+ JDBC2Tests.closeDB(con);
+ }
+
+ // Tear down the fixture for this test case.
+ protected void tearDown() throws Exception {
+ Connection con = JDBC2Tests.openDB();
+ Statement stmt = con.createStatement();
+
+ stmt.executeUpdate("DROP TABLE test_a");
+ stmt.executeUpdate("DROP TABLE test_c");
+ stmt.close();
+ JDBC2Tests.closeDB(con);
+ }
+
/**
* Tests the two forms of createStatement()
*/
@@ -234,4 +258,4 @@ public class ConnectionTest extends TestCase {
assert(ex.getMessage(),false);
}
}
-} \ No newline at end of file
+}
diff --git a/src/interfaces/jdbc/org/postgresql/test/jdbc2/JBuilderTest.java b/src/interfaces/jdbc/org/postgresql/test/jdbc2/JBuilderTest.java
index 986f61df386..c114eb0c515 100644
--- a/src/interfaces/jdbc/org/postgresql/test/jdbc2/JBuilderTest.java
+++ b/src/interfaces/jdbc/org/postgresql/test/jdbc2/JBuilderTest.java
@@ -6,7 +6,7 @@ import java.sql.*;
import java.math.BigDecimal;
/**
- * $Id: JBuilderTest.java,v 1.1 2001/02/13 16:39:05 peter Exp $
+ * $Id: JBuilderTest.java,v 1.2 2001/09/07 22:17:48 momjian Exp $
*
* Some simple tests to check that the required components needed for JBuilder
* stay working
@@ -18,6 +18,26 @@ public class JBuilderTest extends TestCase {
super(name);
}
+ // Set up the fixture for this testcase: the tables for this test.
+ protected void setUp() throws Exception {
+ Connection con = JDBC2Tests.openDB();
+
+ JDBC2Tests.createTable( con, "test_c",
+ "source text,cost money,imageid int4" );
+
+ JDBC2Tests.closeDB(con);
+ }
+
+ // Tear down the fixture for this test case.
+ protected void tearDown() throws Exception {
+ Connection con = JDBC2Tests.openDB();
+ Statement stmt = con.createStatement();
+
+ stmt.executeUpdate("DROP TABLE test_c");
+ stmt.close();
+ JDBC2Tests.closeDB(con);
+ }
+
/**
* This tests that Money types work. JDBCExplorer barfs if this fails.
*/