@SuppressWarnings({ "unchecked", "rawtypes" })
	@Test
	void shouldReregisterHealthCheckHandlerAfterRefresh() throws Exception {
		TestPropertyValues
			.of("eureka.client.healthcheck.enabled=true", "spring.cloud.config.import-check.enabled=false",
					"spring.cloud.refresh.additionalPropertySourcesToRetain=test")
			.applyTo(this.context);
		setupContext(RefreshAutoConfiguration.class, AutoServiceRegistrationConfiguration.class);

		EurekaClient oldEurekaClient = getLazyInitEurekaClient();

		HealthCheckHandler healthCheckHandler = this.context.getBean("eurekaHealthCheckHandler",
				HealthCheckHandler.class);

		assertThat(healthCheckHandler).isInstanceOf(EurekaHealthCheckHandler.class);
		assertThat(oldEurekaClient.getHealthCheckHandler()).isSameAs(healthCheckHandler);

		ContextRefresher refresher = this.context.getBean(ContextRefresher.class);
		if (refresher instanceof ApplicationListener) {
			ApplicationListener<ContextRefreshedWithApplicationEvent> listener = (ApplicationListener) refresher;
			listener.onApplicationEvent(new ContextRefreshedWithApplicationEvent(Mockito.mock(SpringApplication.class),
					new String[0], this.context));
		}
		refresher.refresh();

		EurekaClient newEurekaClient = getLazyInitEurekaClient();
		HealthCheckHandler newHealthCheckHandler = this.context.getBean("eurekaHealthCheckHandler",
				HealthCheckHandler.class);

		assertThat(healthCheckHandler).isSameAs(newHealthCheckHandler);
		assertThat(oldEurekaClient).isNotSameAs(newEurekaClient);
		assertThat(newEurekaClient.getHealthCheckHandler()).isSameAs(healthCheckHandler);
	}
@author Spencer Gibb
@author Matt Jenkins
@author Olga Maciaszek-Sharma
@author Tim Ysewyn
spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationTests.java