Restore use of management.health.*.enabled keys

The move of health.* keys to management.health.* broke them as they
are not defined as configuration keys and `ManagementServerProperties`
is strict on the whole management namespace.

This commit updates the tests to actually include that properties class
and relax the "ignoreUnknownFields" condition so that extra attributes
can be defined on the "management" namespace.

Fixes gh-2115
This commit is contained in:
Stephane Nicoll 2014-12-11 15:28:28 +01:00
parent 43fb5b63a8
commit f8141cbb95
2 changed files with 14 additions and 2 deletions

View File

@ -33,7 +33,7 @@ import org.springframework.util.ClassUtils;
* @author Dave Syer
* @see ServerProperties
*/
@ConfigurationProperties(prefix = "management", ignoreUnknownFields = false)
@ConfigurationProperties(prefix = "management", ignoreUnknownFields = true)
public class ManagementServerProperties implements SecurityPrequisite {
private static final String SECURITY_CHECK_CLASS = "org.springframework.security.config.http.SessionCreationPolicy";

View File

@ -76,7 +76,8 @@ public class HealthIndicatorAutoConfigurationTests {
@Test
public void defaultHealthIndicator() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(HealthIndicatorAutoConfiguration.class);
this.context.register(HealthIndicatorAutoConfiguration.class,
ManagementServerProperties.class);
EnvironmentTestUtils.addEnvironment(this.context,
"management.health.diskspace.enabled:false");
this.context.refresh();
@ -91,6 +92,7 @@ public class HealthIndicatorAutoConfigurationTests {
public void redisHealthIndicator() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(RedisAutoConfiguration.class,
ManagementServerProperties.class,
HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"management.health.diskspace.enabled:false");
@ -106,6 +108,7 @@ public class HealthIndicatorAutoConfigurationTests {
public void notRedisHealthIndicator() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(RedisAutoConfiguration.class,
ManagementServerProperties.class,
HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"management.health.redis.enabled:false",
@ -122,6 +125,7 @@ public class HealthIndicatorAutoConfigurationTests {
public void mongoHealthIndicator() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(MongoAutoConfiguration.class,
ManagementServerProperties.class,
MongoDataAutoConfiguration.class, HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"management.health.diskspace.enabled:false");
@ -137,6 +141,7 @@ public class HealthIndicatorAutoConfigurationTests {
public void notMongoHealthIndicator() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(MongoAutoConfiguration.class,
ManagementServerProperties.class,
MongoDataAutoConfiguration.class, HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"management.health.mongo.enabled:false",
@ -165,6 +170,7 @@ public class HealthIndicatorAutoConfigurationTests {
public void dataSourceHealthIndicator() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(EmbeddedDataSourceConfiguration.class,
ManagementServerProperties.class,
HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"management.health.diskspace.enabled:false");
@ -180,6 +186,7 @@ public class HealthIndicatorAutoConfigurationTests {
public void dataSourceHealthIndicatorWithCustomValidationQuery() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(PropertyPlaceholderAutoConfiguration.class,
ManagementServerProperties.class,
DataSourceProperties.class, DataSourceConfig.class,
DataSourcePoolMetadataProvidersConfiguration.class,
HealthIndicatorAutoConfiguration.class);
@ -200,6 +207,7 @@ public class HealthIndicatorAutoConfigurationTests {
public void notDataSourceHealthIndicator() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(EmbeddedDataSourceConfiguration.class,
ManagementServerProperties.class,
HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"management.health.db.enabled:false",
@ -216,6 +224,7 @@ public class HealthIndicatorAutoConfigurationTests {
public void rabbitHealthIndicator() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(RabbitAutoConfiguration.class,
ManagementServerProperties.class,
HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"management.health.diskspace.enabled:false");
@ -231,6 +240,7 @@ public class HealthIndicatorAutoConfigurationTests {
public void notRabbitHealthIndicator() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(RabbitAutoConfiguration.class,
ManagementServerProperties.class,
HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"management.health.rabbit.enabled:false",
@ -247,6 +257,7 @@ public class HealthIndicatorAutoConfigurationTests {
public void solrHeathIndicator() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(SolrAutoConfiguration.class,
ManagementServerProperties.class,
HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"management.health.diskspace.enabled:false");
@ -262,6 +273,7 @@ public class HealthIndicatorAutoConfigurationTests {
public void notSolrHeathIndicator() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(SolrAutoConfiguration.class,
ManagementServerProperties.class,
HealthIndicatorAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"management.health.solr.enabled:false",