Appendix A: Testing event-driven code
One notification route tested against a real Kafka from Dev Services, with its HTTP source stubbed by the test application, an AdviceWith route test, first-match and drain assertions, and a harness that proves each guard by running altered copies.
Chapter 36
examples/aa-testing-event-driven-code/ holds one Camel route that reads OrderPlaced, drops a repeated event id, fetches the order over HTTP, skips a cancelled order and publishes a notification keyed by the order id. It accompanies Appendix A: Testing event-driven code.
It uses Quarkus, Camel Quarkus (Kafka, HTTP, Jackson), camel-quarkus-junit with AdviceWith, KafkaCompanion and Kafka Dev Services. No compose stack runs.
(cd examples/domain-model && mvn -B -q install)
cd examples/aa-testing-event-driven-code
./verify.sh
What to observe
- A route test without a broker. The advised route takes an exchange on
direct:inand ends on a mock endpoint. - A drain that sees a second record. Each altered copy fails only the test that names its guard.
- A first match that stays green. With the dedup removed, the first-match test still passes.