Browse Source

Restores bootstrap functionality.

pull/1025/merge
spencergibb 3 years ago
parent
commit
0d7722dec8
No known key found for this signature in database
GPG Key ID: 7788A47380690861
  1. 5
      spring-cloud-commons/src/main/java/org/springframework/cloud/client/HostInfoEnvironmentPostProcessor.java
  2. 992
      spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/BootstrapConfigFileApplicationListener.java
  3. 4
      spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/config/PropertySourceBootstrapConfiguration.java
  4. 1
      spring-cloud-context/src/main/resources/META-INF/spring.factories
  5. 2
      spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingAutoConfigurationIntegrationTests.java
  6. 2
      spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomOverrideSystemPropertiesIntegrationTests.java
  7. 2
      spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomPropertySourceIntegrationTests.java
  8. 2
      spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapSourcesOrderingTests.java
  9. 45
      spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapConfigurationTests.java
  10. 7
      spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapListenerHierarchyIntegrationTests.java
  11. 4
      spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionIntegrationTests.java
  12. 2
      spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderIntegrationTests.java
  13. 2
      spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderRefreshScopeIntegrationTests.java
  14. 2
      spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherIntegrationTests.java
  15. 2
      spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherOrderingIntegrationTests.java
  16. 23
      spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java
  17. 2
      spring-cloud-context/src/test/java/org/springframework/cloud/context/restart/RestartIntegrationTests.java
  18. 2
      spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeSerializationTests.java
  19. 6
      spring-cloud-context/src/test/java/org/springframework/cloud/endpoint/RefreshEndpointTests.java

5
spring-cloud-commons/src/main/java/org/springframework/cloud/client/HostInfoEnvironmentPostProcessor.java

@ -19,7 +19,6 @@ package org.springframework.cloud.client; @@ -19,7 +19,6 @@ package org.springframework.cloud.client;
import java.util.LinkedHashMap;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.config.ConfigFileApplicationListener;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
@ -36,8 +35,8 @@ import org.springframework.core.env.MapPropertySource; @@ -36,8 +35,8 @@ import org.springframework.core.env.MapPropertySource;
*/
public class HostInfoEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {
// Before ConfigFileApplicationListener
private int order = ConfigFileApplicationListener.DEFAULT_ORDER - 1;
// Before BootstrapConfigFileApplicationListener
private int order = Ordered.HIGHEST_PRECEDENCE + 9;
@Override
public int getOrder() {

992
spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/BootstrapConfigFileApplicationListener.java

File diff suppressed because it is too large Load Diff

4
spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/config/PropertySourceBootstrapConfiguration.java

@ -28,7 +28,6 @@ import org.apache.commons.logging.Log; @@ -28,7 +28,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.config.ConfigFileApplicationListener;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.context.properties.bind.Bindable;
import org.springframework.boot.context.properties.bind.Binder;
@ -36,6 +35,7 @@ import org.springframework.boot.logging.LogFile; @@ -36,6 +35,7 @@ import org.springframework.boot.logging.LogFile;
import org.springframework.boot.logging.LoggingInitializationContext;
import org.springframework.boot.logging.LoggingSystem;
import org.springframework.cloud.bootstrap.BootstrapApplicationListener;
import org.springframework.cloud.bootstrap.BootstrapConfigFileApplicationListener;
import org.springframework.cloud.context.environment.EnvironmentChangeEvent;
import org.springframework.cloud.logging.LoggingRebinder;
import org.springframework.context.ApplicationContextInitializer;
@ -239,7 +239,7 @@ public class PropertySourceBootstrapConfiguration @@ -239,7 +239,7 @@ public class PropertySourceBootstrapConfiguration
}
else {
Collections.addAll(profiles, getProfilesForValue(
propertySource.getProperty(ConfigFileApplicationListener.INCLUDE_PROFILES_PROPERTY)));
propertySource.getProperty(BootstrapConfigFileApplicationListener.INCLUDE_PROFILES_PROPERTY)));
}
return profiles;
}

1
spring-cloud-context/src/main/resources/META-INF/spring.factories

@ -22,5 +22,6 @@ org.springframework.cloud.bootstrap.RefreshBootstrapRegistryInitializer,\ @@ -22,5 +22,6 @@ org.springframework.cloud.bootstrap.RefreshBootstrapRegistryInitializer,\
org.springframework.cloud.bootstrap.TextEncryptorConfigBootstrapper
# Environment Post Processors
org.springframework.boot.env.EnvironmentPostProcessor=\
org.springframework.cloud.bootstrap.BootstrapConfigFileApplicationListener,\
org.springframework.cloud.bootstrap.encrypt.DecryptEnvironmentPostProcessor,\
org.springframework.cloud.util.random.CachedRandomPropertySourceEnvironmentPostProcessor

