Search in sources :

Example 1 with Application

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

the class ApplicationTest method test_json_format.

@Test
public void test_json_format() throws JsonProcessingException, IOException {
    ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();
    Application app = Application.create("test").withHealthUrl("http://health").withServiceUrl("http://service").withManagementUrl("http://management").build();
    DocumentContext json = JsonPath.parse(objectMapper.writeValueAsString(app));
    assertThat((String) json.read("$.name")).isEqualTo("test");
    assertThat((String) json.read("$.serviceUrl")).isEqualTo("http://service");
    assertThat((String) json.read("$.managementUrl")).isEqualTo("http://management");
    assertThat((String) json.read("$.healthUrl")).isEqualTo("http://health");
}
Also used : DocumentContext(com.jayway.jsonpath.DocumentContext) Application(de.codecentric.boot.admin.client.registration.Application) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 2 with Application

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

the class DefaultApplicationFactoryTest method test_mgmtPortPath.

@Test
public void test_mgmtPortPath() {
    management.setContextPath("/admin");
    DefaultApplicationFactory factory = new DefaultApplicationFactory(client, management, server, "/alive");
    publishApplicationReadyEvent(factory, 8080, 8081);
    Application app = factory.createApplication();
    assertThat(app.getManagementUrl(), is("http://" + getHostname() + ":8081/admin"));
    assertThat(app.getHealthUrl(), is("http://" + getHostname() + ":8081/admin/alive"));
    assertThat(app.getServiceUrl(), is("http://" + getHostname() + ":8080"));
}
Also used : SpringApplication(org.springframework.boot.SpringApplication) Application(de.codecentric.boot.admin.client.registration.Application) DefaultApplicationFactory(de.codecentric.boot.admin.client.registration.DefaultApplicationFactory) Test(org.junit.Test)

Example 3 with Application

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

the class DefaultApplicationFactoryTest method test_contextPath_mgmtPortPath.

@Test
public void test_contextPath_mgmtPortPath() {
    server.setContextPath("app");
    management.setContextPath("/admin");
    publishApplicationReadyEvent(factory, 8080, 8081);
    Application app = factory.createApplication();
    assertThat(app.getManagementUrl(), is("http://" + getHostname() + ":8081/admin"));
    assertThat(app.getHealthUrl(), is("http://" + getHostname() + ":8081/admin/health"));
    assertThat(app.getServiceUrl(), is("http://" + getHostname() + ":8080/app"));
}
Also used : SpringApplication(org.springframework.boot.SpringApplication) Application(de.codecentric.boot.admin.client.registration.Application) Test(org.junit.Test)

Example 4 with Application

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

the class DefaultApplicationFactoryTest method test_ssl_managment.

@Test
public void test_ssl_managment() {
    management.setSsl(new Ssl());
    management.getSsl().setEnabled(true);
    publishApplicationReadyEvent(factory, 8080, 9090);
    Application app = factory.createApplication();
    assertThat(app.getManagementUrl(), is("https://" + getHostname() + ":9090"));
    assertThat(app.getHealthUrl(), is("https://" + getHostname() + ":9090/health"));
    assertThat(app.getServiceUrl(), is("http://" + getHostname() + ":8080"));
}
Also used : Ssl(org.springframework.boot.context.embedded.Ssl) SpringApplication(org.springframework.boot.SpringApplication) Application(de.codecentric.boot.admin.client.registration.Application) Test(org.junit.Test)

Example 5 with Application

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

the class DefaultApplicationFactoryTest method test_preferIpAddress_serveraddress_missing.

@Test
public void test_preferIpAddress_serveraddress_missing() {
    client.setPreferIp(true);
    publishApplicationReadyEvent(factory, 8080, null);
    Application app = factory.createApplication();
    assertTrue(app.getServiceUrl().matches("http://\\d{0,3}\\.\\d{0,3}\\.\\d{0,3}\\.\\d{0,3}:8080"));
}
Also used : SpringApplication(org.springframework.boot.SpringApplication) Application(de.codecentric.boot.admin.client.registration.Application) Test(org.junit.Test)

Aggregations

Application (de.codecentric.boot.admin.client.registration.Application)14 Test (org.junit.Test)14 SpringApplication (org.springframework.boot.SpringApplication)12 Ssl (org.springframework.boot.context.embedded.Ssl)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 DocumentContext (com.jayway.jsonpath.DocumentContext)1 DefaultApplicationFactory (de.codecentric.boot.admin.client.registration.DefaultApplicationFactory)1