From 967a7c4a5c7a44c846da32b64d37dc4acdc3e999 Mon Sep 17 00:00:00 2001 From: chickenchickenlove Date: Sat, 12 Oct 2024 10:26:17 +0900 Subject: [PATCH] Fixes flaky test. --- ...pletableFutureRetryTopicScenarioTests.java | 24 +++++++++---------- .../AsyncMonoRetryTopicScenarioTests.java | 24 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/spring-kafka/src/test/java/org/springframework/kafka/retrytopic/AsyncCompletableFutureRetryTopicScenarioTests.java b/spring-kafka/src/test/java/org/springframework/kafka/retrytopic/AsyncCompletableFutureRetryTopicScenarioTests.java index f29b2ccb5c..1dd852e121 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/retrytopic/AsyncCompletableFutureRetryTopicScenarioTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/retrytopic/AsyncCompletableFutureRetryTopicScenarioTests.java @@ -212,10 +212,10 @@ void firstShortFailAndLastLongSuccessRetryTest( assertThat(awaitLatch(latchContainer.dltCountdownLatch1)).isTrue(); assertThat(destinationTopic.getDestinationName()).isEqualTo(expectedRetryTopic); - assertThat(testTopicListener1.receivedMsgs).containsExactly(expectedReceivedMsgs); - assertThat(testTopicListener1.receivedTopics).containsExactly(expectedReceivedTopics); + assertThat(testTopicListener1.receivedMsgs).containsExactlyInAnyOrder(expectedReceivedMsgs); + assertThat(testTopicListener1.receivedTopics).containsExactlyInAnyOrder(expectedReceivedTopics); - assertThat(myCustomDltProcessor1.receivedMsg).containsExactly(expectedDltMsgs); + assertThat(myCustomDltProcessor1.receivedMsg).containsExactlyInAnyOrder(expectedDltMsgs); } @Test @@ -261,10 +261,10 @@ void firstLongSuccessAndLastShortFailed( assertThat(awaitLatch(latchContainer.dltCountdownLatch2)).isTrue(); assertThat(destinationTopic.getDestinationName()).isEqualTo(expectedRetryTopic); - assertThat(zero2TopicListener.receivedMsgs).containsExactly(expectedReceivedMsgs); - assertThat(zero2TopicListener.receivedTopics).containsExactly(expectedReceivedTopics); + assertThat(zero2TopicListener.receivedMsgs).containsExactlyInAnyOrder(expectedReceivedMsgs); + assertThat(zero2TopicListener.receivedTopics).containsExactlyInAnyOrder(expectedReceivedTopics); - assertThat(myCustomDltProcessor2.receivedMsg).containsExactly(expectedDltMsgs); + assertThat(myCustomDltProcessor2.receivedMsg).containsExactlyInAnyOrder(expectedDltMsgs); } @Test @@ -325,10 +325,10 @@ void longFailMsgTwiceThenShortSucessMsgThird( assertThat(awaitLatch(latchContainer.dltCountdownLatch3)).isTrue(); assertThat(destinationTopic.getDestinationName()).isEqualTo(expectedRetryTopic); - assertThat(testTopicListener3.receivedMsgs).containsExactly(expectedReceivedMsgs); - assertThat(testTopicListener3.receivedTopics).containsExactly(expectedReceivedTopics); + assertThat(testTopicListener3.receivedMsgs).containsExactlyInAnyOrder(expectedReceivedMsgs); + assertThat(testTopicListener3.receivedTopics).containsExactlyInAnyOrder(expectedReceivedTopics); - assertThat(myCustomDltProcessor3.receivedMsg).containsExactly(expectedDltMsgs); + assertThat(myCustomDltProcessor3.receivedMsg).containsExactlyInAnyOrder(expectedDltMsgs); } @Test @@ -386,10 +386,10 @@ void longSuccessMsgTwiceThenShortFailMsgTwice( assertThat(awaitLatch(latchContainer.dltCountdownLatch4)).isTrue(); assertThat(destinationTopic.getDestinationName()).isEqualTo(expectedRetryTopic); - assertThat(topicListener4.receivedMsgs).containsExactly(expectedReceivedMsgs); - assertThat(topicListener4.receivedTopics).containsExactly(expectedReceivedTopics); + assertThat(topicListener4.receivedMsgs).containsExactlyInAnyOrder(expectedReceivedMsgs); + assertThat(topicListener4.receivedTopics).containsExactlyInAnyOrder(expectedReceivedTopics); - assertThat(myCustomDltProcessor4.receivedMsg).containsExactly(expectedDltMsgs); + assertThat(myCustomDltProcessor4.receivedMsg).containsExactlyInAnyOrder(expectedDltMsgs); } @Test diff --git a/spring-kafka/src/test/java/org/springframework/kafka/retrytopic/AsyncMonoRetryTopicScenarioTests.java b/spring-kafka/src/test/java/org/springframework/kafka/retrytopic/AsyncMonoRetryTopicScenarioTests.java index cf6bfe66e4..2392abc6d4 100644 --- a/spring-kafka/src/test/java/org/springframework/kafka/retrytopic/AsyncMonoRetryTopicScenarioTests.java +++ b/spring-kafka/src/test/java/org/springframework/kafka/retrytopic/AsyncMonoRetryTopicScenarioTests.java @@ -212,10 +212,10 @@ void firstShortFailAndLastLongSuccessRetryTest( assertThat(awaitLatch(latchContainer.dltCountdownLatch1)).isTrue(); assertThat(destinationTopic.getDestinationName()).isEqualTo(expectedRetryTopic); - assertThat(testTopicListener1.receivedMsgs).containsExactly(expectedReceivedMsgs); - assertThat(testTopicListener1.receivedTopics).containsExactly(expectedReceivedTopics); + assertThat(testTopicListener1.receivedMsgs).containsExactlyInAnyOrder(expectedReceivedMsgs); + assertThat(testTopicListener1.receivedTopics).containsExactlyInAnyOrder(expectedReceivedTopics); - assertThat(myCustomDltProcessor1.receivedMsg).containsExactly(expectedDltMsgs); + assertThat(myCustomDltProcessor1.receivedMsg).containsExactlyInAnyOrder(expectedDltMsgs); } @Test @@ -260,10 +260,10 @@ void firstLongSuccessAndLastShortFailed( assertThat(awaitLatch(latchContainer.dltCountdownLatch2)).isTrue(); assertThat(destinationTopic.getDestinationName()).isEqualTo(expectedRetryTopic); - assertThat(zero2TopicListener.receivedMsgs).containsExactly(expectedReceivedMsgs); - assertThat(zero2TopicListener.receivedTopics).containsExactly(expectedReceivedTopics); + assertThat(zero2TopicListener.receivedMsgs).containsExactlyInAnyOrder(expectedReceivedMsgs); + assertThat(zero2TopicListener.receivedTopics).containsExactlyInAnyOrder(expectedReceivedTopics); - assertThat(myCustomDltProcessor2.receivedMsg).containsExactly(expectedDltMsgs); + assertThat(myCustomDltProcessor2.receivedMsg).containsExactlyInAnyOrder(expectedDltMsgs); } @Test @@ -324,10 +324,10 @@ void longFailMsgTwiceThenShortSuccessMsgThird( assertThat(awaitLatch(latchContainer.dltCountdownLatch3)).isTrue(); assertThat(destinationTopic.getDestinationName()).isEqualTo(expectedRetryTopic); - assertThat(testTopicListener3.receivedMsgs).containsExactly(expectedReceivedMsgs); - assertThat(testTopicListener3.receivedTopics).containsExactly(expectedReceivedTopics); + assertThat(testTopicListener3.receivedMsgs).containsExactlyInAnyOrder(expectedReceivedMsgs); + assertThat(testTopicListener3.receivedTopics).containsExactlyInAnyOrder(expectedReceivedTopics); - assertThat(myCustomDltProcessor3.receivedMsg).containsExactly(expectedDltMsgs); + assertThat(myCustomDltProcessor3.receivedMsg).containsExactlyInAnyOrder(expectedDltMsgs); } @Test @@ -385,10 +385,10 @@ void longSuccessMsgTwiceThenShortFailMsgTwice( assertThat(awaitLatch(latchContainer.dltCountdownLatch4)).isTrue(); assertThat(destinationTopic.getDestinationName()).isEqualTo(expectedRetryTopic); - assertThat(topicListener4.receivedMsgs).containsExactly(expectedReceivedMsgs); - assertThat(topicListener4.receivedTopics).containsExactly(expectedReceivedTopics); + assertThat(topicListener4.receivedMsgs).containsExactlyInAnyOrder(expectedReceivedMsgs); + assertThat(topicListener4.receivedTopics).containsExactlyInAnyOrder(expectedReceivedTopics); - assertThat(myCustomDltProcessor4.receivedMsg).containsExactly(expectedDltMsgs); + assertThat(myCustomDltProcessor4.receivedMsg).containsExactlyInAnyOrder(expectedDltMsgs); } @Test