Skip to content

Commit

Permalink
Remove oracle legacy timestamp test
Browse files Browse the repository at this point in the history
Since commit Fix timestamp semantics (53bafb4) remove legacy timestamp,
testLegacyDateMapping() and testLegacyDateReadMapping() are doing
the same thing as testDateMapping() and testDateReadMapping().
  • Loading branch information
brandboat authored and hashhar committed Jun 9, 2021
1 parent 5cec3fd commit 94cac3c
Showing 1 changed file with 0 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -661,57 +661,6 @@ public void testVarbinary()

/* Datetime tests */

@Test
public void testLegacyDateMapping()
{
legacyDateTests(zone -> trinoCreateAsSelect("l_date_" + zone));
}

@Test
public void testLegacyDateReadMapping()
{
legacyDateTests(zone -> oracleCreateAndInsert("l_read_date_" + zone));
}

private void legacyDateTests(Function<String, DataSetup> dataSetup)
{
Map<String, TimeZoneKey> zonesBySqlName = ImmutableMap.of(
"UTC", UTC_KEY,
"JVM", getTimeZoneKey(ZoneId.systemDefault().getId()),
"other", getTimeZoneKey(ZoneId.of("Europe/Vilnius").getId()));

for (Map.Entry<String, TimeZoneKey> zone : zonesBySqlName.entrySet()) {
runLegacyTimestampTestInZone(
dataSetup.apply(zone.getKey()),
zone.getValue().getId(),
legacyDateTests());
}
}

private static DataTypeTest legacyDateTests()
{
ZoneId someZone = ZoneId.of("Europe/Vilnius");

LocalDate dateOfLocalTimeChangeBackwardAtMidnightInSomeZone =
LocalDate.of(1983, 10, 1);

verify(someZone.getRules().getValidOffsets(
dateOfLocalTimeChangeBackwardAtMidnightInSomeZone
.atStartOfDay().minusMinutes(1)).size() == 2);

return DataTypeTest.create()
// before epoch
.addRoundTrip(dateDataType(), LocalDate.of(1952, 4, 3))
.addRoundTrip(dateDataType(), LocalDate.of(1970, 2, 3))
// summer on northern hemisphere (possible DST)
.addRoundTrip(dateDataType(), LocalDate.of(2017, 7, 1))
// winter on northern hemisphere
// (possible DST on southern hemisphere)
.addRoundTrip(dateDataType(), LocalDate.of(2017, 1, 1))
.addRoundTrip(dateDataType(),
dateOfLocalTimeChangeBackwardAtMidnightInSomeZone);
}

@Test
public void testDateMapping()
{
Expand Down Expand Up @@ -943,20 +892,6 @@ private void runTestsWithSetup(DataSetup dataSetup, DataTypeTest... tests)
}
}

/**
* Run a {@link DataTypeTest} in the given time zone, using legacy timestamps.
* <p>
* If the given time zone is {@code null}, use the default session time zone.
*/
private void runLegacyTimestampTestInZone(DataSetup dataSetup, String zone, DataTypeTest test)
{
Session.SessionBuilder session = Session.builder(getSession());
if (zone != null) {
session.setTimeZoneKey(getTimeZoneKey(zone));
}
test.execute(getQueryRunner(), session.build(), dataSetup);
}

/**
* Run a {@link DataTypeTest} in the given time zone, using non-legacy timestamps.
* <p>
Expand Down

0 comments on commit 94cac3c

Please sign in to comment.