forked from alibaba/fastjson
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorTest2.java
More file actions
executable file
·27 lines (19 loc) · 839 Bytes
/
Copy pathColorTest2.java
File metadata and controls
executable file
·27 lines (19 loc) · 839 Bytes
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
package com.alibaba.json.bvt;
import java.awt.Color;
import org.junit.Assert;
import junit.framework.TestCase;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.ColorCodec;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.SerializerFeature;
public class ColorTest2 extends TestCase {
public void test_color() throws Exception {
JSONSerializer serializer = new JSONSerializer();
Assert.assertEquals(ColorCodec.class, serializer.getObjectWriter(Color.class).getClass());
Color color = Color.RED;
String text = JSON.toJSONString(color, SerializerFeature.WriteClassName);
System.out.println(text);
Color color2 = (Color) JSON.parse(text);
Assert.assertEquals(color, color2);
}
}