https://github.com/znsio/specmatic-kafka-sample
https://github.com/znsio/specmatic-kafka-sample
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/znsio/specmatic-kafka-sample
- Owner: znsio
- Created: 2024-06-07T08:44:03.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-25T06:53:46.000Z (over 1 year ago)
- Last Synced: 2025-02-25T07:42:46.298Z (over 1 year ago)
- Language: Kotlin
- Size: 2.92 MB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Specmatic Kafka Sample
* [Specmatic Website](https://specmatic.io)
* [Specmatic Documenation](https://specmatic.io/documentation.html)
This sample project demonstrates how we can run contract tests against a service which interacts with a kafka broker.
**NOTE**: This project uses **AsyncAPI 2.6** specification. For equivalent sample project that uses **AsyncAPI 3.0** spec please refer to **[specmatic-kafka-sample-asyncapi3](https://github.com/znsio/specmatic-kafka-sample-asyncapi3)**.
## Background
This project includes a consumer that listens to messages on a specific topic.
Upon receiving a message, the consumer processes it and publishes a new message to two other designated topics.

## Pre-requisites
* Gradle
* JDK 17+
* Docker
## Run the tests
```shell
./gradlew clean test
```
## Run the contract tests using specmatic-kafka docker image
1. Start the kafka broker using below command.
```shell
docker compose up
```
2. Run the application.
```shell
./gradlew bootRun
```
3. Run the contract tests.
```shell
docker run --network host -v "$PWD/specmatic.yaml:/usr/src/app/specmatic.yaml" -v "$PWD/src/test/resources:/usr/src/app/examples" -v "$PWD/build/reports:/usr/src/app/build/reports" znsio/specmatic-kafka:0.22.13 test --examples=examples
```
## Get information around other CLI args exposed by specmatic-kafka docker image
1. To get information around all the CLI args of the `virtualize` command, run the following.
```shell
docker run znsio/specmatic-kafka virtualize --help
```
2. To get information around all the CLI args of the `test` command, run the following.
```shell
docker run znsio/specmatic-kafka test --help
```