From 438f39fa648862a423ba29b950ba58f3043075c3 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Fri, 15 Apr 2022 12:17:23 +0200 Subject: [PATCH] =?utf8?q?Tests:=20Fehlerfall-Test=20pr=C3=BCft,=20dass=20?= =?utf8?q?nicht=20alle=20Nachrichten=20gelesen=20wurden?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/test/java/de/juplo/kafka/ApplicationTests.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/test/java/de/juplo/kafka/ApplicationTests.java b/src/test/java/de/juplo/kafka/ApplicationTests.java index f541093..61e0a8d 100644 --- a/src/test/java/de/juplo/kafka/ApplicationTests.java +++ b/src/test/java/de/juplo/kafka/ApplicationTests.java @@ -82,6 +82,8 @@ class ApplicationTests Set> received = new HashSet<>(); testHandler = record -> received.add(record); + endlessConsumer.start(); + await("100 records received") .atMost(Duration.ofSeconds(30)) .until(() -> received.size() >= 100); @@ -104,6 +106,11 @@ class ApplicationTests ? new Bytes(stringSerializer.serialize(TOPIC, "BOOM!")) : new Bytes(longSerializer.serialize(TOPIC, counter))); + Set> received = new HashSet<>(); + testHandler = record -> received.add(record); + + endlessConsumer.start(); + await("Consumer failed") .atMost(Duration.ofSeconds(30)) .until(() -> !endlessConsumer.running()); @@ -118,6 +125,9 @@ class ApplicationTests checkSeenOffsetsForProgress(); compareToCommitedOffsets(newOffsets); + assertThat(received.size()) + .describedAs("Received not all sent events") + .isLessThan(100); } @@ -246,8 +256,6 @@ class ApplicationTests properties.getTopic(), kafkaConsumer, captureOffsetAndExecuteTestHandler); - - endlessConsumer.start(); } @AfterEach -- 2.20.1