Hi,
So I have a test that is now failing when upgrading from 1.3.153 to 1.4.182
The test code is:
@Test
public void testDirect() throws SQLException {
// For it to fail, the time has to match the time at which the daylight
saving changes
// are applied in that time zone. Therefore specify it explicitly.
// Get a connection ...
EbeanServer server = Ebean.getServer(null);
Transaction transaction = server.createTransaction();
Connection connection = transaction.getConnection();
PreparedStatement pstmt = connection.prepareStatement("create table
dls_test (id bigint auto_increment not null, myts timestamp)");
pstmt.execute();
pstmt.close();
TimeZone defaultTimeZone = TimeZone.getDefault();
try {
TimeZone.setDefault(TimeZone.getTimeZone("EET"));
// Run the code and see how there is a 3600 second change
Timestamp daylightSavingDate = new Timestamp(1351382400000l);
// On a second run comment in the following date and see
// how there is a 0 second change
// daylightSavingDate = new Date(1361382400000l);
pstmt = connection.prepareStatement("insert into dls_test (myts)
values (?)");
pstmt.setTimestamp(1, daylightSavingDate);
assertEquals(1, pstmt.executeUpdate());
pstmt.close();
pstmt = connection.prepareStatement("select myts from dls_test ");
ResultSet rset = pstmt.executeQuery();
rset.next();
Timestamp timestampBack = rset.getTimestamp(1);
pstmt.close();
rset.close();
long diffMillis = daylightSavingDate.getTime() -
timestampBack.getTime();
System.out.println(" --- the date i put in : " +
daylightSavingDate);
System.out.println(" as millis : " +
daylightSavingDate.getTime());
System.out.println(" --- the date i get back : " + timestampBack);
System.out.println(" as millis : " +
timestampBack.getTime());
System.out.println("The difference is " + diffMillis / 1000 + "
seconds");
assertEquals(0L, diffMillis);
} finally {
TimeZone.setDefault(defaultTimeZone);
}
}
Using version 1.3.153 the test passes and the output is:
--- the date i put in : 2012-10-28 03:00:00.0
as millis : 1351382400000
--- the date i get back : 2012-10-28 03:00:00.0
as millis : 1351382400000
The difference is 0 seconds
Using version 1.4.182 the test fails and the output is:
--- the date i put in : 2012-10-28 03:00:00.0
as millis : 1351382400000
--- the date i get back : 2012-10-28 03:00:00.0
as millis : 1351386000000
The difference is -3600 seconds
java.lang.AssertionError:
Expected :0
Actual :-3600000
<Click to see difference>
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:743)
at org.junit.Assert.assertEquals(Assert.java:118)
at org.junit.Assert.assertEquals(Assert.java:555)
at org.junit.Assert.assertEquals(Assert.java:542)
at
com.avaje.tests.insert.TestSaveWithDaylightSavings.testDirect(TestSaveWithDaylightSavings.java:110)
...
Is the test valid or perhaps there is some bug introduced?
Thanks, Rob.
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.