The goal of this (simple) project, is to act like a real Microservice, so you can simulate success and error scenarios. This project also simulates latency conditions, that is very useful to check if your retry and exponential backoff policies are working as expected.
You can configure which status codes will be returned. In the same way, you can configure a latency range.
Enter in src/main/resources directory and edit application.properties file.
Default values:
microservice.latency=10, 18, 25, 67, 85, 130, 200, 300, 500, 1000
microservice.httpStatusCode=NO_CONTENT, OK, ACCEPTED, CREATED, INTERNAL_SERVER_ERROR, SERVICE_UNAVAILABLE
For httpStatusCode property, you must use Spring's Framework HttpStatus enum values.
latency property is in the order of magnitude of milliseconds.
Do this sequence of steps (command line):
mvn install
java -jar target/*.jar
time curl -v localhost:8080/mock
cURL Examples:
curl localhost:8080/mock -v
curl -X POST localhost:8080/mock -H "Content-Type: application/json" -v
curl -X PUT localhost:8080/mock -H "Content-Type: application/json" -v
curl -X DELETE localhost:8080/mock -H "Content-Type: application/json" -v
- You can also use POST, PUT and DELETE verbs
- If you want to increase the chance of a specific response (latency and/or HTTP status code), just repeat the desired value in the given property