A library that provides in-memory instances of both Kafka and Confluent Schema Registry to run your tests against.
Relies on the embedded-kafka library.
embedded-kafka-schema-registry is available on Maven Central, compiled for Scala 2.12 and 2.13.
Support for Scala 2.11 was dropped by Apache in Kafka v2.5.0.
Versions match the version of Confluent Schema Registry they're built against.
Prior to v2.8.0 Kafka core was inlining the Scala library, so you couldn't use a different Scala patch version than what Kafka used to compile its jars!
From v6.2.0 onwards package name has been updated to reflect the library group id (i.e. io.github.embeddedkafka
).
Aliases to the old package name have been added, along with a one-time Scalafix rule to ensure the smoothest migration.
build.sbt
file add the following resolvers:resolvers ++= Seq(
"confluent" at "https://packages.confluent.io/maven/",
"jitpack" at "https://jitpack.io"
)
build.sbt
file add the following dependency (replace x.x.x
with the appropriate version): "io.github.embeddedkafka" %% "embedded-kafka-schema-registry" % "x.x.x" % Test
EmbeddedKafka
trait (from the io.github.embeddedkafka.schemaregistry
package).withRunningKafka
closure.EmbeddedKafkaConfigImpl
(from the same package mentioned before).class MySpec extends AnyWordSpecLike with Matchers with EmbeddedKafka {
"runs with embedded kafka and Schema Registry" should {
"work" in {
implicit val config = EmbeddedKafkaConfig()
withRunningKafka {
// ... code goes here
}
}
}
}
A library that builds on top of embedded-kafka-schema-registry
to offer easy testing of Kafka Streams with Confluent Schema Registry.
It takes care of instantiating and starting your streams as well as closing them after running your test-case code.
build.sbt
file add the following dependency (replace x.x.x
with the appropriate version): "io.github.embeddedkafka" %% "embedded-kafka-schema-registry-streams" % "x.x.x" % Test
EmbeddedKafkaStreams
trait (from the io.github.embeddedkafka.schemaregistry.streams
package). This offers both streams management and easy creation of consumers for asserting resulting messages in output/sink topics.EmbeddedKafkaStreams.runStreams
and EmbeddedKafka.withConsumer
and EmbeddedKafka.withProducer
. This allows you to create your own consumers of custom types as seen in the example test.