Skip to content

Instantly share code, notes, and snippets.

@Romeh
Created December 3, 2017 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Romeh/5c51906140851f1c4d8fd98efdafff33 to your computer and use it in GitHub Desktop.
Save Romeh/5c51906140851f1c4d8fd98efdafff33 to your computer and use it in GitHub Desktop.
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