From 480dc80416842e9300842a8456b9b46b00c90a9b Mon Sep 17 00:00:00 2001 From: Augustine Cui <37201272+Augustine-C@users.noreply.github.com> Date: Sun, 14 Nov 2021 22:19:35 -0600 Subject: [PATCH] Fixed flaky tests in `feign.json.JsonEncoderTest` (#1538) fixed format --- json/pom.xml | 6 ++++++ json/src/test/java/feign/json/JsonEncoderTest.java | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/json/pom.xml b/json/pom.xml index 469437d724..691363545a 100644 --- a/json/pom.xml +++ b/json/pom.xml @@ -51,6 +51,12 @@ ${mockito.version} test + + org.skyscreamer + jsonassert + 1.5.0 + test + ${project.groupId} feign-mock diff --git a/json/src/test/java/feign/json/JsonEncoderTest.java b/json/src/test/java/feign/json/JsonEncoderTest.java index 0d08fbd56c..874c60f142 100644 --- a/json/src/test/java/feign/json/JsonEncoderTest.java +++ b/json/src/test/java/feign/json/JsonEncoderTest.java @@ -19,6 +19,7 @@ import org.json.JSONObject; import org.junit.Before; import org.junit.Test; +import org.skyscreamer.jsonassert.JSONAssert; import java.util.Date; import static feign.Util.UTF_8; import static org.junit.Assert.*; @@ -43,13 +44,15 @@ public void setUp() { @Test public void encodesArray() { new JsonEncoder().encode(jsonArray, JSONArray.class, requestTemplate); - assertEquals("[{\"a\":\"b\",\"c\":1},123]", new String(requestTemplate.body(), UTF_8)); + JSONAssert.assertEquals("[{\"a\":\"b\",\"c\":1},123]", + new String(requestTemplate.body(), UTF_8), false); } @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); } @Test