Merge branch '2.2.x'
Closes gh-19822
This commit is contained in:
@@ -29,6 +29,7 @@ import org.springframework.boot.context.properties.source.ConfigurationPropertyS
|
||||
import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
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;
|
||||
@@ -97,7 +98,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());
|
||||
@@ -155,6 +156,11 @@ public class SpringBootContextLoader extends AbstractContextLoader {
|
||||
.getValue("args", String[].class).orElse(NO_ARGS);
|
||||
}
|
||||
|
||||
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