use of org.springframework.cloud.netflix.eureka.EurekaServiceInstance in project spring-boot-admin by codecentric.
the class EurekaServiceInstanceConverterTest method convert_secure_healthUrl.
@Test
public void convert_secure_healthUrl() {
InstanceInfo instanceInfo = mock(InstanceInfo.class);
when(instanceInfo.getSecureHealthCheckUrl()).thenReturn("https://localhost:80/health");
EurekaServiceInstance service = mock(EurekaServiceInstance.class);
when(service.getInstanceInfo()).thenReturn(instanceInfo);
when(service.getUri()).thenReturn(URI.create("http://localhost:80"));
when(service.getServiceId()).thenReturn("test");
Registration registration = new EurekaServiceInstanceConverter().convert(service);
assertThat(registration.getHealthUrl()).isEqualTo("https://localhost:80/health");
}
use of org.springframework.cloud.netflix.eureka.EurekaServiceInstance in project spring-boot-admin by codecentric.
the class EurekaServiceInstanceConverterTest method convert_missing_mgmtpath.
@Test
public void convert_missing_mgmtpath() {
InstanceInfo instanceInfo = mock(InstanceInfo.class);
when(instanceInfo.getHealthCheckUrl()).thenReturn("http://localhost:80/mgmt/ping");
EurekaServiceInstance service = mock(EurekaServiceInstance.class);
when(service.getInstanceInfo()).thenReturn(instanceInfo);
when(service.getUri()).thenReturn(URI.create("http://localhost:80"));
when(service.getServiceId()).thenReturn("test");
Registration registration = new EurekaServiceInstanceConverter().convert(service);
assertThat(registration.getManagementUrl()).isEqualTo("http://localhost:80/actuator");
}
use of org.springframework.cloud.netflix.eureka.EurekaServiceInstance in project spring-boot-admin by codecentric.
the class EurekaServiceInstanceConverter method getHealthUrl.
@Override
protected URI getHealthUrl(ServiceInstance instance) {
if (!(instance instanceof EurekaServiceInstance)) {
return super.getHealthUrl(instance);
}
InstanceInfo instanceInfo = ((EurekaServiceInstance) instance).getInstanceInfo();
String healthUrl = instanceInfo.getSecureHealthCheckUrl();
if (!StringUtils.hasText(healthUrl)) {
healthUrl = instanceInfo.getHealthCheckUrl();
}
return URI.create(healthUrl);
}
use of org.springframework.cloud.netflix.eureka.EurekaServiceInstance in project spring-boot-admin by codecentric.
the class EurekaServiceInstanceConverterTest method convert_secure.
@Test
public void convert_secure() {
InstanceInfo instanceInfo = mock(InstanceInfo.class);
when(instanceInfo.getSecureHealthCheckUrl()).thenReturn("");
when(instanceInfo.getHealthCheckUrl()).thenReturn("http://localhost:80/mgmt/ping");
EurekaServiceInstance service = mock(EurekaServiceInstance.class);
when(service.getInstanceInfo()).thenReturn(instanceInfo);
when(service.getUri()).thenReturn(URI.create("http://localhost:80"));
when(service.getServiceId()).thenReturn("test");
when(service.getMetadata()).thenReturn(singletonMap("management.context-path", "/mgmt"));
Registration registration = new EurekaServiceInstanceConverter().convert(service);
assertThat(registration.getName()).isEqualTo("test");
assertThat(registration.getServiceUrl()).isEqualTo("http://localhost:80");
assertThat(registration.getManagementUrl()).isEqualTo("http://localhost:80/mgmt");
assertThat(registration.getHealthUrl()).isEqualTo("http://localhost:80/mgmt/ping");
}
Aggregations