2
spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingAutoConfigurationIntegrationTests.java

@ -29,7 +29,7 @@ import org.springframework.test.context.ActiveProfiles; @@ -29,7 +29,7 @@ import org.springframework.test.context.ActiveProfiles;
import static org.assertj.core.api.BDDAssertions.then;
@SpringBootTest(classes = Application.class,
properties = { "encrypt.key:deadbeef", "spring.config.use-legacy-processing=true" })
properties = { "encrypt.key:deadbeef", "spring.cloud.bootstrap.enabled=true" })
@ActiveProfiles("encrypt")
public class BootstrapOrderingAutoConfigurationIntegrationTests {

2
spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomOverrideSystemPropertiesIntegrationTests.java

@ -39,7 +39,7 @@ import static java.util.Collections.singletonMap; @@ -39,7 +39,7 @@ import static java.util.Collections.singletonMap;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(classes = Application.class,
properties = { "spring.config.use-legacy-processing=true", "spring.cloud.bootstrap.name:ordering" })
properties = { "spring.cloud.bootstrap.enabled=true", "spring.cloud.bootstrap.name:ordering" })
public class BootstrapOrderingCustomOverrideSystemPropertiesIntegrationTests {
@Autowired

2
spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapOrderingCustomPropertySourceIntegrationTests.java

@ -37,7 +37,7 @@ import org.springframework.test.context.ActiveProfiles; @@ -37,7 +37,7 @@ import org.springframework.test.context.ActiveProfiles;
import static org.assertj.core.api.BDDAssertions.then;
@SpringBootTest(classes = Application.class, properties = { "encrypt.key:deadbeef",
"spring.cloud.bootstrap.name:custom", "spring.config.use-legacy-processing=true" })
"spring.cloud.bootstrap.name:custom", "spring.cloud.bootstrap.enabled=true" })
@ActiveProfiles("encrypt")
public class BootstrapOrderingCustomPropertySourceIntegrationTests {

2
spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/BootstrapSourcesOrderingTests.java

@ -26,7 +26,7 @@ import org.springframework.context.annotation.Configuration; @@ -26,7 +26,7 @@ import org.springframework.context.annotation.Configuration;
import static org.assertj.core.api.BDDAssertions.then;
import static org.springframework.cloud.bootstrap.TestHigherPriorityBootstrapConfiguration.firstToBeCreated;
@SpringBootTest(classes = Application.class, properties = "spring.config.use-legacy-processing=true")
@SpringBootTest(classes = Application.class, properties = "spring.cloud.bootstrap.enabled=true")
public class BootstrapSourcesOrderingTests {
@Test

45
spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapConfigurationTests.java

@ -80,7 +80,7 @@ public class BootstrapConfigurationTests { @@ -80,7 +80,7 @@ public class BootstrapConfigurationTests {
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE).sources(BareConfiguration.class)
.properties("spring.cloud.bootstrap.location=" + externalPropertiesPath,
"spring.config.use-legacy-processing=true")
"spring.cloud.bootstrap.enabled=true")
.run();
then(this.context.getEnvironment().getProperty("info.name")).isEqualTo("externalPropertiesInfoName");
then(this.context.getEnvironment().getProperty("info.desc")).isNull();
@ -95,7 +95,7 @@ public class BootstrapConfigurationTests { @@ -95,7 +95,7 @@ public class BootstrapConfigurationTests {
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE).sources(BareConfiguration.class)
.properties("spring.cloud.bootstrap.additional-location=" + externalPropertiesPath,
"spring.config.use-legacy-processing=true")
"spring.cloud.bootstrap.enabled=true")
.run();
then(this.context.getEnvironment().getProperty("info.name")).isEqualTo("externalPropertiesInfoName");
then(this.context.getEnvironment().getProperty("info.desc")).isEqualTo("defaultPropertiesInfoDesc");
@ -107,7 +107,7 @@ public class BootstrapConfigurationTests { @@ -107,7 +107,7 @@ public class BootstrapConfigurationTests {
@Test
public void bootstrapPropertiesAvailableInInitializer() {
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
.properties("spring.config.use-legacy-processing=true").sources(BareConfiguration.class)
.properties("spring.cloud.bootstrap.enabled=true").sources(BareConfiguration.class)
.initializers(new ApplicationContextInitializer<ConfigurableApplicationContext>() {
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
@ -134,7 +134,7 @@ public class BootstrapConfigurationTests { @@ -134,7 +134,7 @@ public class BootstrapConfigurationTests {
public void picksUpAdditionalPropertySource() {
PropertySourceConfiguration.MAP.put("bootstrap.foo", "bar");
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
.properties("spring.config.use-legacy-processing=true").sources(BareConfiguration.class).run();
.properties("spring.cloud.bootstrap.enabled=true").sources(BareConfiguration.class).run();
then(this.context.getEnvironment().getProperty("bootstrap.foo")).isEqualTo("bar");
then(this.context.getEnvironment().getPropertySources()
.contains(PropertySourceBootstrapConfiguration.BOOTSTRAP_PROPERTY_SOURCE_NAME + "-testBootstrap"))
@ -146,7 +146,7 @@ public class BootstrapConfigurationTests { @@ -146,7 +146,7 @@ public class BootstrapConfigurationTests {
System.setProperty("expected.fail", "true");
Throwable throwable = Assertions.assertThrows(RuntimeException.class, () -> {
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
.properties("spring.config.use-legacy-processing=true").sources(BareConfiguration.class).run();
.properties("spring.cloud.bootstrap.enabled=true").sources(BareConfiguration.class).run();
});
then(throwable.getMessage().equals("Planned"));
}
@ -156,7 +156,7 @@ public class BootstrapConfigurationTests { @@ -156,7 +156,7 @@ public class BootstrapConfigurationTests {
PropertySourceConfiguration.MAP.put("bootstrap.foo", "bar");
System.setProperty("bootstrap.foo", "system");
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
.properties("spring.config.use-legacy-processing=true").sources(BareConfiguration.class).run();
.properties("spring.cloud.bootstrap.enabled=true").sources(BareConfiguration.class).run();
then(this.context.getEnvironment().getProperty("bootstrap.foo")).isEqualTo("bar");
}
@ -166,7 +166,7 @@ public class BootstrapConfigurationTests { @@ -166,7 +166,7 @@ public class BootstrapConfigurationTests {
PropertySourceConfiguration.MAP.put("spring.cloud.config.overrideSystemProperties", "false");
System.setProperty("bootstrap.foo", "system");
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
.properties("spring.config.use-legacy-processing=true").sources(BareConfiguration.class).run();
.properties("spring.cloud.bootstrap.enabled=true").sources(BareConfiguration.class).run();
then(this.context.getEnvironment().getProperty("bootstrap.foo")).isEqualTo("system");
}
@ -180,7 +180,7 @@ public class BootstrapConfigurationTests { @@ -180,7 +180,7 @@ public class BootstrapConfigurationTests {
PropertySourceConfiguration.MAP.put("spring.cloud.config.allowOverride", "false");
System.setProperty("bootstrap.foo", "system");
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
.properties("spring.config.use-legacy-processing=true").sources(BareConfiguration.class).run();
.properties("spring.cloud.bootstrap.enabled=true").sources(BareConfiguration.class).run();
then(this.context.getEnvironment().getProperty("bootstrap.foo")).isEqualTo("bar");
}
@ -191,7 +191,7 @@ public class BootstrapConfigurationTests { @@ -191,7 +191,7 @@ public class BootstrapConfigurationTests {
PropertySourceConfiguration.MAP.put("spring.cloud.config.allowOverride", "true");
System.setProperty("bootstrap.foo", "system");
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
.properties("spring.config.use-legacy-processing=true").sources(BareConfiguration.class).run();
.properties("spring.cloud.bootstrap.enabled=true").sources(BareConfiguration.class).run();
then(this.context.getEnvironment().getProperty("bootstrap.foo")).isEqualTo("system");
}
@ -204,7 +204,7 @@ public class BootstrapConfigurationTests { @@ -204,7 +204,7 @@ public class BootstrapConfigurationTests {
environment.getPropertySources().addLast(
new MapPropertySource("last", Collections.<String, Object>singletonMap("bootstrap.foo", "splat")));
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
.properties("spring.config.use-legacy-processing=true").environment(environment)
.properties("spring.cloud.bootstrap.enabled=true").environment(environment)
.sources(BareConfiguration.class).run();
then(this.context.getEnvironment().getProperty("bootstrap.foo")).isEqualTo("splat");
}
@ -214,7 +214,7 @@ public class BootstrapConfigurationTests { @@ -214,7 +214,7 @@ public class BootstrapConfigurationTests {
System.setProperty("expected.name", "main");
this.context = new SpringApplicationBuilder()
.web(WebApplicationType.NONE).properties("spring.cloud.bootstrap.name:other",
"spring.config.use-legacy-processing=true", "spring.config.name:plain")
"spring.cloud.bootstrap.enabled=true", "spring.config.name:plain")
.sources(BareConfiguration.class).run();
then(this.context.getEnvironment().getProperty("spring.application.name")).isEqualTo("app");
// The parent is called "main" because spring.application.name is specified in
@ -231,7 +231,7 @@ public class BootstrapConfigurationTests { @@ -231,7 +231,7 @@ public class BootstrapConfigurationTests {
System.setProperty("expected.name", "main");
this.context = new SpringApplicationBuilder()
.web(WebApplicationType.NONE).properties("spring.cloud.bootstrap.name:application",
"spring.config.use-legacy-processing=true", "spring.config.name:other")
"spring.cloud.bootstrap.enabled=true", "spring.config.name:other")
.sources(BareConfiguration.class).run();
then(this.context.getEnvironment().getProperty("spring.application.name")).isEqualTo("main");
// The parent has no name because spring.application.name is not
@ -243,7 +243,7 @@ public class BootstrapConfigurationTests { @@ -243,7 +243,7 @@ public class BootstrapConfigurationTests {
public void applicationNameOnlyInBootstrap() {
System.setProperty("expected.name", "main");
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
.properties("spring.cloud.bootstrap.name:other", "spring.config.use-legacy-processing=true")
.properties("spring.cloud.bootstrap.name:other", "spring.cloud.bootstrap.enabled=true")
.sources(BareConfiguration.class).run();
// The main context is called "main" because spring.application.name is specified
// in other.properties (and not in the main config file)
@ -258,7 +258,7 @@ public class BootstrapConfigurationTests { @@ -258,7 +258,7 @@ public class BootstrapConfigurationTests {
public void environmentEnrichedOnceWhenSharedWithChildContext() {
PropertySourceConfiguration.MAP.put("bootstrap.foo", "bar");
this.context = new SpringApplicationBuilder().sources(BareConfiguration.class)
.properties("spring.config.use-legacy-processing=true").environment(new StandardEnvironment())
.properties("spring.cloud.bootstrap.enabled=true").environment(new StandardEnvironment())
.child(BareConfiguration.class).web(WebApplicationType.NONE).run();
then(this.context.getEnvironment().getProperty("bootstrap.foo")).isEqualTo("bar");
then(this.context.getParent().getEnvironment()).isEqualTo(this.context.getEnvironment());
@ -274,7 +274,7 @@ public class BootstrapConfigurationTests { @@ -274,7 +274,7 @@ public class BootstrapConfigurationTests {
TestHigherPriorityBootstrapConfiguration.count.set(0);
PropertySourceConfiguration.MAP.put("bootstrap.foo", "bar");
this.context = new SpringApplicationBuilder().sources(BareConfiguration.class)
.properties("spring.config.use-legacy-processing=true").child(BareConfiguration.class)
.properties("spring.cloud.bootstrap.enabled=true").child(BareConfiguration.class)
.web(WebApplicationType.NONE).run();
then(TestHigherPriorityBootstrapConfiguration.count.get()).isEqualTo(1);
then(this.context.getParent()).isNotNull();
@ -286,7 +286,7 @@ public class BootstrapConfigurationTests { @@ -286,7 +286,7 @@ public class BootstrapConfigurationTests {
@Test
public void listOverride() {
this.context = new SpringApplicationBuilder().sources(BareConfiguration.class)
.properties("spring.config.use-legacy-processing=true").child(BareConfiguration.class)
.properties("spring.cloud.bootstrap.enabled=true").child(BareConfiguration.class)
.web(WebApplicationType.NONE).run();
ListProperties listProperties = new ListProperties();
Binder.get(this.context.getEnvironment()).bind("list", Bindable.ofInstance(listProperties));
@ -299,7 +299,7 @@ public class BootstrapConfigurationTests { @@ -299,7 +299,7 @@ public class BootstrapConfigurationTests {
TestHigherPriorityBootstrapConfiguration.count.set(0);
PropertySourceConfiguration.MAP.put("bootstrap.foo", "bar");
SpringApplicationBuilder builder = new SpringApplicationBuilder()
.properties("spring.config.use-legacy-processing=true").sources(BareConfiguration.class);
.properties("spring.cloud.bootstrap.enabled=true").sources(BareConfiguration.class);
this.sibling = builder.child(BareConfiguration.class).properties("spring.application.name=sibling")
.web(WebApplicationType.NONE).run();
this.context = builder.child(BareConfiguration.class).properties("spring.application.name=context")
@ -321,7 +321,7 @@ public class BootstrapConfigurationTests { @@ -321,7 +321,7 @@ public class BootstrapConfigurationTests {
public void environmentEnrichedInParentContext() {
PropertySourceConfiguration.MAP.put("bootstrap.foo", "bar");
this.context = new SpringApplicationBuilder().sources(BareConfiguration.class)
.properties("spring.config.use-legacy-processing=true").child(BareConfiguration.class)
.properties("spring.cloud.bootstrap.enabled=true").child(BareConfiguration.class)
.web(WebApplicationType.NONE).run();
then(this.context.getEnvironment().getProperty("bootstrap.foo")).isEqualTo("bar");
then(this.context.getParent().getEnvironment()).isNotSameAs(this.context.getEnvironment());
@ -341,7 +341,7 @@ public class BootstrapConfigurationTests { @@ -341,7 +341,7 @@ public class BootstrapConfigurationTests {
ConfigurableApplicationContext parent = new SpringApplicationBuilder().sources(BareConfiguration.class)
.profiles("parent").web(WebApplicationType.NONE).run();
this.context = new SpringApplicationBuilder(BareConfiguration.class)
.properties("spring.config.use-legacy-processing=true").profiles("child").parent(parent)
.properties("spring.cloud.bootstrap.enabled=true").profiles("child").parent(parent)
.web(WebApplicationType.NONE).run();
then(this.context.getParent().getEnvironment()).isNotSameAs(this.context.getEnvironment());
// The ApplicationContext merges profiles (profiles and property sources), see
@ -367,7 +367,7 @@ public class BootstrapConfigurationTests { @@ -367,7 +367,7 @@ public class BootstrapConfigurationTests {
public void includeProfileFromBootstrapPropertySource() {
PropertySourceConfiguration.MAP.put("spring.profiles.include", "bar,baz");
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE)
.properties("spring.config.use-legacy-processing=true").profiles("foo").sources(BareConfiguration.class)
.properties("spring.cloud.bootstrap.enabled=true").profiles("foo").sources(BareConfiguration.class)
.run();
then(this.context.getEnvironment().acceptsProfiles("baz")).isTrue();
then(this.context.getEnvironment().acceptsProfiles("bar")).isTrue();
@ -376,7 +376,7 @@ public class BootstrapConfigurationTests { @@ -376,7 +376,7 @@ public class BootstrapConfigurationTests {
@Test
public void includeProfileFromBootstrapProperties() {
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE).sources(BareConfiguration.class)
.properties("spring.config.use-legacy-processing=true", "spring.cloud.bootstrap.name=local").run();
.properties("spring.cloud.bootstrap.enabled=true", "spring.cloud.bootstrap.name=local").run();
then(this.context.getEnvironment().acceptsProfiles("local")).isTrue();
then(this.context.getEnvironment().getProperty("added")).isEqualTo("Hello added!");
}
@ -384,8 +384,7 @@ public class BootstrapConfigurationTests { @@ -384,8 +384,7 @@ public class BootstrapConfigurationTests {
@Test
public void nonEnumerablePropertySourceWorks() {
this.context = new SpringApplicationBuilder().web(WebApplicationType.NONE).sources(BareConfiguration.class)
.properties("spring.config.use-legacy-processing=true", "spring.cloud.bootstrap.name=nonenumerable")
.run();
.properties("spring.cloud.bootstrap.enabled=true", "spring.cloud.bootstrap.name=nonenumerable").run();
then(this.context.getEnvironment().getProperty("foo")).isEqualTo("bar");
}

7
spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapListenerHierarchyIntegrationTests.java

@ -37,8 +37,7 @@ public class BootstrapListenerHierarchyIntegrationTests { @@ -37,8 +37,7 @@ public class BootstrapListenerHierarchyIntegrationTests {
@Test
public void shouldAddInABootstrapContext() {
ConfigurableApplicationContext context = new SpringApplicationBuilder()
.properties("spring.config.use-legacy-processing=true").sources(BasicConfiguration.class).web(NONE)
.run();
.properties("spring.cloud.bootstrap.enabled=true").sources(BasicConfiguration.class).web(NONE).run();
then(context.getParent()).isNotNull();
}
@ -46,7 +45,7 @@ public class BootstrapListenerHierarchyIntegrationTests { @@ -46,7 +45,7 @@ public class BootstrapListenerHierarchyIntegrationTests {
@Test
public void shouldAddInOneBootstrapForABasicParentChildHierarchy() {
ConfigurableApplicationContext context = new SpringApplicationBuilder()
.properties("spring.config.use-legacy-processing=true").sources(RootConfiguration.class).web(NONE)
.properties("spring.cloud.bootstrap.enabled=true").sources(RootConfiguration.class).web(NONE)
.child(BasicConfiguration.class).web(NONE).run();
// Should be RootConfiguration based context
@ -65,7 +64,7 @@ public class BootstrapListenerHierarchyIntegrationTests { @@ -65,7 +64,7 @@ public class BootstrapListenerHierarchyIntegrationTests {
@Test
public void shouldAddInOneBootstrapForSiblingsBasedHierarchy() {
ConfigurableApplicationContext context = new SpringApplicationBuilder()
.properties("spring.config.use-legacy-processing=true").sources(RootConfiguration.class).web(NONE)
.properties("spring.cloud.bootstrap.enabled=true").sources(RootConfiguration.class).web(NONE)
.child(BasicConfiguration.class).web(NONE).sibling(BasicConfiguration.class).web(NONE).run();
// Should be RootConfiguration based context

4
spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionIntegrationTests.java

@ -39,7 +39,7 @@ public class EncryptionIntegrationTests { @@ -39,7 +39,7 @@ public class EncryptionIntegrationTests {
@Test
public void legacySymmetricPropertyValues() {
ConfigurableApplicationContext context = new SpringApplicationBuilder(TestConfiguration.class)
.web(WebApplicationType.NONE).properties("spring.config.use-legacy-processing=true", "encrypt.key:pie",
.web(WebApplicationType.NONE).properties("spring.cloud.bootstrap.enabled=true", "encrypt.key:pie",
"foo.password:{cipher}bf29452295df354e6153c5b31b03ef23c70e55fba24299aa85c63438f1c43c95")
.run();
then(context.getEnvironment().getProperty("foo.password")).isEqualTo("test");
@ -48,7 +48,7 @@ public class EncryptionIntegrationTests { @@ -48,7 +48,7 @@ public class EncryptionIntegrationTests {
@Test
public void legacySymmetricConfigurationProperties() {
ConfigurableApplicationContext context = new SpringApplicationBuilder(TestConfiguration.class)
.web(WebApplicationType.NONE).properties("spring.config.use-legacy-processing=true", "encrypt.key:pie",
.web(WebApplicationType.NONE).properties("spring.cloud.bootstrap.enabled=true", "encrypt.key:pie",
"foo.password:{cipher}bf29452295df354e6153c5b31b03ef23c70e55fba24299aa85c63438f1c43c95")
.run();
then(context.getBean(PasswordProperties.class).getPassword()).isEqualTo("test");

2
spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderIntegrationTests.java

@ -40,7 +40,7 @@ import org.springframework.test.context.ActiveProfiles; @@ -40,7 +40,7 @@ import org.springframework.test.context.ActiveProfiles;
import static org.assertj.core.api.BDDAssertions.then;
@SpringBootTest(classes = TestConfiguration.class, properties = "spring.config.use-legacy-processing=true")
@SpringBootTest(classes = TestConfiguration.class, properties = "spring.cloud.bootstrap.enabled=true")
@ActiveProfiles("config")
public class ConfigurationPropertiesRebinderIntegrationTests {

2
spring-cloud-context/src/test/java/org/springframework/cloud/context/properties/ConfigurationPropertiesRebinderRefreshScopeIntegrationTests.java

@ -37,7 +37,7 @@ import org.springframework.test.annotation.DirtiesContext; @@ -37,7 +37,7 @@ import org.springframework.test.annotation.DirtiesContext;
import static org.assertj.core.api.BDDAssertions.then;
@SpringBootTest(classes = TestConfiguration.class, properties = "spring.config.use-legacy-processing=true")
@SpringBootTest(classes = TestConfiguration.class, properties = "spring.cloud.bootstrap.enabled=true")
public class ConfigurationPropertiesRebinderRefreshScopeIntegrationTests {
@Autowired

2
spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherIntegrationTests.java

@ -34,7 +34,7 @@ import org.springframework.test.annotation.DirtiesContext; @@ -34,7 +34,7 @@ import org.springframework.test.annotation.DirtiesContext;
import static org.assertj.core.api.BDDAssertions.then;
@SpringBootTest(classes = TestConfiguration.class,
properties = { "spring.datasource.hikari.read-only=false", "spring.config.use-legacy-processing=true" })
properties = { "spring.datasource.hikari.read-only=false", "spring.cloud.bootstrap.enabled=true" })
public class ContextRefresherIntegrationTests {
@Autowired

2
spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherOrderingIntegrationTests.java

@ -41,7 +41,7 @@ import org.springframework.test.annotation.DirtiesContext; @@ -41,7 +41,7 @@ import org.springframework.test.annotation.DirtiesContext;
import static java.util.Collections.singletonMap;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(properties = "spring.config.use-legacy-processing=true")
@SpringBootTest(properties = "spring.cloud.bootstrap.enabled=true")
@DirtiesContext
public class ContextRefresherOrderingIntegrationTests {

23
spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java

@ -62,8 +62,8 @@ public class ContextRefresherTests { @@ -62,8 +62,8 @@ public class ContextRefresherTests {
@Disabled // FIXME: legacy config
public void orderNewPropertiesConsistentWithNewContext() {
try (ConfigurableApplicationContext context = SpringApplication.run(Empty.class,
"--spring.config.use-legacy-processing=true", "--spring.main.web-application-type=none",
"--debug=false", "--spring.main.bannerMode=OFF")) {
"--spring.cloud.bootstrap.enabled=true", "--spring.main.web-application-type=none", "--debug=false",
"--spring.main.bannerMode=OFF")) {
context.getEnvironment().setActiveProfiles("refresh");
List<String> names = names(context.getEnvironment().getPropertySources());
then(names).doesNotContain("applicationConfig: [classpath:/bootstrap-refresh.properties]");
@ -82,8 +82,8 @@ public class ContextRefresherTests { @@ -82,8 +82,8 @@ public class ContextRefresherTests {
// Use spring.cloud.bootstrap.name to switch off the defaults (which would pick up
// a bootstrapProperties immediately
try (ConfigurableApplicationContext context = SpringApplication.run(Empty.class,
"--spring.config.use-legacy-processing=true", "--spring.main.web-application-type=none",
"--debug=false", "--spring.main.bannerMode=OFF", "--spring.cloud.bootstrap.name=refresh")) {
"--spring.cloud.bootstrap.enabled=true", "--spring.main.web-application-type=none", "--debug=false",
"--spring.main.bannerMode=OFF", "--spring.cloud.bootstrap.name=refresh")) {
List<String> names = names(context.getEnvironment().getPropertySources());
System.err.println("***** " + context.getEnvironment().getPropertySources());
then(names).doesNotContain("bootstrapProperties");
@ -103,8 +103,8 @@ public class ContextRefresherTests { @@ -103,8 +103,8 @@ public class ContextRefresherTests {
// Use spring.cloud.bootstrap.name to switch off the defaults (which would pick up
// a bootstrapProperties immediately
try (ConfigurableApplicationContext context = SpringApplication.run(ContextRefresherTests.class,
"--spring.main.web-application-type=none", "--spring.config.use-legacy-processing=true",
"--debug=false", "--spring.main.bannerMode=OFF", "--spring.cloud.bootstrap.name=refresh")) {
"--spring.main.web-application-type=none", "--spring.cloud.bootstrap.enabled=true", "--debug=false",
"--spring.main.bannerMode=OFF", "--spring.cloud.bootstrap.name=refresh")) {
LegacyContextRefresher refresher = new LegacyContextRefresher(context, this.scope);
TestPropertyValues.of("spring.cloud.bootstrap.sources: "
+ "org.springframework.cloud.context.refresh.ContextRefresherTests.PropertySourceConfiguration")
@ -123,8 +123,8 @@ public class ContextRefresherTests { @@ -123,8 +123,8 @@ public class ContextRefresherTests {
TestLoggingSystem system = (TestLoggingSystem) LoggingSystem.get(getClass().getClassLoader());
then(system.getCount()).isEqualTo(0);
try (ConfigurableApplicationContext context = SpringApplication.run(Empty.class,
"--spring.config.use-legacy-processing=true", "--spring.main.web-application-type=none",
"--debug=false", "--spring.main.bannerMode=OFF", "--spring.cloud.bootstrap.name=refresh")) {
"--spring.cloud.bootstrap.enabled=true", "--spring.main.web-application-type=none", "--debug=false",
"--spring.main.bannerMode=OFF", "--spring.cloud.bootstrap.name=refresh")) {
then(system.getCount()).isEqualTo(4);
ContextRefresher refresher = new LegacyContextRefresher(context, this.scope);
refresher.refresh();
@ -138,9 +138,8 @@ public class ContextRefresherTests { @@ -138,9 +138,8 @@ public class ContextRefresherTests {
TestBootstrapConfiguration.fooSightings = new ArrayList<>();
try (ConfigurableApplicationContext context = SpringApplication.run(ContextRefresherTests.class,
"--spring.main.web-application-type=none", "--spring.config.use-legacy-processing=true",
"--debug=false", "--spring.main.bannerMode=OFF", "--spring.cloud.bootstrap.name=refresh",
"--test.bootstrap.foo=bar")) {
"--spring.main.web-application-type=none", "--spring.cloud.bootstrap.enabled=true", "--debug=false",
"--spring.main.bannerMode=OFF", "--spring.cloud.bootstrap.name=refresh", "--test.bootstrap.foo=bar")) {
context.getEnvironment().setActiveProfiles("refresh");
ContextRefresher refresher = new LegacyContextRefresher(context, this.scope);
refresher.refresh();
@ -162,7 +161,7 @@ public class ContextRefresherTests { @@ -162,7 +161,7 @@ public class ContextRefresherTests {
@Test
public void legacyContextRefresherCreated() {
new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(RefreshAutoConfiguration.class))
.withPropertyValues("spring.config.use-legacy-processing=true").run(context -> {
.withPropertyValues("spring.cloud.bootstrap.enabled=true").run(context -> {
assertThat(context).hasSingleBean(LegacyContextRefresher.class);
assertThat(context).hasSingleBean(ContextRefresher.class);
});

2
spring-cloud-context/src/test/java/org/springframework/cloud/context/restart/RestartIntegrationTests.java

@ -45,7 +45,7 @@ public class RestartIntegrationTests { @@ -45,7 +45,7 @@ public class RestartIntegrationTests {
public void testRestartTwice() throws Exception {
this.context = SpringApplication.run(TestConfiguration.class, "--management.endpoint.restart.enabled=true",
"--server.port=0", "--spring.config.use-legacy-processing=true",
"--server.port=0", "--spring.cloud.bootstrap.enabled=true",
"--management.endpoints.web.exposure.include=restart", "--spring.liveBeansView.mbeanDomain=livebeans");
RestartEndpoint endpoint = this.context.getBean(RestartEndpoint.class);

2
spring-cloud-context/src/test/java/org/springframework/cloud/context/scope/refresh/RefreshScopeSerializationTests.java

@ -35,7 +35,7 @@ public class RefreshScopeSerializationTests { @@ -35,7 +35,7 @@ public class RefreshScopeSerializationTests {
@Test
public void defaultApplicationContextId() throws Exception {
ConfigurableApplicationContext context = new SpringApplicationBuilder(TestConfiguration.class)
.properties("spring.config.use-legacy-processing=true").web(WebApplicationType.NONE).run();
.properties("spring.cloud.bootstrap.enabled=true").web(WebApplicationType.NONE).run();
then(context.getId()).isEqualTo("application-1");
}

6
spring-cloud-context/src/test/java/org/springframework/cloud/endpoint/RefreshEndpointTests.java

@ -72,7 +72,7 @@ public class RefreshEndpointTests { @@ -72,7 +72,7 @@ public class RefreshEndpointTests {
@Disabled // FIXME: legacy
public void keysComputedWhenAdded() throws Exception {
this.context = new SpringApplicationBuilder(Empty.class).web(WebApplicationType.NONE).bannerMode(Mode.OFF)
.properties("spring.config.use-legacy-processing=true", "spring.cloud.bootstrap.name:none").run();
.properties("spring.cloud.bootstrap.enabled=true", "spring.cloud.bootstrap.name:none").run();
RefreshScope scope = new RefreshScope();
scope.setApplicationContext(this.context);
this.context.getEnvironment().setActiveProfiles("local");
@ -86,7 +86,7 @@ public class RefreshEndpointTests { @@ -86,7 +86,7 @@ public class RefreshEndpointTests {
@Disabled // FIXME: legacy
public void keysComputedWhenOveridden() throws Exception {
this.context = new SpringApplicationBuilder(Empty.class).web(WebApplicationType.NONE).bannerMode(Mode.OFF)
.properties("spring.config.use-legacy-processing=true", "spring.cloud.bootstrap.name:none").run();
.properties("spring.cloud.bootstrap.enabled=true", "spring.cloud.bootstrap.name:none").run();
RefreshScope scope = new RefreshScope();
scope.setApplicationContext(this.context);
this.context.getEnvironment().setActiveProfiles("override");
@ -99,7 +99,7 @@ public class RefreshEndpointTests { @@ -99,7 +99,7 @@ public class RefreshEndpointTests {
@Test
public void keysComputedWhenChangesInExternalProperties() throws Exception {
this.context = new SpringApplicationBuilder(Empty.class).web(WebApplicationType.NONE).bannerMode(Mode.OFF)
.properties("spring.cloud.bootstrap.name:none", "spring.config.use-legacy-processing=true").run();
.properties("spring.cloud.bootstrap.name:none", "spring.cloud.bootstrap.enabled=true").run();
RefreshScope scope = new RefreshScope();
scope.setApplicationContext(this.context);
TestPropertyValues.of("spring.cloud.bootstrap.sources=" + ExternalPropertySourceLocator.class.getName())

Loading…
Cancel
Save