1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-30 06:01:21 +03:00

Some more including the patch to DatabaseMetaData backed out by Bruce.

Tue Feb 13 16:33:00 GMT 2001 peter@retep.org.uk
        - More TestCases implemented. Refined the test suite api's.
        - Removed need for SimpleDateFormat in ResultSet.getDate() improving
          performance.
        - Rewrote ResultSet.getTime() so that it uses JDK api's better.

Tue Feb 13 10:25:00 GMT 2001 peter@retep.org.uk
        - Added MiscTest to hold reported problems from users.
        - Fixed PGMoney.
        - JBuilder4/JDBCExplorer now works with Money fields. Patched Field &
          ResultSet (lots of methods) for this one. Also changed cash/money to
          return type DOUBLE not DECIMAL. This broke JBuilder as zero scale
          BigDecimal's can't have decimal places!
        - When a Statement is reused, the previous ResultSet is now closed.
        - Removed deprecated call in ResultSet.getTime()

Thu Feb 08 18:53:00 GMT 2001 peter@retep.org.uk
        - Changed a couple of settings in DatabaseMetaData where 7.1 now
          supports those features
        - Implemented the DatabaseMetaData TestCase.

Wed Feb 07 18:06:00 GMT 2001 peter@retep.org.uk
        - Added comment to Connection.isClosed() explaining why we deviate from
          the JDBC2 specification.
        - Fixed bug where the Isolation Level is lost while in autocommit mode.
        - Fixed bug where several calls to getTransactionIsolationLevel()
          returned the first call's result.
This commit is contained in:
Peter Mount
2001-02-13 16:39:06 +00:00
parent 2410963e8c
commit 3d21bf82c3
17 changed files with 1149 additions and 103 deletions

View File

@@ -0,0 +1,136 @@
package org.postgresql.test.jdbc2;
import org.postgresql.test.JDBC2Tests;
import junit.framework.TestCase;
import java.sql.*;
/**
* $Id: TimestampTest.java,v 1.1 2001/02/13 16:39:05 peter Exp $
*
* This has been the most controversial pair of methods since 6.5 was released!
*
* From now on, any changes made to either getTimestamp or setTimestamp
* MUST PASS this TestCase!!!
*
*/
public class TimestampTest extends TestCase {
public TimestampTest(String name) {
super(name);
}
/**
* Tests the time methods in ResultSet
*/
public void testGetTimestamp() {
try {
Connection con = JDBC2Tests.openDB();
Statement st=con.createStatement();
JDBC2Tests.createTable(con,"ts timestamp");
st.executeUpdate(JDBC2Tests.insert("'1950-02-07 15:00:00'"));
// Before you ask why 8:13:00 and not 7:13:00, this is a problem with the
// getTimestamp method in this TestCase. It's simple, brain-dead. It
// simply doesn't know about summer time. As this date is in June, it's
// summer (GMT wise).
//
// This case needs some work done on it.
//
st.executeUpdate(JDBC2Tests.insert("'"+getTimestamp(1970,6,2,8,13,0).toString()+"'"));
//st.executeUpdate(JDBC2Tests.insert("'1950-02-07'"));
// Fall through helper
checkTimeTest(con,st);
st.close();
JDBC2Tests.closeDB(con);
} catch(Exception ex) {
assert(ex.getMessage(),false);
}
}
/**
* Tests the time methods in PreparedStatement
*/
public void testSetTimestamp() {
try {
Connection con = JDBC2Tests.openDB();
Statement st=con.createStatement();
JDBC2Tests.createTable(con,"ts timestamp");
PreparedStatement ps = con.prepareStatement(JDBC2Tests.insert("?"));
ps.setTimestamp(1,getTimestamp(1950,2,7,15,0,0));
assert(!ps.execute()); // false as its an update!
// Before you ask why 8:13:00 and not 7:13:00, this is a problem with the
// getTimestamp method in this TestCase. It's simple, brain-dead. It
// simply doesn't know about summer time. As this date is in June, it's
// summer (GMT wise).
//
// This case needs some work done on it.
//
ps.setTimestamp(1,getTimestamp(1970,6,2,7,13,0));
assert(!ps.execute()); // false as its an update!
// Fall through helper
checkTimeTest(con,st);
ps.close();
st.close();
JDBC2Tests.closeDB(con);
} catch(Exception ex) {
assert(ex.getMessage(),false);
}
}
/**
* Helper for the TimeTests. It tests what should be in the db
*/
private void checkTimeTest(Connection con,Statement st) throws SQLException {
ResultSet rs=null;
java.sql.Timestamp t=null;
rs=st.executeQuery(JDBC2Tests.select("ts"));
assert(rs!=null);
assert(rs.next());
t = rs.getTimestamp(1);
assert(t!=null);
assert(t.equals(getTimestamp(1950,2,7,15,0,0)));
assert(rs.next());
t = rs.getTimestamp(1);
assert(t!=null);
assert(t.equals(getTimestamp(1970,6,2,7,13,0)));
assert(!rs.next()); // end of table. Fail if more entries exist.
rs.close();
}
/**
* These implement depreciated methods in java.sql.Time
*/
private static final long dayms = 24*3600*1000;
/**
* Yes this is ugly, but it gets the test done ;-)
*
* Actually its buggy. We need a better solution to this, then the hack of adding 1 hour to
* entries in June above don't need setting.
*/
private java.sql.Timestamp getTimestamp(int y,int m,int d,int h,int mn,int se) {
return java.sql.Timestamp.valueOf(JDBC2Tests.fix(y,4)+"-"+JDBC2Tests.fix(m,2)+"-"+JDBC2Tests.fix(d,2)+" "+JDBC2Tests.fix(h,2)+":"+JDBC2Tests.fix(mn,2)+":"+JDBC2Tests.fix(se,2)+"."+JDBC2Tests.fix(0,9));
}
}