Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit 8640693

Browse files
authored
Merge pull request #3483 from MengdiGao/fix-issue-1780-test
Fix flaky testcases for issue #1780
2 parents 803fd73 + 85fdac6 commit 8640693

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/test/java/com/alibaba/json/bvt/issue_1700/Issue1780_JSONObject.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.alibaba.json.bvt.issue_1700;
22

3+
import com.alibaba.fastjson.serializer.SerializerFeature;
34
import org.junit.Assert;
45
import com.alibaba.fastjson.JSON;
56
import junit.framework.TestCase;
@@ -10,6 +11,7 @@ public void test_for_issue() {
1011
org.json.JSONObject req = new org.json.JSONObject();
1112
req.put("id", 1111);
1213
req.put("name", "name11");
13-
Assert.assertEquals("{\"name\":\"name11\",\"id\":1111}", JSON.toJSONString(req));
14+
String text = JSON.toJSONString(req, SerializerFeature.SortField);
15+
Assert.assertEquals("{\"id\":1111,\"name\":\"name11\"}", text);
1416
}
1517
}

src/test/java/com/alibaba/json/bvt/issue_1700/Issue1780_Module.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.IOException;
44
import java.lang.reflect.Type;
55

6+
import com.alibaba.fastjson.serializer.SerializerFeature;
67
import org.junit.Assert;
78

89
import com.alibaba.fastjson.JSON;
@@ -24,7 +25,8 @@ public void test_for_issue() {
2425
config.register(new myModule());
2526
req.put("id", 1111);
2627
req.put("name", "name11");
27-
Assert.assertEquals("{\"name\":\"name11\",\"id\":1111}", JSON.toJSONString(req, config));
28+
String text = JSON.toJSONString(req, SerializerFeature.SortField);
29+
Assert.assertEquals("{\"id\":1111,\"name\":\"name11\"}", text);
2830
}
2931

3032
public class myModule implements Module {

0 commit comments

Comments
 (0)