projects
/
demos
/
kafka
/
training
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Springify: ROT - Merge des verschärften Tests aus der Vanilla-Version
[demos/kafka/training]
/
src
/
test
/
java
/
de
/
juplo
/
kafka
/
ApplicationTests.java
diff --git
a/src/test/java/de/juplo/kafka/ApplicationTests.java
b/src/test/java/de/juplo/kafka/ApplicationTests.java
index
35d2b2e
..
3ded0d2
100644
(file)
--- a/
src/test/java/de/juplo/kafka/ApplicationTests.java
+++ b/
src/test/java/de/juplo/kafka/ApplicationTests.java
@@
-73,6
+73,7
@@
class ApplicationTests
Map<TopicPartition, Long> oldOffsets;
Map<TopicPartition, Long> newOffsets;
Map<TopicPartition, Long> oldOffsets;
Map<TopicPartition, Long> newOffsets;
+ Set<ConsumerRecord<String, Long>> receivedRecords;
/** Tests methods */
/** Tests methods */
@@
-83,12
+84,9
@@
class ApplicationTests
{
send100Messages(i -> new Bytes(longSerializer.serialize(TOPIC, i)));
{
send100Messages(i -> new Bytes(longSerializer.serialize(TOPIC, i)));
- Set<ConsumerRecord<String, Long>> received = new HashSet<>();
- recordHandler.testHandler = record -> received.add(record);
-
await("100 records received")
.atMost(Duration.ofSeconds(30))
await("100 records received")
.atMost(Duration.ofSeconds(30))
- .until(() -> received.size() >= 100);
+ .until(() -> received
Records
.size() >= 100);
await("Offsets committed")
.atMost(Duration.ofSeconds(10))
await("Offsets committed")
.atMost(Duration.ofSeconds(10))
@@
-113,6
+111,9
@@
class ApplicationTests
.untilAsserted(() -> checkSeenOffsetsForProgress());
compareToCommitedOffsets(newOffsets);
.untilAsserted(() -> checkSeenOffsetsForProgress());
compareToCommitedOffsets(newOffsets);
+ assertThat(receivedRecords.size())
+ .describedAs("Received not all sent events")
+ .isLessThan(100);
}
}
@@
-124,7
+125,9
@@
class ApplicationTests
{
Long expected = offsetsToCheck.get(tp) + 1;
log.debug("Checking, if the offset for {} is {}", tp, expected);
{
Long expected = offsetsToCheck.get(tp) + 1;
log.debug("Checking, if the offset for {} is {}", tp, expected);
- assertThat(offset).isEqualTo(expected);
+ assertThat(offset)
+ .describedAs("Committed offset corresponds to the offset of the consumer")
+ .isEqualTo(expected);
});
}
});
}
@@
-142,7
+145,9
@@
class ApplicationTests
withProgress.add(tp);
}
});
withProgress.add(tp);
}
});
- assertThat(withProgress).isNotEmpty().describedAs("Found no partitions with any offset-progress");
+ assertThat(withProgress)
+ .describedAs("Some offsets must have changed, compared to the old offset-positions")
+ .isNotEmpty();
}
}
@@
-214,6
+219,7
@@
class ApplicationTests
oldOffsets = new HashMap<>();
newOffsets = new HashMap<>();
oldOffsets = new HashMap<>();
newOffsets = new HashMap<>();
+ receivedRecords = new HashSet<>();
doForCurrentOffsets((tp, offset) ->
{
doForCurrentOffsets((tp, offset) ->
{
@@
-223,9
+229,12
@@
class ApplicationTests
recordHandler.captureOffsets =
record ->
recordHandler.captureOffsets =
record ->
+ {
+ receivedRecords.add(record);
newOffsets.put(
new TopicPartition(record.topic(), record.partition()),
record.offset());
newOffsets.put(
new TopicPartition(record.topic(), record.partition()),
record.offset());
+ };
endlessConsumer.start();
}
endlessConsumer.start();
}