diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/test/java/com/juick/tests/JsonTests.java | 29 | ||||
-rw-r--r-- | src/test/java/com/juick/tests/MessageTests.java | 18 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/test/java/com/juick/tests/JsonTests.java b/src/test/java/com/juick/tests/JsonTests.java new file mode 100644 index 00000000..babcc6c7 --- /dev/null +++ b/src/test/java/com/juick/tests/JsonTests.java @@ -0,0 +1,29 @@ +package com.juick.tests; + +import com.juick.Message; +import com.juick.json.MessageSerializer; +import org.junit.Test; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.TimeZone; + +import static org.junit.Assert.assertEquals; + +public class JsonTests { + @Test + public void DateTest() { + Message msg = new Message(); + SimpleDateFormat df= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + df.setTimeZone(TimeZone.getTimeZone("UTC")); + try { + msg.setDate(df.parse("2015-01-01 05:02:10")); + MessageSerializer serializer = new MessageSerializer(); + String json = serializer.serialize(msg).toString(); + assertEquals("{\"timestamp\":\"2015-01-01 05:02:10\"}", json); + } catch (ParseException e) { + e.printStackTrace(); + } + + } +}
\ No newline at end of file diff --git a/src/test/java/com/juick/tests/MessageTests.java b/src/test/java/com/juick/tests/MessageTests.java new file mode 100644 index 00000000..0392c7b3 --- /dev/null +++ b/src/test/java/com/juick/tests/MessageTests.java @@ -0,0 +1,18 @@ +package com.juick.tests;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import com.juick.Message;
+
+public class MessageTests {
+ @Test
+ public void messageTagsParser() {
+ Message msg = new Message();
+ msg.parseTags("test test" + (char)0xA0 + "2 test3");
+ assertEquals("First tag must be", "test", msg.Tags.get(0));
+ assertEquals("Third tag must be", "test3", msg.Tags.get(2));
+ assertEquals("Count of tags must be", 3, msg.Tags.size());
+ }
+}
\ No newline at end of file |