Skip to content

Commit

Permalink
complete test case for #1492
Browse files Browse the repository at this point in the history
  • Loading branch information
kimmking committed Oct 4, 2017
1 parent c3261b8 commit 340a5a6
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/test/java/com/alibaba/json/bvt/issue_1400/Issue1492.java
@@ -1,6 +1,7 @@
package com.alibaba.json.bvt.issue_1400;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import junit.framework.TestCase;

Expand All @@ -9,11 +10,29 @@
public class Issue1492 extends TestCase {
public void test_for_issue() throws Exception {
DubboResponse resp = new DubboResponse();
resp.setData(new JSONObject());

// test for JSONObject
JSONObject obj = new JSONObject();
obj.put("key1","value1");
obj.put("key2","value2");
resp.setData(obj);

String str = JSON.toJSONString(resp);
System.out.println(str);
DubboResponse resp1 = JSON.parseObject(str, DubboResponse.class);
assertEquals(str, JSON.toJSONString(resp1));

// test for JSONArray
JSONArray arr = new JSONArray();
arr.add("key1");
arr.add("key2");
resp.setData(arr);

String str2 = JSON.toJSONString(resp);
System.out.println(str2);
DubboResponse resp2 = JSON.parseObject(str2, DubboResponse.class);
assertEquals(str2, JSON.toJSONString(resp2));

}

public static final class DubboResponse implements Serializable {
Expand Down

0 comments on commit 340a5a6

Please sign in to comment.