Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
bhuism committed Jan 20, 2025
1 parent 6adfa2c commit d11a599
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/test/java/nl/appsource/TestingWebApplicationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.test.web.server.LocalManagementPort;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
Expand All @@ -32,17 +33,18 @@ class TestingWebApplicationTests {
private Environment environment;
@Autowired
private TestRestTemplate restTemplate;
@LocalManagementPort
private int actuatorPort;

@Test
@DisplayName("""
Given the Spring Boot application is running with actuator enabled
When accessing the /actuator/health endpoint
When accessing the /manage/health endpoint
Then the response should contain a status of 'UP'
""")
void testActuatorHealthEndpoint() {
final int actuatorPort = environment.getProperty("local.management.port", Integer.class);
assertThat(
restTemplate.getForObject("http://localhost:" + actuatorPort + "/actuator/health",
restTemplate.getForObject("http://localhost:" + actuatorPort + "/manage/health",
String.class)
).contains("{\"status\":\"UP\"}");
}
Expand Down

0 comments on commit d11a599

Please sign in to comment.