Execute Kafka streams and pass a block of code that can operate while the streams are active.
Execute Kafka streams and pass a block of code that can
operate while the streams are active.
The code block can be used for publishing and consuming messages in Kafka.
The block gets a pre-initialized kafka consumer that can be used implicitly for
util methods such as consumeLazily(String)
.
e.g.
runStreams(Seq("inputTopic", "outputTopic", streamBuilder) { // here you can publish and consume messages and make assertions publishToKafka(in, Seq("one-string", "another-string")) consumeFirstStringMessageFrom(in) should be ("one-string") }
the topics that should be created in Kafka before launching the streams.
the streams builder that will be used to instantiate the streams with a default configuration (all state directories are different and in temp folders)
the code block that will executed while the streams are active. Once the block has been executed the streams will be closed.
Run Kafka Streams while offering a String-based consumer for easy testing of stream output.
Run Kafka Streams while offering a String-based consumer for easy testing of stream output.
the topics that should be created. Usually these should be the topics that the Streams-under-test use for inputs and outputs. They need to be created before running the streams and this is automatically taken care of.
the streams builder that contains the stream topology that will be instantiated
the block of testing code that will be executed by passing the simple String-based consumer.
the result of the testing code
Create a test stream config for a given stream.
Create a test stream config for a given stream.
the name of the stream. It will be used as the Application ID
any additional configuration. If the keys are already defined in the default they will be overwritten with this
the Kafka test configuration
the Streams configuration
Convenience trait for testing Kafka Streams with ScalaTest. It exposes
EmbeddedKafkaStreams.runStreams
as well asConsumers
api for easily creating and querying consumers in tests.e.g.
EmbeddedKafkaStreams
Consumers