BAEL-2351 fixed integration tests

This commit is contained in:
markoprevisic 2018-12-13 15:12:23 +01:00
parent 7e3e9db288
commit 7a23ac4f53
3 changed files with 20 additions and 9 deletions

View File

@ -1,4 +1,7 @@
management.endpoints.web.exposure.include=* management.endpoints.web.exposure.include=*
management.metrics.enable.root=true management.metrics.enable.root=true
management.metrics.enable.jvm=true management.metrics.enable.jvm=true
management.endpoint.restart.enabled=true management.endpoint.restart.enabled=true
spring.datasource.jmx-enabled=false
spring.main.allow-bean-definition-overriding=true
management.endpoint.shutdown.enabled=true

View File

@ -2,20 +2,25 @@ package com.baeldung.restart;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import org.junit.After;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import java.time.Duration;
public class RestartApplicationIntegrationTest { public class RestartApplicationIntegrationTest {
private TestRestTemplate template = new TestRestTemplate(); private TestRestTemplate restTemplate = new TestRestTemplate();
@Test @Test
public void givenBootApp_whenRestart_thenOk() throws Exception { public void givenBootApp_whenRestart_thenOk() throws Exception {
Application.main(new String[0]); 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); HttpMethod.POST, null, Object.class);
assertEquals(200, response.getStatusCode().value()); assertEquals(200, response.getStatusCode().value());
@ -24,11 +29,11 @@ public class RestartApplicationIntegrationTest {
@Test @Test
public void givenBootApp_whenRestartUsingActuator_thenOk() throws Exception { public void givenBootApp_whenRestartUsingActuator_thenOk() throws Exception {
Application.main(new String[] { "--server.port=8090" }); 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); HttpMethod.POST, null, Object.class);
assertEquals(200, response.getStatusCode().value()); assertEquals(200, response.getStatusCode().value());
} }
} }

View File

@ -6,4 +6,7 @@ management.endpoints.web.exposure.include=*
management.endpoint.shutdown.enabled=true management.endpoint.shutdown.enabled=true
endpoints.shutdown.enabled=true endpoints.shutdown.enabled=true
management.endpoint.restart.enabled=true management.endpoint.restart.enabled=true
spring.main.allow-bean-definition-overriding=true
spring.jmx.unique-names=true