Giter Club home page Giter Club logo

jsonrpc4j's Introduction

Hi, there! โœŒ๏ธ

I'm Elias* and this is my GitHub profile. (bit messy, don't look too closely ๐Ÿ˜‰)

jsonrpc4j's People

Contributors

dependabot[bot] avatar eliasstar avatar harshith2000 avatar

Watchers

 avatar  avatar

Forkers

harshith2000

jsonrpc4j's Issues

Found non-deterministic tests.

Describe the bug
The following tests fail due to an assertCheck between two JSON Strings.

  1. testOptionalSerialization()
  2. testNotificationSending()
  3. testNotificationSerialization()
  4. testRequestIdSerialization()
  5. testRequestParamsSerialization()

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"}>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.