From 2fd2f99c9da2188a5b41cc0d54708df1789fbdb5 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Fri, 20 Oct 2017 11:18:30 +0100 Subject: [PATCH] Suppress use of configuration properties source in refresh --- .../context/refresh/ContextRefresher.java | 7 +++- .../springframework/cloud/AdhocTestSuite.java | 36 +++++++++++++++++++ .../RefreshEndpointIntegrationTests.java | 6 +++- .../cloud/endpoint/RefreshEndpointTests.java | 2 ++ 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 spring-cloud-context/src/test/java/org/springframework/cloud/AdhocTestSuite.java diff --git a/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/ContextRefresher.java b/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/ContextRefresher.java index f2e3aba1..0d1fc7b8 100644 --- a/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/ContextRefresher.java +++ b/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/ContextRefresher.java @@ -39,7 +39,8 @@ public class ContextRefresher { StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, StandardServletEnvironment.JNDI_PROPERTY_SOURCE_NAME, StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME, - StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME)); + StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME, + "configurationProperties")); private ConfigurableApplicationContext context; private RefreshScope scope; @@ -118,6 +119,10 @@ public class ContextRefresher { capturedPropertySources.remove(source.getName()); } for (PropertySource source : input.getPropertySources()) { + if ("configurationProperties".equals(source.getName())) { + // Spring Boot artifact, tracking values in the other sources + continue; + } capturedPropertySources.addLast(source); } environment.setActiveProfiles(input.getActiveProfiles()); diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/AdhocTestSuite.java b/spring-cloud-context/src/test/java/org/springframework/cloud/AdhocTestSuite.java new file mode 100644 index 00000000..8ed21a9a --- /dev/null +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/AdhocTestSuite.java @@ -0,0 +1,36 @@ +/* + * Copyright 2012-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud; + +import org.junit.Ignore; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; +import org.springframework.cloud.context.refresh.ContextRefresherTests; +import org.springframework.cloud.endpoint.RefreshEndpointTests; + +/** + * A test suite for probing weird ordering problems in the tests. + * + * @author Dave Syer + */ +@RunWith(Suite.class) +@SuiteClasses({ RefreshEndpointTests.class, ContextRefresherTests.class }) +@Ignore +public class AdhocTestSuite { + +} diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshEndpointIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshEndpointIntegrationTests.java index f22ecac9..c3af6f40 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshEndpointIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshEndpointIntegrationTests.java @@ -97,8 +97,12 @@ public class RefreshEndpointIntegrationTests { @RestController protected static class Controller { - @Value("${message:Hello World!}") String message; + + @Value("${message:Hello World!}") + public void setMessage(String message) { + this.message = message; + } @RequestMapping("/") public String hello() { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/endpoint/RefreshEndpointTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/endpoint/RefreshEndpointTests.java index 80b79276..66b53a45 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/endpoint/RefreshEndpointTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/endpoint/RefreshEndpointTests.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.Map; import org.junit.After; +import org.junit.Ignore; import org.junit.Test; import org.springframework.boot.Banner.Mode; import org.springframework.boot.WebApplicationType; @@ -93,6 +94,7 @@ public class RefreshEndpointTests { } @Test + // @Ignore public void keysComputedWhenChangesInExternalProperties() throws Exception { this.context = new SpringApplicationBuilder(Empty.class) .web(WebApplicationType.NONE).bannerMode(Mode.OFF)