A Java webapp with a servlet for mocking JSON web service responses.
The purpose of this is to allow our various middle-tier implementations to hit a backend over the network and receive data back to simulate actual behavior.
What happens inside this service is not important as long as it returns JSON and takes time to simulate a service dependency doing something.
Number used to generate a 'responseKey' for the ws-client to assert correct implementation and flow of requests.
The delay in milliseconds to add to the server side response to simulate server-side latency.
Default: 50ms
The number of items to return in a JSON Array.
Default: 10
The length in characters of each item in the list.
Default: 128
Example Requests:
http://hostname:8989/ws-backend-mock/mock.json?id=123
http://hostname:8989/ws-backend-mock/mock.json?id=123&delay=500
http://hostname:8989/ws-backend-mock/mock.json?id=123&numItems=25&itemSize=256
http://hostname:8989/ws-backend-mock/mock.json?id=123&numItems=25&itemSize=256&delay=400
Example Response:
{
"responseKey":41262963,
"delay": 50,
"itemSize": 128,
"numItems": 10,
"items": [
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ",
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ",
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ",
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ",
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ",
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ",
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ",
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ",
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ",
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut "
]
}
To run from command line:
../gradlew jettyRun