diff --git a/codegen-test/src/test/java/com/alibaba/fastjson2/internal/processor/annotation/MapTest.java b/codegen-test/src/test/java/com/alibaba/fastjson2/internal/processor/annotation/MapTest.java index 1df41aa1c4..7447a3cf75 100644 --- a/codegen-test/src/test/java/com/alibaba/fastjson2/internal/processor/annotation/MapTest.java +++ b/codegen-test/src/test/java/com/alibaba/fastjson2/internal/processor/annotation/MapTest.java @@ -1,11 +1,12 @@ package com.alibaba.fastjson2.internal.processor.annotation; import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.annotation.JSONCompiled; import org.junit.jupiter.api.Test; -import java.util.HashMap; import java.util.Map; +import java.util.TreeMap; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -13,7 +14,7 @@ public class MapTest { @Test public void test() { Bean bean = new Bean(); - bean.values = new HashMap<>(); + bean.values = new TreeMap<>(); bean.values.put("a", "101"); bean.values.put("b", "201"); @@ -21,7 +22,9 @@ public void test() { Bean bean1 = JSON.parseObject(str, Bean.class); assertEquals(bean.values.size(), bean1.values.size()); String str1 = JSON.toJSONString(bean1); - assertEquals(str, str1); + JSONObject json1 = JSON.parseObject(str); + JSONObject json2 = JSON.parseObject(str1); + assertEquals(json1, json2); } @JSONCompiled @@ -32,7 +35,7 @@ public static class Bean{ @Test public void test1() { Bean1 bean = new Bean1(); - bean.values = new HashMap<>(); + bean.values = new TreeMap<>(); bean.values.put("a", "101"); bean.values.put("b", "201"); @@ -40,7 +43,9 @@ public void test1() { Bean1 bean1 = JSON.parseObject(str, Bean1.class); assertEquals(bean.values.size(), bean1.values.size()); String str1 = JSON.toJSONString(bean1); - assertEquals(str, str1); + JSONObject json1 = JSON.parseObject(str); + JSONObject json2 = JSON.parseObject(str1); + assertEquals(json1, json2); } @JSONCompiled @@ -51,7 +56,7 @@ public static class Bean1{ @Test public void test2() { Bean2 bean = new Bean2(); - bean.values = new HashMap<>(); + bean.values = new TreeMap<>(); bean.values.put("a", "101"); bean.values.put("b", "201"); @@ -59,7 +64,9 @@ public void test2() { Bean2 bean1 = JSON.parseObject(str, Bean2.class); assertEquals(bean.values.size(), bean1.values.size()); String str1 = JSON.toJSONString(bean1); - assertEquals(str, str1); + JSONObject json1 = JSON.parseObject(str); + JSONObject json2 = JSON.parseObject(str1); + assertEquals(json1, json2); } @JSONCompiled diff --git a/codegen-test/src/test/java/com/alibaba/fastjson2/internal/processor/primitives/DateTypeTest.java b/codegen-test/src/test/java/com/alibaba/fastjson2/internal/processor/primitives/DateTypeTest.java index ae961135a1..742de379b6 100644 --- a/codegen-test/src/test/java/com/alibaba/fastjson2/internal/processor/primitives/DateTypeTest.java +++ b/codegen-test/src/test/java/com/alibaba/fastjson2/internal/processor/primitives/DateTypeTest.java @@ -4,11 +4,14 @@ import com.alibaba.fastjson2.annotation.JSONCompiled; import org.junit.jupiter.api.Test; +import java.util.TimeZone; + import static org.junit.jupiter.api.Assertions.assertEquals; public class DateTypeTest { @Test public void test() { + TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); Bean bean = new Bean(); bean.v01 = new java.util.Date(); bean.v02 = java.util.Calendar.getInstance();