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
pull/2134/head
Stephane Nicoll 10 years ago
parent 43fb5b63a8
commit f8141cbb95

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

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

Loading…
Cancel
Save