Fix bean name of EnvironmentEndpointWebExtension

Closes gh-12827
This commit is contained in:
Stephane Nicoll
2018-04-11 11:34:44 +02:00
parent 8d81bcd101
commit 3c169b4e0a
2 changed files with 18 additions and 2 deletions

View File

@@ -21,11 +21,13 @@ import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
@@ -49,6 +51,9 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
@LocalManagementPort
private int managementPort = 9011;
@Autowired
private Environment environment;
@Test
public void testHome() {
@SuppressWarnings("rawtypes")
@@ -79,6 +84,17 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}");
}
@Test
public void testEnvNotFound() {
String unknownProperty = "test-does-not-exist";
assertThat(this.environment.containsProperty(unknownProperty)).isFalse();
ResponseEntity<String> entity = new TestRestTemplate()
.withBasicAuth("user", getPassword()).getForEntity(
"http://localhost:" + this.managementPort + "/admin/env/" + unknownProperty,
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}
@Test
public void testMissing() {
ResponseEntity<String> entity = new TestRestTemplate("user", getPassword())