alibaba / fastjson2

🚄 FASTJSON2 is a Java JSON library with excellent performance.
Apache License 2.0
3.79k stars 495 forks source link

Fix flaky test in issue#3096 #3097

Closed Mukta13 closed 1 month ago

Mukta13 commented 1 month ago

What this PR does / why we need it?

The fix for: https://github.com/alibaba/fastjson2/issues/3096

Summary of your change

This change introduces a helper method, assertMapsEqual(), that reduces test flakiness by serializing two objects to JSON, converting them into maps, and comparing their content. It ensures stable data comparison by avoiding issues with non-deterministic behavior or inconsistent serialization. Error handling is added to manage potential serialization failures.

Can be tested by running:

mvn -pl core edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=com.alibaba.fastjson2.codec.JSONBTableTest3#test_0

mvn -pl core edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=com.alibaba.fastjson2.codec.JSONBTableTest3#test_1

Please indicate you've done the following:

CLAassistant commented 1 month ago

CLA assistant check
All committers have signed the CLA.

Mukta13 commented 1 month ago

Hi. Can this PR be reviewed as well? Thanks!! @wenshao