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.
The library available on Maven Central.
Versions match the version of Confluent Schema Registry they're built against.
| embedded-kafka-schema-registry version | Confluent Schema Registry version | embedded-kafka & Kafka Kafka version | Scala versions | Java version |
|---|---|---|---|---|
| 8.1.0 | 8.1.0 | 4.1.x | 2.13, 3.3 | 17+ |
| 8.0.0 | 8.0.0 | 4.0.x | 2.13, 3.3 | 17+ |
| 7.9.2 | 7.9.2 | 3.9.x | 2,12, 2.13, 3.3 | 17+ |
| 7.9.1 | 7.9.1 | 3.9.x | 2,12, 2.13, 3.3 | 17+ |
| 7.9.0 | 7.9.0 | 3.9.x | 2,12, 2.13, 3.3 | 8+ |
| 7.8.0 | 7.8.0 | 3.8.x | 2,12, 2.13, 3.3 | 8+ |
| 7.7.0 | 7.7.0 | 3.7.x | 2,12, 2.13, 3.3 | 8+ |
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.
- In your
build.sbtfile add the following resolvers:
resolvers ++= Seq(
"confluent" at "https://packages.confluent.io/maven/"
)- In your
build.sbtfile add the following dependency (replacex.x.xwith the appropriate version):"io.github.embeddedkafka" %% "embedded-kafka-schema-registry" % "x.x.x" % Test - Have your class extend the
EmbeddedKafkatrait (from theio.github.embeddedkafka.schemaregistrypackage). - Enclose the code that needs a running instance of Kafka within the
withRunningKafkaclosure. - Provide an implicit
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
}
}
}
}- Kafka Broker, Kafka Controller and Schema Registry will be instantiated respectively on port 6001, 6002, and 6003 and automatically shutdown at the end of the test.
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.
- In your
build.sbtfile add the following dependency (replacex.x.xwith the appropriate version):"io.github.embeddedkafka" %% "embedded-kafka-schema-registry-streams" % "x.x.x" % Test - For most of the cases have your class extend the
EmbeddedKafkaStreamstrait (from theio.github.embeddedkafka.schemaregistry.streamspackage). This offers both streams management and easy creation of consumers for asserting resulting messages in output/sink topics. - Use
EmbeddedKafkaStreams.runStreamsandEmbeddedKafka.withConsumerandEmbeddedKafka.withProducer. This allows you to create your own consumers of custom types as seen in the example test.