Skip to content

Commit

Permalink
net-sf-ucanaccess-fork: Improvements to unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spannm committed Sep 24, 2023
1 parent c539f3d commit b11781f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@

class SummerTimeLostHourTest extends UcanaccessBaseTest {

private static Locale prevLocale;
private static Locale prevLocale;
private static TimeZone prevTimeZone;

@BeforeAll
static void goToRome() {
static void setLocalAndTimezone() {
prevLocale = Locale.getDefault();
prevTimeZone = TimeZone.getDefault();
Locale.setDefault(Locale.ITALY);
TimeZone.setDefault(TimeZone.getTimeZone("Europe/Rome"));
}

@AfterAll
static void returnHomeFromRome() {
static void resetLocalAndTimezone() {
Locale.setDefault(prevLocale);
TimeZone.setDefault(prevTimeZone);
}
Expand All @@ -56,21 +56,21 @@ void testForLostHour(AccessVersion _accessVersion) throws SQLException, IOExcept
*/
Connection hsqldbConn = ucanaccess.getHSQLDBConnection();
Statement hsqldbStmt = hsqldbConn.createStatement();
ResultSet rs = hsqldbStmt.executeQuery("SELECT CAST(DTMFIELD AS VARCHAR(26)) AS str FROM TABLE1 WHERE ID=1");
ResultSet rs = hsqldbStmt.executeQuery("SELECT CAST(f_datetime AS VARCHAR(26)) AS str FROM t_datetime WHERE id=1");
rs.next();
assertEquals("2017-03-26 02:00:00.000000", rs.getString(1));

/*
* also ensure that 02:00:00 -> 01:00:00 doesn't happen when writing back to Access
*/
Statement ucaStmt = ucanaccess.createStatement();
ucaStmt.executeUpdate("UPDATE Table1 SET txtField='updated' WHERE id=1");
ucaStmt.executeUpdate("UPDATE t_datetime SET f_descr='updated' WHERE id=1");

LocalDateTime expectedBackFromAccess = LocalDateTime.of(2017, 3, 26, 2, 0);
Database db = ucanaccess.getDbIO();
Table tbl = db.getTable("Table1");
Table tbl = db.getTable("t_datetime");
Row r = CursorBuilder.findRowByPrimaryKey(tbl, 1);
assertEquals(expectedBackFromAccess, r.get("dtmField"));
assertEquals(expectedBackFromAccess, r.get("f_datetime"));
}

}
Binary file modified src/test/resources/testdbs/summerTimeLostHour.accdb
Binary file not shown.

0 comments on commit b11781f

Please sign in to comment.