mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-02 11:49:07 +08:00
add test
This commit is contained in:
parent
33ca89ce7d
commit
cc1a7672de
@ -59,6 +59,11 @@
|
||||
<version>2.0.40</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>2.0.32</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt-impl</artifactId>
|
||||
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2023. looly(loolly@aliyun.com)
|
||||
* Hutool is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* https://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
package org.dromara.hutool.json;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class IssueI7VM64Test {
|
||||
|
||||
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
|
||||
@Test
|
||||
void hutoolJSONTest() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("a", "1");
|
||||
|
||||
final JSONObject jsonObject = new JSONObject(map);
|
||||
map.put("b", 2);
|
||||
|
||||
//Console.log("Hutool JSON: " + jsonObject);
|
||||
Assertions.assertEquals("{\"a\":\"1\"}", jsonObject.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
void fastJSONTest() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("a", "1");
|
||||
|
||||
final com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject(map);
|
||||
map.put("b", 2);
|
||||
|
||||
//Console.log("FastJSON: " + jsonObject);
|
||||
Assertions.assertEquals("{\"a\":\"1\",\"b\":2}", jsonObject.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
void fastJSON2Test() {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("a", "1");
|
||||
|
||||
final com.alibaba.fastjson2.JSONObject jsonObject = new com.alibaba.fastjson2.JSONObject(map);
|
||||
map.put("b", 2);
|
||||
|
||||
//Console.log("FastJSON2 " + jsonObject);
|
||||
Assertions.assertEquals("{\"a\":\"1\"}", jsonObject.toString());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user