HHH-13379 Test storage of java.time type representing an instant near the end of DST

This commit is contained in:
Yoann Rodière 2019-07-26 08:32:15 +02:00 committed by gbadner
parent 89d304a00e
commit 0387090bba
8 changed files with 133 additions and 5 deletions

View File

@ -70,6 +70,8 @@ abstract class AbstractJavaTimeTypeTest<T, E> extends BaseCoreFunctionalTestCase
protected static final ZoneId ZONE_GMT = ZoneId.of( "GMT" );
protected static final ZoneId ZONE_OSLO = ZoneId.of( "Europe/Oslo" );
protected static final ZoneId ZONE_AMSTERDAM = ZoneId.of( "Europe/Amsterdam" );
protected static final ZoneId ZONE_AUCKLAND = ZoneId.of( "Pacific/Auckland" );
protected static final ZoneId ZONE_SANTIAGO = ZoneId.of( "America/Santiago" );
private final EnvironmentParameters env;

View File

@ -45,7 +45,7 @@ public class InstantTest extends AbstractJavaTimeTypeTest<Instant, InstantTest.E
@Parameterized.Parameters(name = "{1}-{2}-{3}T{4}:{5}:{6}.{7}Z {0}")
public static List<Object[]> data() {
return new ParametersBuilder()
// Not affected by HHH-13266 (JDK-8061577)
// Not affected by any known bug
.add( 2017, 11, 6, 19, 19, 1, 0, ZONE_UTC_MINUS_8 )
.add( 2017, 11, 6, 19, 19, 1, 0, ZONE_PARIS )
.add( 2017, 11, 6, 19, 19, 1, 500, ZONE_PARIS )
@ -66,6 +66,27 @@ public class InstantTest extends AbstractJavaTimeTypeTest<Instant, InstantTest.E
.add( 1899, 12, 31, 23, 59, 59, 999_999_999, ZONE_AMSTERDAM )
.add( 1600, 1, 1, 0, 0, 0, 0, ZONE_AMSTERDAM )
)
// HHH-13379: DST end (where Timestamp becomes ambiguous, see JDK-4312621)
// => This used to work correctly in 5.4.1.Final and earlier
.add( 2018, 10, 28, 1, 0, 0, 0, ZONE_PARIS )
.add( 2018, 3, 31, 14, 0, 0, 0, ZONE_AUCKLAND )
// => This has never worked correctly, unless the JDBC timezone was set to UTC
.withForcedJdbcTimezone( "UTC", b -> b
.add( 2018, 10, 28, 0, 0, 0, 0, ZONE_PARIS )
.add( 2018, 3, 31, 13, 0, 0, 0, ZONE_AUCKLAND )
)
// => Also test DST start, just in case
.add( 2018, 3, 25, 1, 0, 0, 0, ZONE_PARIS )
.add( 2018, 3, 25, 2, 0, 0, 0, ZONE_PARIS )
.add( 2018, 9, 30, 2, 0, 0, 0, ZONE_AUCKLAND )
.add( 2018, 9, 30, 3, 0, 0, 0, ZONE_AUCKLAND )
// => Also test dates around 1905-01-01, because the code behaves differently before and after 1905
.add( 1904, 12, 31, 22, 59, 59, 999_999_999, ZONE_PARIS )
.add( 1904, 12, 31, 23, 59, 59, 999_999_999, ZONE_PARIS )
.add( 1905, 1, 1, 0, 59, 59, 999_999_999, ZONE_PARIS )
.add( 1904, 12, 31, 23, 0, 0, 0, ZONE_PARIS )
.add( 1905, 1, 1, 0, 0, 0, 0, ZONE_PARIS )
.add( 1905, 1, 1, 1, 0, 0, 0, ZONE_PARIS )
.build();
}

View File

