How to Test Latency with a Mock Server in Java
The source code for what follows can be found on Github.
Very often, you will want to test service api clients using a Mock Server [for example, testing the spring webclient with mockserver]. And since network latency is a fact of life, not something we can merely ignore, actually injecting some latency to simulate timeouts will give us greater confidence that our system will behave as expected.