From 0387090bba264f1c40af62f58e335d50bba7731a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Fri, 26 Jul 2019 08:32:15 +0200 Subject: [PATCH] HHH-13379 Test storage of java.time type representing an instant near the end of DST --- .../test/type/AbstractJavaTimeTypeTest.java | 2 ++ .../org/hibernate/test/type/InstantTest.java | 23 +++++++++++++++- .../hibernate/test/type/LocalDateTest.java | 10 +++++++ .../test/type/LocalDateTimeTest.java | 17 ++++++++++++ .../hibernate/test/type/LocalTimeTest.java | 8 ++++++ .../test/type/OffsetDateTimeTest.java | 26 +++++++++++++++++-- .../hibernate/test/type/OffsetTimeTest.java | 26 +++++++++++++++++++ .../test/type/ZonedDateTimeTest.java | 26 +++++++++++++++++-- 8 files changed, 133 insertions(+), 5 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java index 48f058593d..69384e1675 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java @@ -70,6 +70,8 @@ abstract class AbstractJavaTimeTypeTest 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; diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/InstantTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/InstantTest.java index b88e8782b9..2b960ae667 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/InstantTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/InstantTest.java @@ -45,7 +45,7 @@ public class InstantTest extends AbstractJavaTimeTypeTest 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 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(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTest.java index 8cf5dabc4c..50a00f62c2 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTest.java @@ -65,6 +65,16 @@ public class LocalDateTest extends AbstractJavaTimeTypeTest 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(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTimeTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTimeTest.java index 7224460f4b..d61cd590c4 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTimeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/LocalDateTimeTest.java @@ -61,6 +61,23 @@ public class LocalDateTimeTest extends AbstractJavaTimeTypeTest 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(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/LocalTimeTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/LocalTimeTest.java index a7aa5628be..9c80a3eba1 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/LocalTimeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/LocalTimeTest.java @@ -82,6 +82,14 @@ public class LocalTimeTest extends AbstractJavaTimeTypeTest 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 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 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(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/OffsetTimeTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/OffsetTimeTest.java index 8a4203cbfc..e7a2066f95 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/OffsetTimeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/OffsetTimeTest.java @@ -90,6 +90,32 @@ public class OffsetTimeTest extends AbstractJavaTimeTypeTest 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 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 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(); }