summaryrefslogtreecommitdiffstats
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
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
-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;
19import org.junit.Before; 19import org.junit.Before;
20import org.junit.Test; 20import org.junit.Test;
21 21
22/**
23 * @author ac
24 * @since 16.5
25 *
26 */
27public class DateTimeTest { 22public class DateTimeTest {
28 23
29 private final SimpleDateFormat isoFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); 24 private final SimpleDateFormat isoFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
@@ -53,4 +48,12 @@ public class DateTimeTest {
53 assertEquals("1969-07-21T02:56:15Z", DateTime.dateToString(time)); 48 assertEquals("1969-07-21T02:56:15Z", DateTime.dateToString(time));
54 } 49 }
55 50
51 @Test
52 public void testDatePreEpochToString() {
53 // In Swiften this returns empty string due to pre 1970 dates sometimes
54 // throwing an error. This is not a problem in java.
55 Date time = DateTime.stringToDate("1954-07-20T21:56:15-05:00");
56 assertEquals("1954-07-21T02:56:15Z", DateTime.dateToString(time));
57 }
58
56} 59}