diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/resources/application.properties | 2 | ||||
-rw-r--r-- | src/test/java/org/onap/aai/modelloader/actuator/ActuatorTest.java | 45 |
2 files changed, 33 insertions, 14 deletions
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index d3b4f45..ab5186a 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -29,3 +29,5 @@ server.tomcat.threads.min-spare=25 # Spring Boot logging logging.config=${logback.configurationFile} + +management.endpoints.web.exposure.include=* diff --git a/src/test/java/org/onap/aai/modelloader/actuator/ActuatorTest.java b/src/test/java/org/onap/aai/modelloader/actuator/ActuatorTest.java index e9a6da5..2ccbb0c 100644 --- a/src/test/java/org/onap/aai/modelloader/actuator/ActuatorTest.java +++ b/src/test/java/org/onap/aai/modelloader/actuator/ActuatorTest.java @@ -19,29 +19,46 @@ */ package org.onap.aai.modelloader.actuator; -import static org.junit.jupiter.api.Assertions.assertEquals; - import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestTemplate; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.web.reactive.server.WebTestClient; +@AutoConfigureWebTestClient +@TestPropertySource(properties = { + "management.endpoints.web.exposure.include=prometheus,metrics,info,health" +}) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) public class ActuatorTest { - - @Autowired RestTemplate restTemplate; - @LocalServerPort - private int serverPort; + + @Autowired + private WebTestClient webTestClient; @Test public void thatLivenessEndpointReturnsOk() { - String url = String.format("http://localhost:%s/actuator/health", serverPort); - ResponseEntity<String> entity = restTemplate.getForEntity(url, String.class); - assertEquals(entity.getStatusCode(), HttpStatus.OK); - assertEquals(entity.getBody(), "{\"status\":\"UP\"}"); + webTestClient.get().uri("/actuator/health") + .exchange() + .expectStatus().isOk() + .expectBody() + .jsonPath("$.status") + .isEqualTo("UP"); } + + // @Test + // public void testPrometheusEndpoint() { + // webTestClient.get().uri("/actuator/prometheus") + // .exchange() + // .expectStatus().isOk() + // .expectHeader().contentType("text/plain; charset=utf-8") + // .expectBody(String.class) + // .consumeWith(response -> { + // String responseBody = response.getResponseBody(); + // assert responseBody != null; + // assert responseBody.contains("# HELP"); + // assert responseBody.contains("# TYPE"); + // }); + // } } |