Add ConfigDataEnvironmentPostProcessor.applyTo
Add static methods to `ConfigDataEnvironmentPostProcessor` so that post-processing can be applied to `Environment` instances directly. Closes gh-22601
This commit is contained in:
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.boot.test.context;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.springframework.boot.context.config.ConfigData;
|
||||
import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor;
|
||||
import org.springframework.boot.env.DefaultPropertiesPropertySource;
|
||||
@@ -25,7 +23,6 @@ import org.springframework.boot.env.RandomValuePropertySource;
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@@ -44,20 +41,8 @@ public class ConfigDataApplicationContextInitializer
|
||||
public void initialize(ConfigurableApplicationContext applicationContext) {
|
||||
ConfigurableEnvironment environment = applicationContext.getEnvironment();
|
||||
RandomValuePropertySource.addToEnvironment(environment);
|
||||
new ConfigDataProcessor().addPropertySources(environment, applicationContext);
|
||||
ConfigDataEnvironmentPostProcessor.applyTo(environment, applicationContext);
|
||||
DefaultPropertiesPropertySource.moveToEnd(environment);
|
||||
}
|
||||
|
||||
private static class ConfigDataProcessor extends ConfigDataEnvironmentPostProcessor {
|
||||
|
||||
ConfigDataProcessor() {
|
||||
super(Supplier::get);
|
||||
}
|
||||
|
||||
void addPropertySources(ConfigurableEnvironment environment, ResourceLoader resourceLoader) {
|
||||
addPropertySources(environment, resourceLoader, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user