From e2b3dca1b3aadcdd2e93b741c83c3d8a76e2dfc4 Mon Sep 17 00:00:00 2001 From: Augustine Cui Date: Sun, 14 Nov 2021 19:26:48 -0800 Subject: [PATCH] Fixed flaky tests in `feign.json.JsonEncoderTest` 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 469437d72..691363545 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 0d08fbd56..874c60f14 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