Skip to content

Commit 7a23ac4

Browse files
author
markoprevisic
committed
BAEL-2351 fixed integration tests
1 parent 7e3e9db commit 7a23ac4

3 files changed

Lines changed: 20 additions & 9 deletions

File tree

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
management.endpoints.web.exposure.include=*
22
management.metrics.enable.root=true
33
management.metrics.enable.jvm=true
4-
management.endpoint.restart.enabled=true
4+
management.endpoint.restart.enabled=true
5+
spring.datasource.jmx-enabled=false
6+
spring.main.allow-bean-definition-overriding=true
7+
management.endpoint.shutdown.enabled=true

‎spring-boot-ops/src/test/java/com/baeldung/restart/RestartApplicationIntegrationTest.java‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22

33
import static org.junit.Assert.assertEquals;
44

5+
import org.junit.After;
6+
import org.junit.Before;
57
import org.junit.Test;
68
import org.springframework.boot.test.web.client.TestRestTemplate;
9+
import org.springframework.boot.web.client.RestTemplateBuilder;
710
import org.springframework.http.HttpMethod;
811
import org.springframework.http.ResponseEntity;
912

13+
import java.time.Duration;
14+
1015
public class RestartApplicationIntegrationTest {
11-
12-
private TestRestTemplate template = new TestRestTemplate();
16+
17+
private TestRestTemplate restTemplate = new TestRestTemplate();
1318

1419
@Test
1520
public void givenBootApp_whenRestart_thenOk() throws Exception {
1621
Application.main(new String[0]);
17-
18-
ResponseEntity response = template.exchange("http://localhost:8080/restart",
22+
23+
ResponseEntity response = restTemplate.exchange("http://localhost:8080/restart",
1924
HttpMethod.POST, null, Object.class);
2025

2126
assertEquals(200, response.getStatusCode().value());
@@ -24,11 +29,11 @@ public void givenBootApp_whenRestart_thenOk() throws Exception {
2429
@Test
2530
public void givenBootApp_whenRestartUsingActuator_thenOk() throws Exception {
2631
Application.main(new String[] { "--server.port=8090" });
27-
28-
ResponseEntity response = template.exchange("http://localhost:8090/restartApp",
32+
33+
ResponseEntity response = restTemplate.exchange("http://localhost:8090/restartApp",
2934
HttpMethod.POST, null, Object.class);
3035

3136
assertEquals(200, response.getStatusCode().value());
3237
}
3338

34-
}
39+
}

‎spring-boot-ops/src/test/resources/application.properties‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ management.endpoints.web.exposure.include=*
66
management.endpoint.shutdown.enabled=true
77
endpoints.shutdown.enabled=true
88

9-
management.endpoint.restart.enabled=true
9+
management.endpoint.restart.enabled=true
10+
11+
spring.main.allow-bean-definition-overriding=true
12+
spring.jmx.unique-names=true

0 commit comments

Comments
 (0)