use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.
the class ApplicationDiscoveryListenerTest method test_ignore_pattern.
@Test
public void test_ignore_pattern() {
when(discovery.getServices()).thenReturn(asList("service", "rabbit-1", "rabbit-2"));
when(discovery.getInstances("service")).thenReturn(Collections.singletonList((ServiceInstance) new DefaultServiceInstance("service", "localhost", 80, false)));
listener.setIgnoredServices(singleton("rabbit-*"));
listener.onInstanceRegistered(new InstanceRegisteredEvent<>(new Object(), null));
Collection<Application> applications = registry.getApplications();
assertEquals(1, applications.size());
assertEquals("service", applications.iterator().next().getName());
}
use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.
the class DefaultServiceInstanceConverterTest method test_convert_with_custom_defaults.
@Test
public void test_convert_with_custom_defaults() {
DefaultServiceInstanceConverter converter = new DefaultServiceInstanceConverter();
converter.setHealthEndpointPath("ping");
converter.setManagementContextPath("mgmt");
ServiceInstance service = new DefaultServiceInstance("test", "localhost", 80, false);
Application application = converter.convert(service);
assertThat(application.getId(), nullValue());
assertThat(application.getName(), is("test"));
assertThat(application.getServiceUrl(), is("http://localhost:80"));
assertThat(application.getManagementUrl(), is("http://localhost:80/mgmt"));
assertThat(application.getHealthUrl(), is("http://localhost:80/mgmt/ping"));
}
use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.
the class DefaultServiceInstanceConverterTest method test_convert_with_defaults.
@Test
public void test_convert_with_defaults() {
ServiceInstance service = new DefaultServiceInstance("test", "localhost", 80, false);
Application application = new DefaultServiceInstanceConverter().convert(service);
assertThat(application.getId(), nullValue());
assertThat(application.getName(), is("test"));
assertThat(application.getServiceUrl(), is("http://localhost:80"));
assertThat(application.getManagementUrl(), is("http://localhost:80"));
assertThat(application.getHealthUrl(), is("http://localhost:80/health"));
}
use of de.codecentric.boot.admin.model.Application 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");
Application application = new EurekaServiceInstanceConverter().convert(service);
assertThat(application.getHealthUrl(), is("https://localhost:80/health"));
}
use of de.codecentric.boot.admin.model.Application 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"));
Application application = new EurekaServiceInstanceConverter().convert(service);
assertThat(application.getId(), nullValue());
assertThat(application.getName(), is("test"));
assertThat(application.getServiceUrl(), is("http://localhost:80"));
assertThat(application.getManagementUrl(), is("http://localhost:80/mgmt"));
assertThat(application.getHealthUrl(), is("http://localhost:80/mgmt/ping"));
}
Aggregations