boggrt-example is a small Spring Boot application that demonstrates how to use
Boggrt: replacing a real external HTTP dependency with a predictable mock server.
The main idea is straightforward: define mock responses once, then reuse them in both local development and integration tests.
This application exposes a GET /demo/hello endpoint and calls the https://dogapi.dog API by default.
This example shows how to replace that external dependency with Boggrt in two situations:
- Local development with Docker Compose
- Integration tests with Testcontainers
In both cases, the application uses the same mock definitions instead of calling the real external API.
./mvnw spring-boot:runThen call:
GET http://localhost:8080/demo/hello
This runs the application with its default configuration and calls the real external API.
This flow requires Docker.
./mvnw spring-boot:run -Dspring-boot.run.profiles=localThe local profile does three things:
- sets
demo.external-url=http://localhost:9080/ - enables Spring Boot Docker Compose support
- starts the Boggrt container defined in
docker-compose.yml
When the app is running, requests to /demo/hello are served using the mock response defined in
src/test/resources/test-data/example.json.
This allows local development against a predictable mocked dependency instead of the real external API.
This flow also requires Docker.
./mvnw testDuring the test run:
DemoControllerIntegrationTeststarts a Boggrt container with Testcontainers- the
test-datafolder is copied into the container at/resources demo.external-urlis overridden to the mapped Boggrt URL- the test verifies that
/demo/helloreturns the mocked response
This reuses the same mock definitions used during local development, so tests run against the same mocked behavior instead of the real external API.