diff --git a/spring-boot-ops/src/main/resources/application.properties b/spring-boot-ops/src/main/resources/application.properties index 644a3edabc..27b7915cff 100644 --- a/spring-boot-ops/src/main/resources/application.properties +++ b/spring-boot-ops/src/main/resources/application.properties @@ -1,4 +1,7 @@ management.endpoints.web.exposure.include=* management.metrics.enable.root=true management.metrics.enable.jvm=true -management.endpoint.restart.enabled=true \ No newline at end of file +management.endpoint.restart.enabled=true +spring.datasource.jmx-enabled=false +spring.main.allow-bean-definition-overriding=true +management.endpoint.shutdown.enabled=true \ No newline at end of file diff --git a/spring-boot-ops/src/test/java/com/baeldung/restart/RestartApplicationIntegrationTest.java b/spring-boot-ops/src/test/java/com/baeldung/restart/RestartApplicationIntegrationTest.java index 1bec3c6a90..14e80c3ac7 100644 --- a/spring-boot-ops/src/test/java/com/baeldung/restart/RestartApplicationIntegrationTest.java +++ b/spring-boot-ops/src/test/java/com/baeldung/restart/RestartApplicationIntegrationTest.java @@ -2,20 +2,25 @@ package com.baeldung.restart; import static org.junit.Assert.assertEquals; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; +import java.time.Duration; + public class RestartApplicationIntegrationTest { - - private TestRestTemplate template = new TestRestTemplate(); + + private TestRestTemplate restTemplate = new TestRestTemplate(); @Test public void givenBootApp_whenRestart_thenOk() throws Exception { Application.main(new String[0]); - - ResponseEntity response = template.exchange("http://localhost:8080/restart", + + ResponseEntity response = restTemplate.exchange("http://localhost:8080/restart", HttpMethod.POST, null, Object.class); assertEquals(200, response.getStatusCode().value()); @@ -24,11 +29,11 @@ public class RestartApplicationIntegrationTest { @Test public void givenBootApp_whenRestartUsingActuator_thenOk() throws Exception { Application.main(new String[] { "--server.port=8090" }); - - ResponseEntity response = template.exchange("http://localhost:8090/restartApp", + + ResponseEntity response = restTemplate.exchange("http://localhost:8090/restartApp", HttpMethod.POST, null, Object.class); assertEquals(200, response.getStatusCode().value()); } -} +} \ No newline at end of file diff --git a/spring-boot-ops/src/test/resources/application.properties b/spring-boot-ops/src/test/resources/application.properties index 0adf2998d7..cf0f0ab74c 100644 --- a/spring-boot-ops/src/test/resources/application.properties +++ b/spring-boot-ops/src/test/resources/application.properties @@ -6,4 +6,7 @@ management.endpoints.web.exposure.include=* management.endpoint.shutdown.enabled=true endpoints.shutdown.enabled=true -management.endpoint.restart.enabled=true \ No newline at end of file +management.endpoint.restart.enabled=true + +spring.main.allow-bean-definition-overriding=true +spring.jmx.unique-names=true \ No newline at end of file