X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fde%2Fjuplo%2Fkafka%2FApplicationTests.java;h=b7f8308e601b46beb3b0f81219a956c34f537f68;hb=66f52b33cb2380a7449ba6135f1b94a7bbe4d57d;hp=1272124cbe58981aeea2fd5483fd79b9bb53540a;hpb=27768041f2c2f4b1cbb8c45c9a5d665490050f76;p=demos%2Fkafka%2Ftraining diff --git a/src/test/java/de/juplo/kafka/ApplicationTests.java b/src/test/java/de/juplo/kafka/ApplicationTests.java index 1272124..b7f8308 100644 --- a/src/test/java/de/juplo/kafka/ApplicationTests.java +++ b/src/test/java/de/juplo/kafka/ApplicationTests.java @@ -1,16 +1,13 @@ package de.juplo.kafka; -import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.common.serialization.LongSerializer; import org.apache.kafka.common.serialization.StringSerializer; import org.apache.kafka.common.utils.Bytes; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Primary; import org.springframework.test.context.ContextConfiguration; -import java.util.Set; import java.util.function.Consumer; @@ -27,28 +24,30 @@ public class ApplicationTests extends GenericApplicationTests @Override - public void generate( - Set poisonPills, - Set logicErrors, + public int generate( + boolean poisonPills, + boolean logicErrors, Consumer> messageSender) { int i = 0; for (int partition = 0; partition < 10; partition++) { - for (int key = 0; key < 10; key++) + for (int key = 0; key < 10000; key++) { - if (++i > 100) - return; + i++; Bytes value = new Bytes(longSerializer.serialize(TOPIC, (long)i)); - if (logicErrors.contains(i)) + if (i == 99977) { - value = new Bytes(longSerializer.serialize(TOPIC, Long.MIN_VALUE)); - } - if (poisonPills.contains(i)) - { - value = new Bytes(stringSerializer.serialize(TOPIC, "BOOM (Poison-Pill)!")); + if (logicErrors) + { + value = new Bytes(longSerializer.serialize(TOPIC, Long.MIN_VALUE)); + } + if (poisonPills) + { + value = new Bytes(stringSerializer.serialize(TOPIC, "BOOM (Poison-Pill)!")); + } } ProducerRecord record = @@ -61,6 +60,8 @@ public class ApplicationTests extends GenericApplicationTests messageSender.accept(record); } } + + return i; } }); } @@ -69,9 +70,8 @@ public class ApplicationTests extends GenericApplicationTests @TestConfiguration public static class Configuration { - @Primary @Bean - public Consumer> consumer() + public RecordHandler applicationRecordHandler() { return (record) -> {