Fix bean name of EnvironmentEndpointWebExtension
Closes gh-12827
This commit is contained in:
parent
8d81bcd101
commit
3c169b4e0a
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2017 the original author or authors.
|
* Copyright 2012-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -61,7 +61,7 @@ public class EnvironmentEndpointAutoConfiguration {
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
@ConditionalOnEnabledEndpoint
|
@ConditionalOnEnabledEndpoint
|
||||||
@ConditionalOnBean(EnvironmentEndpoint.class)
|
@ConditionalOnBean(EnvironmentEndpoint.class)
|
||||||
public EnvironmentEndpointWebExtension environmentWebEndpointExtension(
|
public EnvironmentEndpointWebExtension environmentEndpointWebExtension(
|
||||||
EnvironmentEndpoint environmentEndpoint) {
|
EnvironmentEndpoint environmentEndpoint) {
|
||||||
return new EnvironmentEndpointWebExtension(environmentEndpoint);
|
return new EnvironmentEndpointWebExtension(environmentEndpoint);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,13 @@ import java.util.Map;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
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.actuate.autoconfigure.web.server.LocalManagementPort;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
import org.springframework.boot.web.server.LocalServerPort;
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
@ -49,6 +51,9 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
|
||||||
@LocalManagementPort
|
@LocalManagementPort
|
||||||
private int managementPort = 9011;
|
private int managementPort = 9011;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Environment environment;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHome() {
|
public void testHome() {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
|
|
@ -79,6 +84,17 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
|
||||||
assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}");
|
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
|
@Test
|
||||||
public void testMissing() {
|
public void testMissing() {
|
||||||
ResponseEntity<String> entity = new TestRestTemplate("user", getPassword())
|
ResponseEntity<String> entity = new TestRestTemplate("user", getPassword())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue