This repository demonstrate unit and integration tests for two Kafka Streams topologies: UserTopology and UserActivityTopology . Topologies cover key concepts such as stateless and stateful operations, windowing, and the use of state stores
Unit tests for the topologies are implemented using TopologyTestDriver and integration tests are implemented using EmbeddedKafka and Testcontainers.
- Java 17 or higher
- Maven
- Docker (optional, for running Docker Compose which include Zookeeper and Apache Kafka)
-
Clone the repository
git clone <repository-url> cd spring-boot-kafka-streams-test-demo
-
Run Unit Tests and Integration Test UserTopologyEmbeddedKafkaIT.java
mvn clean verify
-
Run Integration Test UserTopologyTestContainerIT.java
Requires Docker to be installed and running and then start Kafka and Zookeeper by using Docker Compose file in the repository:
docker-compose up
When Docker container running Kafka and Zookeeper is spun up then you can run integration test UserTopologyTestContainersIT.