Simple example demonstrating how testcontainers, RabbitMQ and JUnit 5 can play together.
A simple test will be converted into JSON and send by RabbitSender.kt to rabbit. Message will be received by RabbitReceiver.kt.
- Spring Boot >= 3.0.x
- Kotlin >= 1.7.x
- Rabbit 3
- Testcontainers >= 1.17.x
- JUnit >= 5.9.x
- Java 17
- Maven >= 3.2.1 (Kotlin comes as maven dependency)
- Docker >= 3.0 (for integration tests)
Integration test RabbitIT
will be started in maven phase verify
.
$ git clone https://github.com/larmic/spring-boot-demos
$ mvn clean verify -f spring-boot-rabbitmq
# start local rabbit
$ docker compose -f misc/rabbitmq/docker-compose.yml up -d
# start application
$ mvn spring-boot:run
# Post a new message
$ curl -i -H "Content-Type: text/plain" --request POST --data 'hello, this is a rabbit message!' http://localhost:8080/