Skip to content

Instantly share code, notes, and snippets.

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 jabrena/2efa34a9a162041672a568b6072a96ef to your computer and use it in GitHub Desktop.
Save jabrena/2efa34a9a162041672a568b6072a96ef to your computer and use it in GitHub Desktop.
Spring Boot Test example
@Autowired
private DiscoveryClient discoveryClient;
@Value("${spring.application.name}")
private String microServiceName;
@Value("${eureka.instance.leaseRenewalIntervalInSeconds}")
private int leaseInternval;
@Test
public void eurekaHeartbeatTest() throws Exception {
//Force a heartbeat on Eureka
TimeUnit.SECONDS.sleep(leaseInternval);
final List<ServiceInstance> microServiceInstances =
discoveryClient.getInstances(microServiceName);
assertTrue(microServiceInstances.size() > 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment