From 5c9f31f688e480d63daab8f99205a05ff4f91e8b Mon Sep 17 00:00:00 2001 From: Alex Clayton Date: Thu, 10 Mar 2016 11:26:36 +0000 Subject: Add test for pre epoch dates in DateTimeTest. As per patch 'Stop throwing out of range exception from dateTimeToLocalStrin' (eed183fbd5d121049d5965d7c60abd65f44d0376). In swiften when DateTime.dateToLocalString was passed a pre 1970 date it could throw an out of range exception. Swiften code was fixed to return an empty string in this case. In java we do not see this error so no need to modify DateTime code. Instead I just added a test to verify we can cope with pre 1970 dates. Test-information: Unit tests pass. Change-Id: Ie1db328818d1457a17e68ab891f564d169912320 diff --git a/test/com/isode/stroke/base/DateTimeTest.java b/test/com/isode/stroke/base/DateTimeTest.java index e6fc787..9616a5f 100644 --- a/test/com/isode/stroke/base/DateTimeTest.java +++ b/test/com/isode/stroke/base/DateTimeTest.java @@ -19,11 +19,6 @@ import java.util.TimeZone; import org.junit.Before; import org.junit.Test; -/** - * @author ac - * @since 16.5 - * - */ public class DateTimeTest { private final SimpleDateFormat isoFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); @@ -53,4 +48,12 @@ public class DateTimeTest { assertEquals("1969-07-21T02:56:15Z", DateTime.dateToString(time)); } + @Test + public void testDatePreEpochToString() { + // In Swiften this returns empty string due to pre 1970 dates sometimes + // throwing an error. This is not a problem in java. + Date time = DateTime.stringToDate("1954-07-20T21:56:15-05:00"); + assertEquals("1954-07-21T02:56:15Z", DateTime.dateToString(time)); + } + } -- cgit v0.10.2-6-g49f6