From 847f6d1b2ce2f046192eff4f927a5535d13af8a3 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 1 Aug 2017 09:03:23 +0100 Subject: [PATCH] Update test in Actuator sample to adapt to changes in env response See gh-9864 --- .../SampleActuatorApplicationTests.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java index 4f2a3f6432..1e9a9fd63b 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java @@ -98,7 +98,8 @@ public class SampleActuatorApplicationTests { testHome(); // makes sure some requests have been made @SuppressWarnings("rawtypes") ResponseEntity entity = this.restTemplate - .withBasicAuth("user", getPassword()).getForEntity("/application/metrics", Map.class); + .withBasicAuth("user", getPassword()) + .getForEntity("/application/metrics", Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); @SuppressWarnings("unchecked") Map body = entity.getBody(); @@ -109,17 +110,18 @@ public class SampleActuatorApplicationTests { public void testEnv() throws Exception { @SuppressWarnings("rawtypes") ResponseEntity entity = this.restTemplate - .withBasicAuth("user", getPassword()).getForEntity("/application/env", Map.class); + .withBasicAuth("user", getPassword()) + .getForEntity("/application/env", Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); @SuppressWarnings("unchecked") Map body = entity.getBody(); - assertThat(body).containsKey("systemProperties"); + assertThat(body).containsKey("propertySources"); } @Test public void testHealth() throws Exception { - ResponseEntity entity = this.restTemplate.getForEntity("/application/health", - String.class); + ResponseEntity entity = this.restTemplate + .getForEntity("/application/health", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).contains("\"status\":\"UP\""); assertThat(entity.getBody()).doesNotContain("\"hello\":\"1\""); @@ -136,8 +138,8 @@ public class SampleActuatorApplicationTests { @Test public void testInfo() throws Exception { - ResponseEntity entity = this.restTemplate.getForEntity("/application/info", - String.class); + ResponseEntity entity = this.restTemplate + .getForEntity("/application/info", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()) .contains("\"artifact\":\"spring-boot-sample-actuator\""); @@ -176,7 +178,8 @@ public class SampleActuatorApplicationTests { this.restTemplate.getForEntity("/health", String.class); @SuppressWarnings("rawtypes") ResponseEntity entity = this.restTemplate - .withBasicAuth("user", getPassword()).getForEntity("/application/trace", List.class); + .withBasicAuth("user", getPassword()) + .getForEntity("/application/trace", List.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); @SuppressWarnings("unchecked") List> list = entity.getBody(); @@ -192,7 +195,8 @@ public class SampleActuatorApplicationTests { this.restTemplate.getForEntity("/application/health?param1=value1", String.class); @SuppressWarnings("rawtypes") ResponseEntity entity = this.restTemplate - .withBasicAuth("user", getPassword()).getForEntity("/application/trace", List.class); + .withBasicAuth("user", getPassword()) + .getForEntity("/application/trace", List.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); @SuppressWarnings("unchecked") List> list = entity.getBody(); @@ -219,7 +223,8 @@ public class SampleActuatorApplicationTests { public void testBeans() throws Exception { @SuppressWarnings("rawtypes") ResponseEntity entity = this.restTemplate - .withBasicAuth("user", getPassword()).getForEntity("/application/beans", List.class); + .withBasicAuth("user", getPassword()) + .getForEntity("/application/beans", List.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).hasSize(1); Map body = (Map) entity.getBody().get(0);