@ -65,6 +65,16 @@ public class LocalDateTest extends AbstractJavaTimeTypeTest<LocalDate, LocalDate
.add( 1900, 1, 1, ZONE_AMSTERDAM )
.add( 1600, 1, 1, ZONE_AMSTERDAM )
)
// HHH-13379: DST end (where Timestamp becomes ambiguous, see JDK-4312621)
// It doesn't seem that any date at midnight can be affected by HHH-13379, but we add some tests just in case
// => Test the day of DST end
.add( 2018, 10, 28, ZONE_PARIS )
.add( 2018, 9, 30, ZONE_AUCKLAND )
.add( 2018, 5, 13, ZONE_SANTIAGO ) // DST end: 00:00 => 23:00 previous day
// => Also test the day of DST start
.add( 2018, 3, 25, ZONE_PARIS )
.add( 2018, 9, 30, ZONE_AUCKLAND )
.add( 2018, 8, 12, ZONE_SANTIAGO ) // DST start: 00:00 => 01:00
.build();
}

View File

@ -61,6 +61,23 @@ public class LocalDateTimeTest extends AbstractJavaTimeTypeTest<LocalDateTime, L
.add( 1900, 1, 1, 0, 19, 31, 0, ZONE_AMSTERDAM )
.add( 1600, 1, 1, 0, 0, 0, 0, ZONE_AMSTERDAM )
)
// HHH-13379: DST end (where Timestamp becomes ambiguous, see JDK-4312621)
// It doesn't seem that any LocalDateTime can be affected by HHH-13379, but we add some tests just in case
.add( 2018, 10, 28, 1, 0, 0, 0, ZONE_PARIS )
.add( 2018, 10, 28, 2, 0, 0, 0, ZONE_PARIS )
.add( 2018, 10, 28, 3, 0, 0, 0, ZONE_PARIS )
.add( 2018, 10, 28, 4, 0, 0, 0, ZONE_PARIS )
.add( 2018, 4, 1, 1, 0, 0, 0, ZONE_AUCKLAND )
.add( 2018, 4, 1, 2, 0, 0, 0, ZONE_AUCKLAND )
.add( 2018, 4, 1, 3, 0, 0, 0, ZONE_AUCKLAND )
.add( 2018, 4, 1, 4, 0, 0, 0, ZONE_AUCKLAND )
// => Also test DST start
// This does not work, but it's unrelated to HHH-13379; see HHH-13515
//.add( 2018, 3, 25, 2, 0, 0, 0, ZONE_PARIS )
.add( 2018, 3, 25, 3, 0, 0, 0, ZONE_PARIS )
// This does not work, but it's unrelated to HHH-13379; see HHH-13515
//.add( 2018, 9, 30, 2, 0, 0, 0, ZONE_AUCKLAND )
.add( 2018, 9, 30, 3, 0, 0, 0, ZONE_AUCKLAND )
.build();
}

View File

@ -82,6 +82,14 @@ public class LocalTimeTest extends AbstractJavaTimeTypeTest<LocalTime, LocalTime
.addPersistedWithoutHibernate( 1900, 1, 1, 0, 19, 31, 0, ZONE_AMSTERDAM )
.addPersistedWithoutHibernate( 1600, 1, 1, 0, 0, 0, 0, ZONE_AMSTERDAM )
)
// HHH-13379: DST end (where Timestamp becomes ambiguous, see JDK-4312621)
// It doesn't seem that any time on 1970-01-01 can be affected by HHH-13379, but we add some tests just in case
.add( 1, 0, 0, 0, ZONE_PARIS )
.add( 2, 0, 0, 0, ZONE_PARIS )
.add( 3, 0, 0, 0, ZONE_PARIS )
.add( 1, 0, 0, 0, ZONE_AUCKLAND )
.add( 2, 0, 0, 0, ZONE_AUCKLAND )
.add( 3, 0, 0, 0, ZONE_AUCKLAND )
.build();
}

View File

