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 1c83b62cc4..48f058593d 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 @@ -243,6 +243,8 @@ abstract class AbstractJavaTimeTypeTest extends BaseCoreFunctionalTestCase private final List> remappingDialectClasses = new ArrayList<>(); + private ZoneId forcedJdbcTimeZone = null; + protected AbstractParametersBuilder() { dialect = determineDialect(); remappingDialectClasses.add( null ); // Always test without remapping @@ -261,6 +263,18 @@ abstract class AbstractJavaTimeTypeTest extends BaseCoreFunctionalTestCase return thisAsS(); } + public S withForcedJdbcTimezone(String zoneIdString, Consumer contributor) { + ZoneId zoneId = ZoneId.of( zoneIdString ); + this.forcedJdbcTimeZone = zoneId; + try { + contributor.accept( thisAsS() ); + } + finally { + this.forcedJdbcTimeZone = null; + } + return thisAsS(); + } + @SafeVarargs public final S alsoTestRemappingsWithH2(Class ... dialectClasses) { if ( dialect instanceof H2Dialect ) { @@ -281,24 +295,26 @@ abstract class AbstractJavaTimeTypeTest extends BaseCoreFunctionalTestCase parameters.add( new EnvironmentParameters( defaultJvmTimeZone, - null, + forcedJdbcTimeZone, remappingDialectClass ) ); Collections.addAll( parameters, subClassParameters ); result.add( parameters.toArray() ); } - for ( ZoneId hibernateJdbcTimeZone : getHibernateJdbcTimeZonesToTest() ) { - List parameters = new ArrayList<>(); - parameters.add( - new EnvironmentParameters( - defaultJvmTimeZone, - hibernateJdbcTimeZone, - null - ) - ); - Collections.addAll( parameters, subClassParameters ); - result.add( parameters.toArray() ); + if ( forcedJdbcTimeZone == null ) { + for ( ZoneId hibernateJdbcTimeZone : getHibernateJdbcTimeZonesToTest() ) { + List parameters = new ArrayList<>(); + parameters.add( + new EnvironmentParameters( + defaultJvmTimeZone, + hibernateJdbcTimeZone, + null + ) + ); + Collections.addAll( parameters, subClassParameters ); + result.add( parameters.toArray() ); + } } return thisAsS(); }