aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test/java/com/juick/tests/JsonTests.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/java/com/juick/tests/JsonTests.java b/src/test/java/com/juick/tests/JsonTests.java
index ab0d6283..8378d7f1 100644
--- a/src/test/java/com/juick/tests/JsonTests.java
+++ b/src/test/java/com/juick/tests/JsonTests.java
@@ -3,6 +3,7 @@ package com.juick.tests;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.juick.Message;
+import com.juick.Tag;
import com.juick.User;
import com.juick.json.MessageSerializer;
import com.juick.json.UserSerializer;
@@ -12,6 +13,7 @@ import org.junit.Test;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.TimeZone;
import static org.junit.Assert.assertEquals;
@@ -48,5 +50,19 @@ public class JsonTests {
String jacksonString = mapper.writeValueAsString(user);
JSONObject jacksonJson = new JSONObject(jacksonString);
assertEquals("jackson should serialize as ugnich", handmadeJson.length(), jacksonJson.length());
+ Message msg = new Message();
+ msg.setMID(1);
+ msg.setUser(user);
+ msg.setText("yo");
+ msg.setDate(new Date());
+ msg.Tags.add(new Tag("test"));
+ msg.Tags.add(new Tag("json"));
+ MessageSerializer messageSerializer = new MessageSerializer();
+ JSONObject handmadeJsonMessage = messageSerializer.serialize(msg);
+ Message jacksonMessage = mapper.readValue(handmadeJsonMessage.toString(), Message.class);
+ assertEquals("jackson should deserialize ugnich json", msg, jacksonMessage);
+ String jacksonStringMessage = mapper.writeValueAsString(jacksonMessage);
+ JSONObject jacksonJsonMessage = new JSONObject(jacksonStringMessage);
+ assertEquals("jackson should serialize as ugnich", handmadeJsonMessage.length(), jacksonJsonMessage.length());
}
} \ No newline at end of file