[bs-148] Add /env endpoint for Spring Environment

Any enumerable property source is enumerated.  Plus all
properties are available through /env/{name}.

[Fixes #51141441]
This commit is contained in:
Dave Syer
2013-06-07 13:29:35 +01:00
parent 6c5f9a5961
commit 4ee6a90edd
5 changed files with 157 additions and 2 deletions

View File

@@ -97,6 +97,28 @@ public class ServiceBootstrapApplicationTests {
assertTrue("Wrong body: " + body, body.containsKey("counter.status.200.root"));
}
@Test
public void testEnv() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = getRestTemplate("user", "password").getForEntity(
"http://localhost:8080/env", Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
assertTrue("Wrong body: " + body, body.containsKey("systemProperties"));
}
@Test
public void testEnvProperty() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = getRestTemplate("user", "password").getForEntity(
"http://localhost:8080/env/logging.file", Map.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
assertEquals("{logging.file=/tmp/logs/app.log}", body.toString());
}
@Test
public void testHealth() throws Exception {
ResponseEntity<String> entity = getRestTemplate().getForEntity(