Skip to content

norcode-dev/boggrt-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Boggrt Example

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.

What this example demonstrates

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:

  1. Local development with Docker Compose
  2. Integration tests with Testcontainers

In both cases, the application uses the same mock definitions instead of calling the real external API.

Run the application against the real API

./mvnw spring-boot:run

Then call:

GET http://localhost:8080/demo/hello

This runs the application with its default configuration and calls the real external API.

Run the application locally with Boggrt

This flow requires Docker.

./mvnw spring-boot:run -Dspring-boot.run.profiles=local

The 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.

Run the integration tests

This flow also requires Docker.

./mvnw test

During the test run:

  • DemoControllerIntegrationTest starts a Boggrt container with Testcontainers
  • the test-data folder is copied into the container at /resources
  • demo.external-url is overridden to the mapped Boggrt URL
  • the test verifies that /demo/hello returns 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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages