attempt to fix continuing test flakiness on Sybase

This commit is contained in:
Gavin 2022-12-07 21:38:00 +01:00 committed by Gavin King
parent 86ef33d55b
commit 7dff19795f
5 changed files with 15 additions and 10 deletions

View File

@ -16,6 +16,7 @@ import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -38,8 +39,8 @@ public class AutoZonedTest {
Zoned z = s.find(Zoned.class, id);
if ( scope.getSessionFactory().getJdbcServices().getDialect() instanceof SybaseDialect) {
// Sybase with jTDS driver has 1/300th sec precision
assertEquals( nowZoned.toInstant().toEpochMilli()/30, z.zonedDateTime.toInstant().toEpochMilli()/30 );
assertEquals( nowOffset.toInstant().toEpochMilli()/30, z.offsetDateTime.toInstant().toEpochMilli()/30 );
assertEquals( nowZoned.toInstant().truncatedTo(ChronoUnit.SECONDS), z.zonedDateTime.toInstant().truncatedTo(ChronoUnit.SECONDS) );
assertEquals( nowOffset.toInstant().truncatedTo(ChronoUnit.SECONDS), z.offsetDateTime.toInstant().truncatedTo(ChronoUnit.SECONDS) );
}
else {
assertEquals( nowZoned.toInstant(), z.zonedDateTime.toInstant() );

View File

@ -16,6 +16,7 @@ import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -38,8 +39,8 @@ public class ColumnZonedTest {
Zoned z = s.find(Zoned.class, id);
if ( scope.getSessionFactory().getJdbcServices().getDialect() instanceof SybaseDialect) {
// Sybase with jTDS driver has 1/300th sec precision
assertEquals( nowZoned.toInstant().toEpochMilli()/30, z.zonedDateTime.toInstant().toEpochMilli()/30 );
assertEquals( nowOffset.toInstant().toEpochMilli()/30, z.offsetDateTime.toInstant().toEpochMilli()/30 );
assertEquals( nowZoned.toInstant().truncatedTo(ChronoUnit.SECONDS), z.zonedDateTime.toInstant().truncatedTo(ChronoUnit.SECONDS) );
assertEquals( nowOffset.toInstant().truncatedTo(ChronoUnit.SECONDS), z.offsetDateTime.toInstant().truncatedTo(ChronoUnit.SECONDS) );
}
else {
assertEquals( nowZoned.toInstant(), z.zonedDateTime.toInstant() );

View File

@ -14,6 +14,7 @@ import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -35,8 +36,8 @@ public class DefaultZonedTest {
Zoned z = s.find(Zoned.class, id);
if ( scope.getSessionFactory().getJdbcServices().getDialect() instanceof SybaseDialect) {
// Sybase with jTDS driver has 1/300th sec precision
assertEquals( nowZoned.toInstant().toEpochMilli()/30, z.zonedDateTime.toInstant().toEpochMilli()/30 );
assertEquals( nowOffset.toInstant().toEpochMilli()/30, z.offsetDateTime.toInstant().toEpochMilli()/30 );
assertEquals( nowZoned.toInstant().truncatedTo(ChronoUnit.SECONDS), z.zonedDateTime.toInstant().truncatedTo(ChronoUnit.SECONDS) );
assertEquals( nowOffset.toInstant().truncatedTo(ChronoUnit.SECONDS), z.offsetDateTime.toInstant().truncatedTo(ChronoUnit.SECONDS) );
}
else {
assertEquals( nowZoned.toInstant(), z.zonedDateTime.toInstant() );

View File

@ -16,6 +16,7 @@ import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -38,8 +39,8 @@ public class NormalizedZonedTest {
Zoned z = s.find(Zoned.class, id);
if ( scope.getSessionFactory().getJdbcServices().getDialect() instanceof SybaseDialect) {
// Sybase with jTDS driver has 1/300th sec precision
assertEquals( nowZoned.toInstant().toEpochMilli()/30, z.zonedDateTime.toInstant().toEpochMilli()/30 );
assertEquals( nowOffset.toInstant().toEpochMilli()/30, z.offsetDateTime.toInstant().toEpochMilli()/30 );
assertEquals( nowZoned.toInstant().truncatedTo(ChronoUnit.SECONDS), z.zonedDateTime.toInstant().truncatedTo(ChronoUnit.SECONDS) );
assertEquals( nowOffset.toInstant().truncatedTo(ChronoUnit.SECONDS), z.offsetDateTime.toInstant().truncatedTo(ChronoUnit.SECONDS) );
}
else {
assertEquals( nowZoned.toInstant(), z.zonedDateTime.toInstant() );

View File

@ -16,6 +16,7 @@ import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -38,8 +39,8 @@ public class PassThruZonedTest {
Zoned z = s.find(Zoned.class, id);
if ( scope.getSessionFactory().getJdbcServices().getDialect() instanceof SybaseDialect) {
// Sybase with jTDS driver has 1/300th sec precision
assertEquals( nowZoned.toInstant().toEpochMilli()/30, z.zonedDateTime.toInstant().toEpochMilli()/30 );
assertEquals( nowOffset.toInstant().toEpochMilli()/30, z.offsetDateTime.toInstant().toEpochMilli()/30 );
assertEquals( nowZoned.toInstant().truncatedTo(ChronoUnit.SECONDS), z.zonedDateTime.toInstant().truncatedTo(ChronoUnit.SECONDS));
assertEquals( nowOffset.toInstant().truncatedTo(ChronoUnit.SECONDS), z.offsetDateTime.toInstant().truncatedTo(ChronoUnit.SECONDS));
}
else {
assertEquals( nowZoned.toInstant(), z.zonedDateTime.toInstant() );