Seeding Cosmos DB Data and run integration tests with Testcontainers and Cosmos DB Docker emulator for Spring Boot applications - Complete Source Code
Complete source code for the content / guide / tutorial covered at:
https://tech.asimio.net/2023/09/08/Cosmos-DB-Spring-Boot-2-Integration-Tests-Seed-Data.html
https://tech.asimio.net/2023/09/10/Extract-Certificate-Create-Truststore-Programmatically.html
https://tech.asimio.net/2024/02/28/Cosmos-DB-Spring-Boot-2-Integration-Tests-Testcontainers.html
Seed Azure Cosmos DB data and run integration tests for your Spring Boot applications with Testcontainers.
Your team uses Java, Spring Boot, and Azure Cosmos DB as a NoSQL data storage to implement functional requirements.
Is the team running integration tests to verify that Cosmos DB interactions go as expected?
The Spring Boot application source code you'll get with this purchase could save your team one or two 2-weeks Sprints worth of time and costs by starting with a fully working code base.
What does the source code include?
- A custom Spring TestExecutionListener implementation that adds support to seed Cosmos DB data from JSON files.
- A working integration test class with a handful of tests that seed data using different strategies.
Class-level support, Method-level support similar to @SqlGroup, @Sql annotations.
Although this integration test class requires a running azure-cosmos-emulator Docker container. - A utility class that automates adding the Cosmos DB self-signed cert to a custom Java truststore just for testing purposes. No manual labor involved.
- A custom Cosmos DB emulator Testcontainer implementation that your team can use or start from.
- Another working integration test class that doesn't require a running azure-cosmos-emulator Docker container. It uses Testcontainers to start/stop the Cosmos DB emulator. Also using a random, available port for the emulator endpoint.
- A custom Jupiter/JUnit 5 callback extension implementation to reuse the same Cosmos DB emulator Docker container across all integration test classes, helping your organization to reduce your tests suite execution time.
It also sets up a temporal truststore, System and Spring Cloud connection properties. - Yet another working integration test class that uses this Cosmos DB-based Jupiter/JUnit 5 callback extension.
A fully working Spring Boot application source code with Integration Tests that seed Cosmos DB data and use Testcontainers to run an azure-cosmos-emulator Docker container