fix all test

This commit is contained in:
Looly 2024-09-24 12:54:03 +08:00
parent 68a6994858
commit 10671aa580
3 changed files with 9 additions and 14 deletions

View File

@ -17,7 +17,6 @@
package org.dromara.hutool.json;
import lombok.ToString;
import org.dromara.hutool.core.lang.Console;
import org.dromara.hutool.json.serializer.JSONDeserializer;
import org.dromara.hutool.json.serializer.JSONSerializer;
import org.dromara.hutool.json.serializer.TypeAdapterManager;
@ -44,7 +43,6 @@ public class CustomSerializeTest {
customBean.name = "testName";
final JSONObject obj = JSONUtil.parseObj(customBean);
Console.log(obj);
Assertions.assertEquals("testName", obj.getStr("customName"));
}

View File

@ -19,7 +19,6 @@ package org.dromara.hutool.json;
import lombok.Data;
import org.dromara.hutool.core.collection.ListUtil;
import org.dromara.hutool.core.io.file.FileUtil;
import org.dromara.hutool.core.lang.Console;
import org.dromara.hutool.core.map.Dict;
import org.dromara.hutool.core.reflect.TypeReference;
import org.dromara.hutool.core.util.CharsetUtil;
@ -200,8 +199,7 @@ public class JSONArrayTest {
Assertions.assertThrows(JSONException.class, ()->{
final String json = "[['aaa',{'akey':'avalue','bkey':'bvalue'}]]";
final JSONArray ja = JSONUtil.parseArray(json);
final Object bean = ja.toBean(new TypeReference<List<List<KeyBean>>>() {});
Console.log(bean);
ja.toBean(new TypeReference<List<List<KeyBean>>>() {});
});
}

View File

@ -16,11 +16,7 @@
package org.dromara.hutool.json.reader;
import org.dromara.hutool.core.lang.Console;
import org.dromara.hutool.json.JSON;
import org.dromara.hutool.json.JSONArray;
import org.dromara.hutool.json.JSONConfig;
import org.dromara.hutool.json.JSONObject;
import org.dromara.hutool.json.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@ -34,18 +30,21 @@ public class JSONParserTest {
}
@Test
void nextToTest() {
void parseToTest() {
final String jsonStr = "{\"a\": 1}";
JSONParser.of(new JSONTokener(jsonStr), JSONConfig.of()).parseTo(new JSONObject());
final JSONObject jsonObject = JSONUtil.ofObj();
JSONParser.of(new JSONTokener(jsonStr), JSONConfig.of()).parseTo(jsonObject);
Assertions.assertEquals("{\"a\":1}", jsonObject.toString());
}
@Test
void parseArrayTest() {
void parseToArrayTest() {
final String jsonStr = "[{},2,3]";
final JSONParser jsonParser = JSONParser.of(new JSONTokener(jsonStr), JSONConfig.of());
final JSONArray jsonArray = new JSONArray();
jsonParser.parseTo(jsonArray);
Console.log(jsonArray);
Assertions.assertEquals(jsonStr, jsonArray.toString());
}
}