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

Commit

Permalink
Add auto type support to remove dependency among tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rRajivramachandran committed Nov 13, 2023
1 parent c942c83 commit 3d0c458
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/test/java/com/alibaba/fastjson/serializer/TestParse.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.ParserConfig;
import org.junit.Before;
import org.junit.Test;

Expand All @@ -15,7 +16,7 @@ public class TestParse {
private final Logger logger = Logger.getLogger(TestParse.class.getSimpleName());

private String jsonString;

@Before
public void prepareJsonString() {
TestBean bean = new TestBean();
Expand All @@ -28,9 +29,11 @@ public void prepareJsonString() {

@Test
public void testParse() {
logger.info("parsing json string:" + jsonString);
TestBean testBean = (TestBean) JSON.parse(jsonString);
assert testBean.getData() != null;
logger.info("parsing json string:" + jsonString);
final ParserConfig parserConfig = new ParserConfig();
parserConfig.setAutoTypeSupport(true);
TestBean testBean = (TestBean) JSON.parse(jsonString, parserConfig);
assert testBean.getData() != null;
assert "tester".equals(testBean.getName());
assert "value".equals(testBean.getData().getString("key"));
}
Expand Down

0 comments on commit 3d0c458

Please sign in to comment.