HHH-13379 Enhance date/time tests to allow testing certain values only when forcing the JDBC timezone
This commit is contained in:
parent
65fa9cb1e7
commit
de8e965cc8
|
@ -243,6 +243,8 @@ abstract class AbstractJavaTimeTypeTest<T, E> extends BaseCoreFunctionalTestCase
|
|||
|
||||
private final List<Class<? extends AbstractRemappingH2Dialect>> 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<T, E> extends BaseCoreFunctionalTestCase
|
|||
return thisAsS();
|
||||
}
|
||||
|
||||
public S withForcedJdbcTimezone(String zoneIdString, Consumer<S> 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<? extends AbstractRemappingH2Dialect> ... dialectClasses) {
|
||||
if ( dialect instanceof H2Dialect ) {
|
||||
|
@ -281,24 +295,26 @@ abstract class AbstractJavaTimeTypeTest<T, E> extends BaseCoreFunctionalTestCase
|
|||
parameters.add(
|
||||
new EnvironmentParameters(
|
||||
defaultJvmTimeZone,
|
||||
null,
|
||||
forcedJdbcTimeZone,
|
||||
remappingDialectClass
|
||||
)
|
||||
);
|
||||
Collections.addAll( parameters, subClassParameters );
|
||||
result.add( parameters.toArray() );
|
||||
}
|
||||
for ( ZoneId hibernateJdbcTimeZone : getHibernateJdbcTimeZonesToTest() ) {
|
||||
List<Object> 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<Object> parameters = new ArrayList<>();
|
||||
parameters.add(
|
||||
new EnvironmentParameters(
|
||||
defaultJvmTimeZone,
|
||||
hibernateJdbcTimeZone,
|
||||
null
|
||||
)
|
||||
);
|
||||
Collections.addAll( parameters, subClassParameters );
|
||||
result.add( parameters.toArray() );
|
||||
}
|
||||
}
|
||||
return thisAsS();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue