use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.
the class StatusUpdaterTest method test_updateStatusForApplications.
@Test
public void test_updateStatusForApplications() throws InterruptedException {
updater.setStatusLifetime(100L);
Application app1 = Application.create("foo").withId("id-1").withHealthUrl("health-1").build();
store.save(app1);
// Let the StatusInfo of id-1 expire
Thread.sleep(120L);
Application app2 = Application.create("foo").withId("id-2").withHealthUrl("health-2").build();
store.save(app2);
when(applicationOps.getHealth(eq(app1))).thenReturn(ResponseEntity.ok((Map<String, Serializable>) null));
updater.updateStatusForAllApplications();
assertThat(store.find("id-1").getStatusInfo().getStatus(), CoreMatchers.is("UP"));
verify(applicationOps, never()).getHealth(eq(app2));
}
use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.
the class ApplicationHeadersFilterTest method test_add_headers_on_matching_route_only.
@Test
public void test_add_headers_on_matching_route_only() {
Application application = Application.create("test").withHealthUrl("/health").build();
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.add("test", "qwertz");
when(routeLocator.getMatchingRoute("/health")).thenReturn(new ApplicationRoute(application, null, null, null, null));
when(headerProvider.getHeaders(application)).thenReturn(httpHeaders);
RequestContext context = creteRequestContext("/health");
RequestContext.testSetCurrentContext(context);
filter.run();
assertThat(context.getZuulRequestHeaders().get("test"), is("qwertz"));
context = creteRequestContext("/foobar");
RequestContext.testSetCurrentContext(context);
filter.run();
assertThat(context.getZuulRequestHeaders().get("test"), nullValue());
}
use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.
the class ApplicationRegistryTest method register.
@Test
public void register() throws Exception {
Application app = registry.register(Application.create("abc").withHealthUrl("http://localhost:8080/health").build());
assertEquals("http://localhost:8080/health", app.getHealthUrl());
assertEquals("abc", app.getName());
assertNotNull(app.getId());
}
use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.
the class ApplicationRegistryTest method refresh.
@Test
public void refresh() throws Exception {
// Given application is already reegistered and has status and info.
StatusInfo status = StatusInfo.ofUp();
Info info = Info.from(singletonMap("foo", "bar"));
Application app = Application.create("abc").withHealthUrl("http://localhost:8080/health").withStatusInfo(status).withInfo(info).build();
String id = idGenerator.generateId(app);
store.save(Application.copyOf(app).withId(id).build());
// When application registers second time
Application registered = registry.register(Application.create("abc").withHealthUrl("http://localhost:8080/health").build());
// Then info and status are retained
assertThat(registered.getInfo(), sameInstance(info));
assertThat(registered.getStatusInfo(), sameInstance(status));
}
use of de.codecentric.boot.admin.model.Application in project spring-boot-admin by codecentric.
the class ApplicationRegistryTest method getApplicationsByName.
@Test
public void getApplicationsByName() throws Exception {
Application app = registry.register(Application.create("abc").withHealthUrl("http://localhost/health").build());
Application app2 = registry.register(Application.create("abc").withHealthUrl("http://localhost:8081/health").build());
Application app3 = registry.register(Application.create("zzz").withHealthUrl("http://localhost:8082/health").build());
Collection<Application> applications = registry.getApplicationsByName("abc");
assertEquals(2, applications.size());
assertTrue(applications.contains(app));
assertTrue(applications.contains(app2));
assertFalse(applications.contains(app3));
}
Aggregations