Skip to content

Commit 847f6d1

Browse files
committed
Update test in Actuator sample to adapt to changes in env response
See gh-9864
1 parent 8f42007 commit 847f6d1

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ public void testMetrics() throws Exception {
9898
testHome(); // makes sure some requests have been made
9999
@SuppressWarnings("rawtypes")
100100
ResponseEntity<Map> entity = this.restTemplate
101-
.withBasicAuth("user", getPassword()).getForEntity("/application/metrics", Map.class);
101+
.withBasicAuth("user", getPassword())
102+
.getForEntity("/application/metrics", Map.class);
102103
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
103104
@SuppressWarnings("unchecked")
104105
Map<String, Object> body = entity.getBody();
@@ -109,17 +110,18 @@ public void testMetrics() throws Exception {
109110
public void testEnv() throws Exception {
110111
@SuppressWarnings("rawtypes")
111112
ResponseEntity<Map> entity = this.restTemplate
112-
.withBasicAuth("user", getPassword()).getForEntity("/application/env", Map.class);
113+
.withBasicAuth("user", getPassword())
114+
.getForEntity("/application/env", Map.class);
113115
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
114116
@SuppressWarnings("unchecked")
115117
Map<String, Object> body = entity.getBody();
116-
assertThat(body).containsKey("systemProperties");
118+
assertThat(body).containsKey("propertySources");
117119
}
118120

119121
@Test
120122
public void testHealth() throws Exception {
121-
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/health",
122-
String.class);
123+
ResponseEntity<String> entity = this.restTemplate
124+
.getForEntity("/application/health", String.class);
123125
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
124126
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
125127
assertThat(entity.getBody()).doesNotContain("\"hello\":\"1\"");
@@ -136,8 +138,8 @@ public void testSecureHealth() throws Exception {
136138

137139
@Test
138140
public void testInfo() throws Exception {
139-
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/info",
140-
String.class);
141+
ResponseEntity<String> entity = this.restTemplate
142+
.getForEntity("/application/info", String.class);
141143
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
142144
assertThat(entity.getBody())
143145
.contains("\"artifact\":\"spring-boot-sample-actuator\"");
@@ -176,7 +178,8 @@ public void testTrace() throws Exception {
176178
this.restTemplate.getForEntity("/health", String.class);
177179
@SuppressWarnings("rawtypes")
178180
ResponseEntity<List> entity = this.restTemplate
179-
.withBasicAuth("user", getPassword()).getForEntity("/application/trace", List.class);
181+
.withBasicAuth("user", getPassword())
182+
.getForEntity("/application/trace", List.class);
180183
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
181184
@SuppressWarnings("unchecked")
182185
List<Map<String, Object>> list = entity.getBody();
@@ -192,7 +195,8 @@ public void traceWithParameterMap() throws Exception {
192195
this.restTemplate.getForEntity("/application/health?param1=value1", String.class);
193196
@SuppressWarnings("rawtypes")
194197
ResponseEntity<List> entity = this.restTemplate
195-
.withBasicAuth("user", getPassword()).getForEntity("/application/trace", List.class);
198+
.withBasicAuth("user", getPassword())
199+
.getForEntity("/application/trace", List.class);
196200
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
197201
@SuppressWarnings("unchecked")
198202
List<Map<String, Object>> list = entity.getBody();
@@ -219,7 +223,8 @@ public void testErrorPageDirectAccess() throws Exception {
219223
public void testBeans() throws Exception {
220224
@SuppressWarnings("rawtypes")
221225
ResponseEntity<List> entity = this.restTemplate
222-
.withBasicAuth("user", getPassword()).getForEntity("/application/beans", List.class);
226+
.withBasicAuth("user", getPassword())
227+
.getForEntity("/application/beans", List.class);
223228
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
224229
assertThat(entity.getBody()).hasSize(1);
225230
Map<String, Object> body = (Map<String, Object>) entity.getBody().get(0);

0 commit comments

Comments
 (0)