A Spring Boot application for creating and managing HTTP mocks using WireMock and MongoDB.
- Java 21 (LTS) - Long-term support Java version with modern features
- Spring Boot 3.5.4 - Modern Spring framework with enhanced capabilities
- Gradle 9.0 (Kotlin DSL) - Type-safe build automation
- WireMock 3.13.1 - Powerful HTTP service virtualization
- MongoDB - Flexible document storage for mock configurations
- Spring Boot Actuator - Production-ready monitoring and health checks
- Lombok - Reduced boilerplate code
- Testcontainers - Integration testing with real services
- Java 21 (LTS) - Required for building and running the application
- Docker Desktop - Required for running tests (uses Testcontainers for MongoDB)
- MongoDB (optional for basic testing - can be configured later)
- Git for version control
The project uses Java 21 via Gradle's toolchain feature. Gradle will automatically detect Java 21 if installed. If you have multiple Java versions installed, ensure Java 21 is available in your system PATH or set JAVA_HOME to point to your Java 21 installation.
The project uses Testcontainers for integration testing, which requires Docker to be running:
- Install Docker Desktop for your operating system
- Start Docker Desktop and ensure it's running
- Verify Docker is running:
docker infoshould not show connection errors
git clone <your-repo-url>
cd Mock-Service./gradlew build./gradlew bootRunOpen another terminal and run:
curl http://localhost:8080/actuator/healthExpected response:
{"status":"UP"}| Command | Description |
|---|---|
./gradlew build |
Build the project and run tests |
./gradlew bootRun |
Start the application with hot reload |
./gradlew test |
Run all tests |
./gradlew clean |
Clean build artifacts |
./gradlew clean build |
Clean and build from scratch |
- Health Check:
GET /actuator/health - Application Info:
GET /actuator/info - Metrics:
GET /actuator/metrics
- Create Mock:
POST /api/mocks- Create a new HTTP mock - List Mocks:
GET /api/mocks- List all configured mocks - Mock Health:
GET /api/mocks/health- Check mock service health
- Get Mocked User:
GET /external/user- Retrieve user data from mocked endpoint
- Swagger UI:
http://localhost:8080/swagger-ui.html- Interactive API documentation - OpenAPI JSON:
http://localhost:8080/v3/api-docs- OpenAPI 3.0 specification
Mock-Service/
βββ src/
β βββ main/
β β βββ java/com/example/mockservice/
β β β βββ MockServiceApplication.java
β β βββ resources/
β β βββ application.properties
β β βββ static/
β β βββ templates/
β βββ test/
β βββ java/com/example/mockservice/
βββ gradle/
βββ build.gradle.kts
βββ settings.gradle.kts
βββ README.md
The application uses application.properties for configuration. Key settings:
- Server Port:
8080(default) - MongoDB: Auto-configuration (when available)
- Actuator: Health endpoints enabled
# Ensure Docker Desktop is running first
docker info
# Run all tests
./gradlew testThe project includes:
- Unit tests for core functionality
- Integration tests with Testcontainers
- MongoDB integration testing using Docker containers
If tests fail with Docker-related errors:
- Ensure Docker Desktop is installed and running
- Verify Docker connectivity:
docker info - On Windows: Check that Docker Desktop is using the correct engine (WSL2 or Hyper-V)
Coming soon - Docker containerization
- Basic WireMock integration
- MongoDB mock storage
- REST API for mock management
- Web UI for mock configuration
- Request/Response logging
- Mock templates and scenarios
- API documentation with Swagger
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin feature-name - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Build fails with Java version error:
- Ensure Java 21 (LTS) is installed
- Gradle will automatically use Java 21 for compilation (configured in
build.gradle.kts) - If Java 21 is not detected, verify it's installed and in your system PATH
- You can check installed Java versions:
java -version - Note: Gradle 9.0 can run with Java 17+ (including Java 25), but the project code requires Java 21
Tests fail with Docker/Testcontainers errors:
- Ensure Docker Desktop is installed and running
- Run
docker infoto verify Docker connectivity - On Windows: Make sure Docker Desktop is using the correct engine
WireMock HttpServerFactory errors:
- This project uses
wiremock-standalonefor better Java 21+ compatibility - If you see "Jetty 11 is not present" errors, ensure you're using the standalone version
- The standalone version includes all necessary HTTP server dependencies
Application won't start - MongoDB connection error:
- MongoDB connection is optional for basic functionality
- Configure
spring.data.mongodb.uriin application.properties if needed
Port 8080 already in use:
- Change the port in application.properties:
server.port=8081
Happy Mocking! π