From 80a33ab3f5de8cbf06fc2645f8acb4062f15da32 Mon Sep 17 00:00:00 2001 From: yyfMichaelYan <54760415+yyfMichaelYan@users.noreply.github.com> Date: Thu, 25 Nov 2021 18:18:45 -0600 Subject: [PATCH] Flaky test fields iteration order (#4095) * Fix flaky test testAssembleLongPollRefreshUrlWithMultipleNamespaces. * Fix flaky test testAssembleLongPollRefreshUrl. * Update assertions in testAssembleLongPollRefreshUrl and testAssembleLongPollRefreshUrlWithMultipleNamespaces. Co-authored-by: Jason Song --- .../RemoteConfigLongPollServiceTest.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java b/apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java index 20ebc3139bd..6dfab334a4b 100644 --- a/apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java +++ b/apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java @@ -508,9 +508,10 @@ public void testAssembleLongPollRefreshUrl() throws Exception { assertTrue(longPollRefreshUrl.contains(someServerUrl + "/notifications/v2?")); assertTrue(longPollRefreshUrl.contains("appId=" + someAppId)); assertTrue(longPollRefreshUrl.contains("cluster=someCluster%2B+%26.-_someSign")); - assertTrue(longPollRefreshUrl.contains( - "notifications=%5B%7B%22namespaceName%22%3A%22" + someNamespace - + "%22%2C%22notificationId%22%3A" + 1 + "%7D%5D")); + assertTrue(longPollRefreshUrl.contains("notifications=%5B%7B") + && longPollRefreshUrl.contains("%22namespaceName%22%3A%22" + someNamespace + "%22") + && longPollRefreshUrl.contains("%22notificationId%22%3A" + someNotificationId) + && longPollRefreshUrl.contains("%7D%5D")); } @Test @@ -532,11 +533,12 @@ public void testAssembleLongPollRefreshUrlWithMultipleNamespaces() throws Except assertTrue(longPollRefreshUrl.contains(someServerUrl + "/notifications/v2?")); assertTrue(longPollRefreshUrl.contains("appId=" + someAppId)); assertTrue(longPollRefreshUrl.contains("cluster=someCluster%2B+%26.-_someSign")); - assertTrue( - longPollRefreshUrl.contains("notifications=%5B%7B%22namespaceName%22%3A%22" + someNamespace - + "%22%2C%22notificationId%22%3A" + someNotificationId - + "%7D%2C%7B%22namespaceName%22%3A%22" + anotherNamespace - + "%22%2C%22notificationId%22%3A" + anotherNotificationId + "%7D%5D")); + assertTrue(longPollRefreshUrl.contains("notifications=%5B%7B") + && longPollRefreshUrl.contains("%22namespaceName%22%3A%22" + someNamespace + "%22") + && longPollRefreshUrl.contains("%22notificationId%22%3A" + someNotificationId) + && longPollRefreshUrl.contains("%22namespaceName%22%3A%22" + anotherNamespace + "%22") + && longPollRefreshUrl.contains("%22notificationId%22%3A" + anotherNotificationId) + && longPollRefreshUrl.contains("%7D%5D")); } public static class MockConfigUtil extends ConfigUtil {