Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class ApplicationSanityCheck{
@Rule
public final RetryRule retry = new RetryRule();
private int port = 8080;
private RestTemplate template;
private URL base;
@Before
public void setUp() throws Exception {
this.base = new URL("http://localhost:" + port + "/");
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
template = new RestTemplate(requestFactory);
}
@Test
// example of true end to end call which call UAT real endpoint
// and retry in case of failure 4 times with 20 seconds delay between each try
@Retry(times = 4, timeout = 20000)
public void test_is_server_up() {
assertTrue(template.getForEntity(base + "/health", String.class).getStatusCode().is2xxSuccessful());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment