Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed flaky tests in feign.json.JsonEncoderTest #1538

Merged
merged 1 commit into from Nov 15, 2021

Conversation

Augustine-C
Copy link
Contributor

I found some flaky tests in feign.json.JsonEncoderTest that are caused by java JSONObject's usage of HashMap.

Thus, the toString method for the JSONObject does not guarantee a deterministic output.

This means that future changes in Java may change the order of the returned string, and cause tests failures in this file. I used a library JSONAssert from org.skyscreamer to compare JSON strings. It compares the logical structure and data in the JSON object from the JSON string.

}

@Test
public void encodesObject() {
new JsonEncoder().encode(jsonObject, JSONObject.class, requestTemplate);
assertEquals("{\"a\":\"b\",\"c\":1}", new String(requestTemplate.body(), UTF_8));
JSONAssert.assertEquals("{\"a\":\"b\",\"c\":1}", new String(requestTemplate.body(), UTF_8),false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably going to fail due to code format....

build it locally, and maven will fix this for you

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the format issue. I think I've fixed that now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants