aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com/juick/JsonTests.java
blob: 5d78a2d6a6acbcf3d26bce06b4cd02c445e4b302 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.juick;

import static org.junit.Assert.assertEquals;

import com.juick.json.MessageSerializer;
import org.junit.Assert;
import org.junit.Test;

import com.juick.Message;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class JsonTests {
    @Test
    public void DateTest() {
        Message msg = new Message();
        SimpleDateFormat df= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            msg.setDate(df.parse("2015-01-01 00:00:00"));
            MessageSerializer serializer = new MessageSerializer();
            String json = serializer.serialize(msg).toString();
            assertEquals("{\"timestamp\":\"2015-01-01 00:00:00\"}", json);
        } catch (ParseException e) {
            e.printStackTrace();
        }

    }
}