@ -53,7 +53,7 @@ public class OffsetDateTimeTest extends AbstractJavaTimeTypeTest<OffsetDateTime,
@Parameterized.Parameters(name = "{1}-{2}-{3}T{4}:{5}:{6}.{7}[{8}] {0}")
public static List<Object[]> data() {
return new ParametersBuilder()
// Not affected by HHH-13266
// Not affected by any known bug
.add( 2017, 11, 6, 19, 19, 1, 0, "+10:00", ZONE_UTC_MINUS_8 )
.add( 2017, 11, 6, 19, 19, 1, 0, "+07:00", ZONE_UTC_MINUS_8 )
.add( 2017, 11, 6, 19, 19, 1, 0, "+01:30", ZONE_UTC_MINUS_8 )
@ -75,6 +75,7 @@ public class OffsetDateTimeTest extends AbstractJavaTimeTypeTest<OffsetDateTime,
// MySQL/Mariadb cannot store values equal to epoch exactly, or less, in a timestamp.
Arrays.asList( MySQLDialect.class, MariaDBDialect.class ),
b -> b
// Not affected by any known bug
.add( 1970, 1, 1, 0, 0, 0, 0, "+01:00", ZONE_GMT )
.add( 1970, 1, 1, 0, 0, 0, 0, "+00:00", ZONE_GMT )
.add( 1970, 1, 1, 0, 0, 0, 0, "-01:00", ZONE_GMT )
@ -85,13 +86,34 @@ public class OffsetDateTimeTest extends AbstractJavaTimeTypeTest<OffsetDateTime,
.add( 1900, 1, 1, 0, 9, 21, 0, "+00:09:21", ZONE_PARIS )
.add( 1900, 1, 1, 0, 19, 32, 0, "+00:19:32", ZONE_PARIS )
.add( 1900, 1, 1, 0, 19, 32, 0, "+00:19:32", ZONE_AMSTERDAM )
// Affected by HHH-13266
// Affected by HHH-13266 (JDK-8061577)
.add( 1892, 1, 1, 0, 0, 0, 0, "+00:00", ZONE_OSLO )
.add( 1900, 1, 1, 0, 9, 20, 0, "+00:09:21", ZONE_PARIS )
.add( 1900, 1, 1, 0, 19, 31, 0, "+00:19:32", ZONE_PARIS )
.add( 1900, 1, 1, 0, 19, 31, 0, "+00:19:32", ZONE_AMSTERDAM )
.add( 1600, 1, 1, 0, 0, 0, 0, "+00:19:32", ZONE_AMSTERDAM )
)
// HHH-13379: DST end (where Timestamp becomes ambiguous, see JDK-4312621)
// => This used to work correctly in 5.4.1.Final and earlier
.add( 2018, 10, 28, 2, 0, 0, 0, "+01:00", ZONE_PARIS )
.add( 2018, 4, 1, 2, 0, 0, 0, "+12:00", ZONE_AUCKLAND )
// => This has never worked correctly, unless the JDBC timezone was set to UTC
.withForcedJdbcTimezone( "UTC", b -> b
.add( 2018, 10, 28, 2, 0, 0, 0, "+02:00", ZONE_PARIS )
.add( 2018, 4, 1, 2, 0, 0, 0, "+13:00", ZONE_AUCKLAND )
)
// => Also test DST start, just in case
.add( 2018, 3, 25, 2, 0, 0, 0, "+01:00", ZONE_PARIS )
.add( 2018, 3, 25, 3, 0, 0, 0, "+02:00", ZONE_PARIS )
.add( 2018, 9, 30, 2, 0, 0, 0, "+12:00", ZONE_AUCKLAND )
.add( 2018, 9, 30, 3, 0, 0, 0, "+13:00", ZONE_AUCKLAND )
// => Also test dates around 1905-01-01, because the code behaves differently before and after 1905
.add( 1904, 12, 31, 23, 59, 59, 999_999_999, "-01:00", ZONE_PARIS )
.add( 1904, 12, 31, 23, 59, 59, 999_999_999, "+00:00", ZONE_PARIS )
.add( 1904, 12, 31, 23, 59, 59, 999_999_999, "+01:00", ZONE_PARIS )
.add( 1905, 1, 1, 0, 0, 0, 0, "-01:00", ZONE_PARIS )
.add( 1905, 1, 1, 0, 0, 0, 0, "+00:00", ZONE_PARIS )
.add( 1905, 1, 1, 0, 0, 0, 0, "+01:00", ZONE_PARIS )
.build();
}

