From 9bff1548d1e639df7ef109e45e3e7bb8af6307a6 Mon Sep 17 00:00:00 2001 From: Ramachandran Nellaiyappan Date: Sun, 10 Mar 2024 15:29:19 +0100 Subject: [PATCH] [feat] #1 spring actuator added to monitor application health --- pom.xml | 5 +++++ .../dev/journey/api/JourneyApiApplicationTests.java | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4afbd58e..e2aaf954 100644 --- a/pom.xml +++ b/pom.xml @@ -27,6 +27,11 @@ spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-actuator + + org.springframework.boot spring-boot-devtools diff --git a/src/test/java/com/github/nramc/dev/journey/api/JourneyApiApplicationTests.java b/src/test/java/com/github/nramc/dev/journey/api/JourneyApiApplicationTests.java index 28898af8..9e0e0ef5 100644 --- a/src/test/java/com/github/nramc/dev/journey/api/JourneyApiApplicationTests.java +++ b/src/test/java/com/github/nramc/dev/journey/api/JourneyApiApplicationTests.java @@ -5,15 +5,24 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; +import org.springframework.test.web.reactive.server.WebTestClient; -@SpringBootTest +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) class JourneyApiApplicationTests { @Autowired private ApplicationContext applicationContext; + @Autowired + private WebTestClient webTestClient; @Test void contextLoads() { Assertions.assertNotNull(applicationContext); } + @Test + void testHealthCheckEndpoint() { + webTestClient.get().uri("/actuator/health").exchange() + .expectStatus().isOk(); + } + }