Search in sources :

Example 16 with Application

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"));
}
Also used : EurekaServiceInstance(org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient.EurekaServiceInstance) InstanceInfo(com.netflix.appinfo.InstanceInfo) Application(de.codecentric.boot.admin.model.Application) Test(org.junit.Test)

Example 17 with Application

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"));
}
Also used : EurekaServiceInstance(org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient.EurekaServiceInstance) InstanceInfo(com.netflix.appinfo.InstanceInfo) Application(de.codecentric.boot.admin.model.Application) Test(org.junit.Test)

Example 18 with Application

use of de.codecentric.boot.admin.model.Application 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");
    Application application = new EurekaServiceInstanceConverter().convert(service);
    assertThat(application.getManagementUrl(), is("http://localhost:80"));
}
Also used : EurekaServiceInstance(org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient.EurekaServiceInstance) InstanceInfo(com.netflix.appinfo.InstanceInfo) Application(de.codecentric.boot.admin.model.Application) Test(org.junit.Test)

Example 19 with Application

use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.

the class HazelcastJournaledEventStoreTest method test_store.

@Test
public void test_store() {
    Application application = Application.create("foo").withId("bar").withHealthUrl("http://health").build();
    List<ClientApplicationEvent> events = Arrays.asList(new ClientApplicationRegisteredEvent(application), new ClientApplicationDeregisteredEvent(application));
    for (ClientApplicationEvent event : events) {
        store.store(event);
    }
    // Items are stored in reverse order
    List<ClientApplicationEvent> reversed = new ArrayList<>(events);
    Collections.reverse(reversed);
    assertThat(store.findAll(), is((Collection<ClientApplicationEvent>) reversed));
}
Also used : ClientApplicationDeregisteredEvent(de.codecentric.boot.admin.event.ClientApplicationDeregisteredEvent) ArrayList(java.util.ArrayList) Collection(java.util.Collection) ClientApplicationRegisteredEvent(de.codecentric.boot.admin.event.ClientApplicationRegisteredEvent) Application(de.codecentric.boot.admin.model.Application) ClientApplicationEvent(de.codecentric.boot.admin.event.ClientApplicationEvent) Test(org.junit.Test)

Example 20 with Application

use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.

the class SimpleJournaledEventStoreTest method test_store.

@Test
public void test_store() {
    SimpleJournaledEventStore store = new SimpleJournaledEventStore();
    Application application = Application.create("foo").withId("bar").withHealthUrl("http://health").build();
    List<ClientApplicationEvent> events = Arrays.asList(new ClientApplicationRegisteredEvent(application), new ClientApplicationDeregisteredEvent(application));
    for (ClientApplicationEvent event : events) {
        store.store(event);
    }
    assertThat(store.findAll(), is((Collection<ClientApplicationEvent>) Arrays.asList(events.get(1), events.get(0))));
}
Also used : ClientApplicationDeregisteredEvent(de.codecentric.boot.admin.event.ClientApplicationDeregisteredEvent) Collection(java.util.Collection) ClientApplicationRegisteredEvent(de.codecentric.boot.admin.event.ClientApplicationRegisteredEvent) Application(de.codecentric.boot.admin.model.Application) ClientApplicationEvent(de.codecentric.boot.admin.event.ClientApplicationEvent) Test(org.junit.Test)

Aggregations

Application (de.codecentric.boot.admin.model.Application)36 Test (org.junit.Test)27 DefaultServiceInstance (org.springframework.cloud.client.DefaultServiceInstance)7 ServiceInstance (org.springframework.cloud.client.ServiceInstance)7 ClientApplicationRegisteredEvent (de.codecentric.boot.admin.event.ClientApplicationRegisteredEvent)5 ClientApplicationDeregisteredEvent (de.codecentric.boot.admin.event.ClientApplicationDeregisteredEvent)4 InstanceInfo (com.netflix.appinfo.InstanceInfo)3 ClientApplicationEvent (de.codecentric.boot.admin.event.ClientApplicationEvent)3 StatusInfo (de.codecentric.boot.admin.model.StatusInfo)3 Collection (java.util.Collection)3 Map (java.util.Map)3 EurekaServiceInstance (org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient.EurekaServiceInstance)3 HttpHeaders (org.springframework.http.HttpHeaders)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 Serializable (java.io.Serializable)2 ArrayList (java.util.ArrayList)2 Collections.singletonMap (java.util.Collections.singletonMap)2 HttpEntity (org.springframework.http.HttpEntity)2 RequestContext (com.netflix.zuul.context.RequestContext)1 ClientApplicationStatusChangedEvent (de.codecentric.boot.admin.event.ClientApplicationStatusChangedEvent)1