summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAlex Clayton <alex.clayton@isode.com>2016-03-10 11:26:36 (GMT)
committerAlex Clayton <alex.clayton@isode.com>2016-03-14 13:53:10 (GMT)
commit5c9f31f688e480d63daab8f99205a05ff4f91e8b (patch)
tree85905767c45dc95e0dd268c8c74b0a8ebdabee9c /test
parentdcc9d6b81d73f42db35c6e26a91e029a117289e1 (diff)
downloadstroke-5c9f31f688e480d63daab8f99205a05ff4f91e8b.zip
stroke-5c9f31f688e480d63daab8f99205a05ff4f91e8b.tar.bz2
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
Diffstat (limited to 'test')
-rw-r--r--test/com/isode/stroke/base/DateTimeTest.java13
1 files changed, 8 insertions, 5 deletions
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));
+ }
+
}