Search in sources :

Example 1 with EurekaServiceInstance

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");
}
Also used : EurekaServiceInstance(org.springframework.cloud.netflix.eureka.EurekaServiceInstance) Registration(de.codecentric.boot.admin.server.domain.values.Registration) InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.jupiter.api.Test)

Example 2 with EurekaServiceInstance

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");
}
Also used : EurekaServiceInstance(org.springframework.cloud.netflix.eureka.EurekaServiceInstance) Registration(de.codecentric.boot.admin.server.domain.values.Registration) InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.jupiter.api.Test)

Example 3 with EurekaServiceInstance

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);
}
Also used : EurekaServiceInstance(org.springframework.cloud.netflix.eureka.EurekaServiceInstance) InstanceInfo(com.netflix.appinfo.InstanceInfo)

Example 4 with EurekaServiceInstance

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");
}
Also used : EurekaServiceInstance(org.springframework.cloud.netflix.eureka.EurekaServiceInstance) Registration(de.codecentric.boot.admin.server.domain.values.Registration) InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.jupiter.api.Test)

Aggregations

InstanceInfo (com.netflix.appinfo.InstanceInfo)4 EurekaServiceInstance (org.springframework.cloud.netflix.eureka.EurekaServiceInstance)4 Registration (de.codecentric.boot.admin.server.domain.values.Registration)3 Test (org.junit.jupiter.api.Test)3