Skip to content

Commit 3c169b4

Browse files
committed
Fix bean name of EnvironmentEndpointWebExtension
Closes spring-projectsgh-12827
1 parent 8d81bcd commit 3c169b4

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/env/EnvironmentEndpointAutoConfiguration.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -61,7 +61,7 @@ public EnvironmentEndpoint environmentEndpoint(Environment environment) {
6161
@ConditionalOnMissingBean
6262
@ConditionalOnEnabledEndpoint
6363
@ConditionalOnBean(EnvironmentEndpoint.class)
64-
public EnvironmentEndpointWebExtension environmentWebEndpointExtension(
64+
public EnvironmentEndpointWebExtension environmentEndpointWebExtension(
6565
EnvironmentEndpoint environmentEndpoint) {
6666
return new EnvironmentEndpointWebExtension(environmentEndpoint);
6767
}

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

+16
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@
2121
import org.junit.Test;
2222
import org.junit.runner.RunWith;
2323

24+
import org.springframework.beans.factory.annotation.Autowired;
2425
import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort;
2526
import org.springframework.boot.test.context.SpringBootTest;
2627
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
2728
import org.springframework.boot.test.web.client.TestRestTemplate;
2829
import org.springframework.boot.web.server.LocalServerPort;
30+
import org.springframework.core.env.Environment;
2931
import org.springframework.http.HttpStatus;
3032
import org.springframework.http.ResponseEntity;
3133
import org.springframework.test.context.junit4.SpringRunner;
@@ -49,6 +51,9 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
4951
@LocalManagementPort
5052
private int managementPort = 9011;
5153

54+
@Autowired
55+
private Environment environment;
56+
5257
@Test
5358
public void testHome() {
5459
@SuppressWarnings("rawtypes")
@@ -79,6 +84,17 @@ public void testHealth() {
7984
assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}");
8085
}
8186

87+
@Test
88+
public void testEnvNotFound() {
89+
String unknownProperty = "test-does-not-exist";
90+
assertThat(this.environment.containsProperty(unknownProperty)).isFalse();
91+
ResponseEntity<String> entity = new TestRestTemplate()
92+
.withBasicAuth("user", getPassword()).getForEntity(
93+
"http://localhost:" + this.managementPort + "/admin/env/" + unknownProperty,
94+
String.class);
95+
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
96+
}
97+
8298
@Test
8399
public void testMissing() {
84100
ResponseEntity<String> entity = new TestRestTemplate("user", getPassword())

0 commit comments

Comments
 (0)