-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for actuator health endpoint
- Loading branch information
Bas Huisman
committed
Nov 19, 2024
1 parent
f1e616b
commit 85ba773
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package nl.ictu; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.web.client.TestRestTemplate; | ||
import org.springframework.boot.test.web.server.LocalServerPort; | ||
import org.springframework.test.context.ActiveProfiles; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@ActiveProfiles("test") | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) | ||
class TestingWebApplicationTests { | ||
|
||
@LocalServerPort | ||
private int port; | ||
|
||
@Value("${management.server.port}") | ||
private int actuatorPort; | ||
|
||
@Autowired | ||
private TestRestTemplate restTemplate; | ||
|
||
@Test | ||
public void contextLoads() { | ||
} | ||
|
||
@Test | ||
public void testActuatorHealthEndpoint() throws Exception { | ||
assertThat( | ||
restTemplate | ||
.getForObject("http://localhost:" + actuatorPort + "/monitor/health", String.class) | ||
).contains("{\"status\":\"UP\"}"); | ||
} | ||
|
||
} |