1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-02 11:44:50 +03:00
Bruce Momjian b6385efb79 Attached is a patch that fixes 2 test cases of the JDBC test
suite. This reduces the number of failures from 9 to 7.

Both ConnectionTest and JBuilderTest did not create their own
tables, which caused these test cases to fail with "relation ...
does not exist". It appears these test cases relied on tables
created by the example code elsewhere in the source tree. I've
added the necessary "create table" and "drop table" statements
to the test cases, using the column definitions from the example
code.

While working on that I modified the helper method createTable
in JDBC2Tests.java to take a table parameter, rather than using
table names passed via the properties in build.xml. I'm not sure
what that was good for, and in fact, except for the default
table name "jdbctest", this functionality wasn't used at all.

Ren? Pijlman
2001-09-07 22:17:48 +00:00

65 lines
1.5 KiB
Java

package org.postgresql.test.jdbc2;
import org.postgresql.test.JDBC2Tests;
import junit.framework.TestCase;
import java.sql.*;
import java.math.BigDecimal;
/**
* $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
*
*/
public class JBuilderTest extends TestCase {
public JBuilderTest(String name) {
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.
*/
public void testMoney() {
try {
Connection con = JDBC2Tests.openDB();
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select cost from test_c");
assert(rs!=null);
while(rs.next()){
double bd = rs.getDouble(1);
}
rs.close();
st.close();
JDBC2Tests.closeDB(con);
} catch(Exception ex) {
assert(ex.getMessage(),false);
}
}
}