Repository: incubator-rya Updated Branches: refs/heads/master c82021393 -> 544ffddf4 (forced update)
RYA-476 Fixes tests sensitive to DST spring forward. Closes #283 Project: http://git-wip-us.apache.org/repos/asf/incubator-rya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-rya/commit/1675f71a Tree: http://git-wip-us.apache.org/repos/asf/incubator-rya/tree/1675f71a Diff: http://git-wip-us.apache.org/repos/asf/incubator-rya/diff/1675f71a Branch: refs/heads/master Commit: 1675f71a7410874ea0c7ce5924c9632f592c8fd5 Parents: 770bd7e Author: David W. Lotts <[email protected]> Authored: Wed Mar 14 11:48:14 2018 -0400 Committer: David W. Lotts <[email protected]> Committed: Tue Mar 20 13:30:17 2018 -0400 ---------------------------------------------------------------------- .../rya/api/functions/DateTimeWithinPeriodTest.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/1675f71a/common/rya.api/src/test/java/org/apache/rya/api/functions/DateTimeWithinPeriodTest.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/test/java/org/apache/rya/api/functions/DateTimeWithinPeriodTest.java b/common/rya.api/src/test/java/org/apache/rya/api/functions/DateTimeWithinPeriodTest.java index 0fb0f2a..ac27d1b 100644 --- a/common/rya.api/src/test/java/org/apache/rya/api/functions/DateTimeWithinPeriodTest.java +++ b/common/rya.api/src/test/java/org/apache/rya/api/functions/DateTimeWithinPeriodTest.java @@ -38,12 +38,13 @@ public class DateTimeWithinPeriodTest { private static final ValueFactory vf = new ValueFactoryImpl(); private static final Literal TRUE = vf.createLiteral(true); private static final Literal FALSE = vf.createLiteral(false); + private static final ZonedDateTime testThisTimeDate = ZonedDateTime.parse("2018-02-03T14:15:16+07:00"); @Test public void testSeconds() throws DatatypeConfigurationException, ValueExprEvaluationException { DatatypeFactory dtf = DatatypeFactory.newInstance(); - ZonedDateTime zTime = ZonedDateTime.now(); + ZonedDateTime zTime = testThisTimeDate; String time = zTime.format(DateTimeFormatter.ISO_INSTANT); ZonedDateTime zTime1 = zTime.minusSeconds(1); @@ -64,7 +65,7 @@ public class DateTimeWithinPeriodTest { DatatypeFactory dtf = DatatypeFactory.newInstance(); - ZonedDateTime zTime = ZonedDateTime.now(); + ZonedDateTime zTime = testThisTimeDate; String time = zTime.format(DateTimeFormatter.ISO_INSTANT); ZonedDateTime zTime1 = zTime.minusMinutes(1); @@ -85,7 +86,7 @@ public class DateTimeWithinPeriodTest { public void testHours() throws DatatypeConfigurationException, ValueExprEvaluationException { DatatypeFactory dtf = DatatypeFactory.newInstance(); - ZonedDateTime zTime = ZonedDateTime.now(); + ZonedDateTime zTime = testThisTimeDate; String time = zTime.format(DateTimeFormatter.ISO_INSTANT); ZonedDateTime zTime1 = zTime.minusHours(1); @@ -106,7 +107,7 @@ public class DateTimeWithinPeriodTest { public void testDays() throws DatatypeConfigurationException, ValueExprEvaluationException { DatatypeFactory dtf = DatatypeFactory.newInstance(); - ZonedDateTime zTime = ZonedDateTime.now(); + ZonedDateTime zTime = testThisTimeDate; String time = zTime.format(DateTimeFormatter.ISO_INSTANT); ZonedDateTime zTime1 = zTime.minusDays(1); @@ -122,11 +123,12 @@ public class DateTimeWithinPeriodTest { assertEquals(TRUE, func.evaluate(vf, now, nowMinusOne, vf.createLiteral(2), OWLTime.DAYS_URI)); } + // Note that this test fails if the week under test spans a DST when the USA springs forward. @Test public void testWeeks() throws DatatypeConfigurationException, ValueExprEvaluationException { DatatypeFactory dtf = DatatypeFactory.newInstance(); - ZonedDateTime zTime = ZonedDateTime.now(); + ZonedDateTime zTime = testThisTimeDate; String time = zTime.format(DateTimeFormatter.ISO_INSTANT); ZonedDateTime zTime1 = zTime.minusWeeks(1); @@ -151,7 +153,7 @@ public class DateTimeWithinPeriodTest { public void testTimeZone() throws DatatypeConfigurationException, ValueExprEvaluationException { DatatypeFactory dtf = DatatypeFactory.newInstance(); - ZonedDateTime now = ZonedDateTime.now(); + ZonedDateTime now = testThisTimeDate; String time = now.format(DateTimeFormatter.ISO_INSTANT); ZonedDateTime zTime1 = now.withZoneSameInstant(ZoneId.of("Europe/London")); @@ -176,5 +178,4 @@ public class DateTimeWithinPeriodTest { assertEquals(TRUE, func.evaluate(vf, nowLocal, nowAsiaTZMinusOne, vf.createLiteral(2), OWLTime.DAYS_URI)); } - }