View File

@ -90,6 +90,32 @@ public class OffsetTimeTest extends AbstractJavaTimeTypeTest<OffsetTime, OffsetT
.addPersistedWithoutHibernate( 1900, 1, 1, 0, 19, 31, 0, "+00:19:32", ZONE_AMSTERDAM )
.addPersistedWithoutHibernate( 1600, 1, 1, 0, 0, 0, 0, "+00:19:32", ZONE_AMSTERDAM )
)
// HHH-13379: DST end (where Timestamp becomes ambiguous, see JDK-4312621)
// It doesn't seem that any time on 1970-01-01 can be affected by HHH-13379, but we add some tests just in case
.add( 1, 0, 0, 0, "-01:00", ZONE_PARIS )
.add( 1, 0, 0, 0, "+00:00", ZONE_PARIS )
.add( 1, 0, 0, 0, "+01:00", ZONE_PARIS )
.add( 1, 0, 0, 0, "+02:00", ZONE_PARIS )
.add( 2, 0, 0, 0, "-01:00", ZONE_PARIS )
.add( 2, 0, 0, 0, "+00:00", ZONE_PARIS )
.add( 2, 0, 0, 0, "+01:00", ZONE_PARIS )
.add( 2, 0, 0, 0, "+02:00", ZONE_PARIS )
.add( 3, 0, 0, 0, "-01:00", ZONE_PARIS )
.add( 3, 0, 0, 0, "+00:00", ZONE_PARIS )
.add( 3, 0, 0, 0, "+01:00", ZONE_PARIS )
.add( 3, 0, 0, 0, "+02:00", ZONE_PARIS )
.add( 1, 0, 0, 0, "-01:00", ZONE_AUCKLAND )
.add( 1, 0, 0, 0, "+00:00", ZONE_AUCKLAND )
.add( 1, 0, 0, 0, "+01:00", ZONE_AUCKLAND )
.add( 1, 0, 0, 0, "+02:00", ZONE_AUCKLAND )
.add( 2, 0, 0, 0, "-01:00", ZONE_AUCKLAND )
.add( 2, 0, 0, 0, "+00:00", ZONE_AUCKLAND )
.add( 2, 0, 0, 0, "+01:00", ZONE_AUCKLAND )
.add( 2, 0, 0, 0, "+02:00", ZONE_AUCKLAND )
.add( 3, 0, 0, 0, "-01:00", ZONE_AUCKLAND )
.add( 3, 0, 0, 0, "+00:00", ZONE_AUCKLAND )
.add( 3, 0, 0, 0, "+01:00", ZONE_AUCKLAND )
.add( 3, 0, 0, 0, "+02:00", ZONE_AUCKLAND )
.build();
}

View File

