projects
/
demos
/
kafka
/
training
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Verbesserte Tests und Korrekturen gemerged: sumup-adder -> stored-offsets
[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
51d579e
..
5166227
100644
(file)
--- a/
src/test/java/de/juplo/kafka/ApplicationTests.java
+++ b/
src/test/java/de/juplo/kafka/ApplicationTests.java
@@
-10,7
+10,6
@@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.context.annotation.Primary;
import org.springframework.test.context.ContextConfiguration;
-import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Consumer;
@@
-27,10
+26,9
@@
public class ApplicationTests extends GenericApplicationTests<String, Long>
@Override
@Override
- public void generate(
- int numberOfMessagesToGenerate,
- Set<Integer> poisonPills,
- Set<Integer> logicErrors,
+ public int generate(
+ boolean poisonPills,
+ boolean logicErrors,
Consumer<ProducerRecord<Bytes, Bytes>> messageSender)
{
int i = 0;
Consumer<ProducerRecord<Bytes, Bytes>> messageSender)
{
int i = 0;
@@
-39,17
+37,19
@@
public class ApplicationTests extends GenericApplicationTests<String, Long>
{
for (int key = 0; key < 10; key++)
{
{
for (int key = 0; key < 10; key++)
{
- if (++i > numberOfMessagesToGenerate)
- return;
+ i++;
Bytes value = new Bytes(longSerializer.serialize(TOPIC, (long)i));
Bytes value = new Bytes(longSerializer.serialize(TOPIC, (long)i));
- if (
logicErrors.contains(i)
)
+ if (
i == 77
)
{
{
- 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<Bytes, Bytes> record =
}
ProducerRecord<Bytes, Bytes> record =
@@
-62,6
+62,8
@@
public class ApplicationTests extends GenericApplicationTests<String, Long>
messageSender.accept(record);
}
}
messageSender.accept(record);
}
}
+
+ return i;
}
});
}
}
});
}
@@
-72,12
+74,18
@@
public class ApplicationTests extends GenericApplicationTests<String, Long>
{
@Primary
@Bean
{
@Primary
@Bean
- public
Consumer<ConsumerRecord<String, Long>> consum
er()
+ public
ApplicationRecordHandler recordHandl
er()
{
{
- return (record) ->
+ ApplicationRecordHandler recordHandler = new ApplicationRecordHandler();
+ return new ApplicationRecordHandler()
{
{
- if (record.value() == Long.MIN_VALUE)
- throw new RuntimeException("BOOM (Logic-Error)!");
+ @Override
+ public void accept(ConsumerRecord<String, Long> record)
+ {
+ if (record.value() == Long.MIN_VALUE)
+ throw new RuntimeException("BOOM (Logic-Error)!");
+ super.accept(record);
+ }
};
}
}
};
}
}