Hi, there! โ๏ธ
I'm Elias* and this is my GitHub profile. (bit messy, don't look too closely ๐)
A general JSON-RPC 2.0 Wrapper for Java
Home Page: https://eliasstar.github.io/JsonRpc4J/
License: GNU Lesser General Public License v3.0
Hi, there! โ๏ธ
I'm Elias* and this is my GitHub profile. (bit messy, don't look too closely ๐)
Describe the bug
The following tests fail due to an assertCheck between two JSON Strings.
The primary issue in these functions was the reliance on the specific ordering of keys in the serialized JSON strings for comparisons in the test assertions. In JSON, the order of keys is not guaranteed and can vary depending on how the JSON serialization is implemented. This variability led to test failures, even though the JSON strings were structurally equivalent and contained the same data.
Fix:
The fix involved using Gson, a popular JSON processing library in Java, to parse the expected and actual JSON strings into JsonObject instances before comparing them. By doing so, the comparison became order-independent, focusing solely on the structure and content of the JSON data. This approach ensured that the tests were robust against differences in key ordering, thereby accurately validating the correctness of the JSON serialization logic regardless of the order in which the keys appeared in the serialized JSON strings. The fix was applied consistently across all functions, streamlining the test verification process and improving the reliability of the tests.
How to reproduce
Steps to reproduce the behavior:
I used an open-source tool called NonDex to detect the assumption by shuffling the order of returned exception types.
Running the following commands will test the aforementioned operation
Clone the Repo
https://github.com/EliasStar/JsonRpc4J.git
Compile the project
mvn install -am -DskipTests
(Optional) Run the unit test
mvn test
Run the unit test using NonDex
mvn edu.illinois:nondex-maven-plugin:2.1.1:nondex
Stack trace for additional information:
[ERROR] Failures:
[ERROR] OptionalTypeAdapterTests.testOptionalSerialization:50 expected: <{"testString":null,"testOptional":"test"}> but was: <{"testOptional":"test","testString":null}>
[ERROR] ConnectionTests.testNotificationSending:171 Multiple Failures (2 failures)
org.opentest4j.AssertionFailedError: expected: <{"jsonrpc":"2.0","method":"test","params":[]}> but was: <{"params":[],"jsonrpc":"2.0","method":"test"}>
org.opentest4j.AssertionFailedError: expected: <{"jsonrpc":"2.0","method":"test","params":{}}> but was: <{"params":{},"jsonrpc":"2.0","method":"test"}>
[ERROR] NotificationTests.testNotificationSerialization:46 Multiple Failures (2 failures)
org.opentest4j.AssertionFailedError: expected: <{"jsonrpc":"2.0","method":"test"}> but was: <{"method":"test","jsonrpc":"2.0"}>
org.opentest4j.AssertionFailedError: expected: <{"jsonrpc":"2.0","method":"test"}> but was: <{"method":"test","jsonrpc":"2.0"}>
[ERROR] RequestTests.testRequestIdSerialization:56->lambda$testRequestIdSerialization$2:56 Multiple Failures (2 failures)
org.opentest4j.AssertionFailedError: expected: <{"jsonrpc":"2.0","id":"test","method":"test"}> but was: <{"jsonrpc":"2.0","method":"test","id":"test"}>
org.opentest4j.AssertionFailedError: expected: <{"jsonrpc":"2.0","id":"test","method":"test"}> but was: <{"method":"test","id":"test","jsonrpc":"2.0"}>
[ERROR] RequestTests.testRequestParamsSerialization:79 expected: <{"jsonrpc":"2.0","method":"test","params":["test",0,null]}> but was: <{"params":["test",0,null],"method":"test","jsonrpc":"2.0"}>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.