schemaregistry-junit
Library | Version | Documentation | Vulnerability |
---|---|---|---|
schemaregistry-junit5 | |||
schemaregistry-junit4 | |||
schemaregistry-junit-core |
Are you tired of waiting for Docker containers to fire up while testing your Kafka solution? Or are you tired of waiting for an ephemeral environment to start? Are you looking for a solution to reduce the time you are loosing waiting for Apache Kafka Cluster and Confluent Schema Registry to start while testing? schemaregistry-junit is the answer! By pairing schemaregistry-junit together with kafka-junit, you can speed up your tests and shorten the feedback loop by reducing the time wasted waiting for Docker containers or ephemeral environments to start. schemaregistry-junit lets you run a fully working Confluent Schema Registry in-memory. The server lifecycle is fully automated via JUnit extensions. A fluent DSL is provided to configure the Confluent Schema Registry.
This project was inspired by kafka-junit.
Features
- Support for JUnit 4 and JUnit 5
- Support all Confluent SchemaRegistry version from 4.0.0 to the latest
Installation
The easiest way to include schemaregistry-junit
in your project(s) is via Maven dependency. Binary, Sources and Javadocs are all available in Maven Central.
For JUnit 5
Maven
Example POM
<!-- Declare schemaregistry-junit5 dependency -->
<dependency>
<groupId>io.github.data-rocks-team</groupId>
<artifactId>schemaregistry-junit5</artifactId>
<version>0.1.1</version>
</dependency>
<!-- Include Confluent Schema-Registry -->
<dependency>
<groupId>io.confluent</groupId>
<artifactId>kafka-schema-registry</artifactId>
<version>X.X.X</version>
</dependency>
Gradle
Example build.gradle
testImplementation 'io.github.data-rocks-team:schemaregistry-junit5:0.1.1'
testImplementation 'io.confluent:kafka-schema-registry:X.X.X'
For JUnit 4
Maven
Example POM
<!-- Declare schemaregistry-junit5 dependency -->
<dependency>
<groupId>io.github.data-rocks-team</groupId>
<artifactId>schemaregistry-junit4</artifactId>
<version>0.1.1</version>
</dependency>
<!-- Include Confluent Schema-Registry -->
<dependency>
<groupId>io.confluent</groupId>
<artifactId>kafka-schema-registry</artifactId>
<version>X.X.X</version>
</dependency>
Gradle
Example build.gradle
testImplementation 'io.github.data-rocks-team:schemaregistry-junit4:0.1.1'
testImplementation 'io.confluent:kafka-schema-registry:X.X.X'
How it works
Given a class using SharedSchemaRegistryTestResource
, before all tests start, JUnit calls the start function. This function replicates the behaviour of SchemaRegistryMain.java, which first validates the settings and then starts the server. When all tests have been executed, independently of the test results, JUnit calls the shutdown function, which will shut the server down. Logs generated by the server are redirected to the terminal.
Regression testing
Every build is automatically tested against the latest patch version of every minor version since 4.0.0. For more details, check schemaregistry-junit-regression-test.
Examples
Before compiling any example, run ./gradlew setDependenciesForExample
in the main project. This gradle task will ensure that the example project will use the same dependency versions used in the main project. To ensure that setDependenciesForExample
works as expected, dependencies version should be defined in the ext {}
section in the main build.gradle and the example project should define versions as nameOfTheDependencyVersion = PLACEHOLDER
(an example can be found here).
Contributing
Found a bug? Think you've got an awesome feature you want to add? We welcome contributions!
Feedback
Any questions or suggestions? Get in touch!
Blog post
License
MIT view license