• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Having a junit run a piece of code for 1 min interval until it returns success

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 13562
223
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!