Hi I m running tests that calls real API calls. I want to make sure the api endpoint returns 200 before I run the tests. I would want to retry couple of times every few mins if it returns 500 or 503. What is the best way to do this in junit. Any pointers appreciated.
Is this a system test or a unit test? Are you verifying the functionality at the endpoint or that the endpoint is reachable and clients able to receive a response?
If you are just trying to test functionality, then you would be doing yourself a favor by testing at a finer grained level, without the network involved. If you are testing your configuration and infrastructure setup, then use a loop with some kind of counter for number of attempts to connect.
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck