I was trying to run Spring Boot Microservices Tests, which are explained in this article: https://blog.codecentric.de/en/2017/02/integration-testing-strategies-spring-boot-microservices-part-2/
In these tests, Spring Boot Application is started and stopped programmatically before and after each test, using Spring RestTemplate Client and Spring Boot Actuator "shutdown" endpoint.
Unfortunately, this code doesn't work in Spring Boot 2.3.1 and returns "Error 415 Unsupported Media Type"
ResponseEntity<JSONObject> response = template
.postForEntity(managementUrl + "/shutdown", "", JSONObject.class);
The application has to be killed manually in administration console after the tests.
Full source code can be found on GitLab: https://gitlab.com/dfeingol/springboot-testing-tips/-/tree/master/atdd
This is a really interesting testing strategy and a great alternative to using Spring Boot Docker Images in the tests.
Unfortunately, the article and the source code are very old and use Spring Boot 1.4.0
Does anyone know how to shutdown Spring Boot 2.3.1 application correctly, using Spring Boot Actuator "shutdown" endpoint and Spring RestTemplate Client?