From: Kai Moritz Date: Fri, 15 Apr 2022 10:17:23 +0000 (+0200) Subject: Tests: Fehlerfall-Test prüft, dass nicht alle Nachrichten gelesen wurden X-Git-Tag: wip-DEPRECATED~11^2^2~8 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=438f39fa648862a423ba29b950ba58f3043075c3;p=demos%2Fkafka%2Ftraining Tests: Fehlerfall-Test prüft, dass nicht alle Nachrichten gelesen wurden --- 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