@ -53,7 +53,7 @@ public class ZonedDateTimeTest extends AbstractJavaTimeTypeTest<ZonedDateTime, Z
@Parameterized.Parameters(name = "{1}-{2}-{3}T{4}:{5}:{6}.{7}[{8}] {0}")
public static List<Object[]> data() {
return new ParametersBuilder()
// Not affected by HHH-13266
// Not affected by any known bug
.add( 2017, 11, 6, 19, 19, 1, 0, "GMT+10:00", ZONE_UTC_MINUS_8 )
.add( 2017, 11, 6, 19, 19, 1, 0, "GMT+07:00", ZONE_UTC_MINUS_8 )
.add( 2017, 11, 6, 19, 19, 1, 0, "GMT+01:30", ZONE_UTC_MINUS_8 )
@ -79,6 +79,7 @@ public class ZonedDateTimeTest extends AbstractJavaTimeTypeTest<ZonedDateTime, Z
// MySQL/Mariadb cannot store values equal to epoch exactly, or less, in a timestamp.
Arrays.asList( MySQLDialect.class, MariaDBDialect.class ),
b -> b
// Not affected by any known bug
.add( 1970, 1, 1, 0, 0, 0, 0, "GMT+01:00", ZONE_GMT )
.add( 1970, 1, 1, 0, 0, 0, 0, "GMT+00:00", ZONE_GMT )
.add( 1970, 1, 1, 0, 0, 0, 0, "GMT-01:00", ZONE_GMT )
@ -93,7 +94,7 @@ public class ZonedDateTimeTest extends AbstractJavaTimeTypeTest<ZonedDateTime, Z
.add( 1900, 1, 1, 0, 19, 32, 0, "Europe/Amsterdam", ZONE_PARIS )
.add( 1900, 1, 1, 0, 19, 32, 0, "GMT+00:19:32", ZONE_AMSTERDAM )
.add( 1900, 1, 1, 0, 19, 32, 0, "Europe/Amsterdam", ZONE_AMSTERDAM )
// Affected by HHH-13266
// Affected by HHH-13266 (JDK-8061577)
.add( 1892, 1, 1, 0, 0, 0, 0, "GMT+00:00", ZONE_OSLO )
.add( 1892, 1, 1, 0, 0, 0, 0, "Europe/Oslo", ZONE_OSLO )
.add( 1900, 1, 1, 0, 9, 20, 0, "GMT+00:09:21", ZONE_PARIS )
@ -104,6 +105,27 @@ public class ZonedDateTimeTest extends AbstractJavaTimeTypeTest<ZonedDateTime, Z
.add( 1600, 1, 1, 0, 0, 0, 0, "GMT+00:19:32", ZONE_AMSTERDAM )
.add( 1600, 1, 1, 0, 0, 0, 0, "Europe/Amsterdam", ZONE_AMSTERDAM )
)
// HHH-13379: DST end (where Timestamp becomes ambiguous, see JDK-4312621)
// => This used to work correctly in 5.4.1.Final and earlier
.add( 2018, 10, 28, 2, 0, 0, 0, "+01:00", ZONE_PARIS )
.add( 2018, 4, 1, 2, 0, 0, 0, "+12:00", ZONE_AUCKLAND )
// => This has never worked correctly, unless the JDBC timezone was set to UTC
.withForcedJdbcTimezone( "UTC", b -> b
.add( 2018, 10, 28, 2, 0, 0, 0, "+02:00", ZONE_PARIS )
.add( 2018, 4, 1, 2, 0, 0, 0, "+13:00", ZONE_AUCKLAND )
)
// => Also test DST start, just in case
.add( 2018, 3, 25, 2, 0, 0, 0, "+01:00", ZONE_PARIS )
.add( 2018, 3, 25, 3, 0, 0, 0, "+02:00", ZONE_PARIS )
.add( 2018, 9, 30, 2, 0, 0, 0, "+12:00", ZONE_AUCKLAND )
.add( 2018, 9, 30, 3, 0, 0, 0, "+13:00", ZONE_AUCKLAND )
// => Also test dates around 1905-01-01, because the code behaves differently before and after 1905
.add( 1904, 12, 31, 23, 59, 59, 999_999_999, "-01:00", ZONE_PARIS )
.add( 1904, 12, 31, 23, 59, 59, 999_999_999, "+00:00", ZONE_PARIS )
.add( 1904, 12, 31, 23, 59, 59, 999_999_999, "+01:00", ZONE_PARIS )
.add( 1905, 1, 1, 0, 0, 0, 0, "-01:00", ZONE_PARIS )
.add( 1905, 1, 1, 0, 0, 0, 0, "+00:00", ZONE_PARIS )
.add( 1905, 1, 1, 0, 0, 0, 0, "+01:00", ZONE_PARIS )
.build();
}