Revert "Add profiles directly to the application environment for tests"
This reverts commit 487b9cbf96.
Fixes gh-19788
This commit is contained in:
@@ -28,6 +28,7 @@ import org.springframework.boot.context.properties.bind.Binder;
|
||||
import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
|
||||
import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
|
||||
import org.springframework.boot.test.mock.web.SpringBootMockServletContext;
|
||||
import org.springframework.boot.test.util.TestPropertyValues;
|
||||
import org.springframework.boot.web.reactive.context.GenericReactiveWebApplicationContext;
|
||||
import org.springframework.boot.web.servlet.support.ServletContextApplicationContextInitializer;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -92,7 +93,7 @@ public class SpringBootContextLoader extends AbstractContextLoader {
|
||||
application.getSources().addAll(Arrays.asList(configLocations));
|
||||
ConfigurableEnvironment environment = getEnvironment();
|
||||
if (!ObjectUtils.isEmpty(config.getActiveProfiles())) {
|
||||
environment.setActiveProfiles(config.getActiveProfiles());
|
||||
setActiveProfiles(environment, config.getActiveProfiles());
|
||||
}
|
||||
ResourceLoader resourceLoader = (application.getResourceLoader() != null) ? application.getResourceLoader()
|
||||
: new DefaultResourceLoader(getClass().getClassLoader());
|
||||
@@ -138,6 +139,11 @@ public class SpringBootContextLoader extends AbstractContextLoader {
|
||||
return new StandardEnvironment();
|
||||
}
|
||||
|
||||
private void setActiveProfiles(ConfigurableEnvironment environment, String[] profiles) {
|
||||
TestPropertyValues.of("spring.profiles.active=" + StringUtils.arrayToCommaDelimitedString(profiles))
|
||||
.applyTo(environment);
|
||||
}
|
||||
|
||||
protected String[] getInlinedProperties(MergedContextConfiguration config) {
|
||||
ArrayList<String> properties = new ArrayList<>();
|
||||
// JMX bean names will clash if the same bean is used in multiple contexts
|
||||
|
||||
Reference in New Issue
Block a user