|
|
|
@ -47,7 +47,6 @@ import org.springframework.mock.env.MockPropertySource;
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatNoException;
|
|
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -221,7 +220,7 @@ class ConfigDataEnvironmentTests {
|
|
|
|
|
|
|
|
|
|
@ParameterizedTest
|
|
|
|
|
@CsvSource({ "include", "include[0]" })
|
|
|
|
|
void processAndApplyThrowExceptionWhenActivateProfileWithProfileInclude(String property, TestInfo info) {
|
|
|
|
|
void processAndApplyWhenHasProfileIncludeInProfileSpecificDocumentThrowsException(String property, TestInfo info) {
|
|
|
|
|
this.environment.setProperty("spring.config.location", getConfigLocation(info));
|
|
|
|
|
ConfigDataEnvironment configDataEnvironment = new ConfigDataEnvironment(this.logFactory, this.bootstrapContext,
|
|
|
|
|
this.environment, this.resourceLoader, this.additionalProfiles, null) {
|
|
|
|
@ -237,16 +236,15 @@ class ConfigDataEnvironmentTests {
|
|
|
|
|
mock(ConfigDataResource.class), false, data, 0));
|
|
|
|
|
return super.createContributors(contributors);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
assertThatExceptionOfType(InactiveConfigDataAccessException.class)
|
|
|
|
|
.isThrownBy(configDataEnvironment::processAndApply);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ParameterizedTest
|
|
|
|
|
@CsvSource({ "spring.config.activate.on-profile", "spring.profiles.include", "spring.profiles.include[0]" })
|
|
|
|
|
void processAndApplyDoseNotThrowExceptionWhenUsingEitherActivateProfileOrProfileInclude(String property,
|
|
|
|
|
TestInfo info) {
|
|
|
|
|
@CsvSource({ "spring.profiles.include", "spring.profiles.include[0]" })
|
|
|
|
|
void processAndApplyIncludesProfilesFromSpringProfilesInclude(String property, TestInfo info) {
|
|
|
|
|
this.environment.setProperty("spring.config.location", getConfigLocation(info));
|
|
|
|
|
ConfigDataEnvironment configDataEnvironment = new ConfigDataEnvironment(this.logFactory, this.bootstrapContext,
|
|
|
|
|
this.environment, this.resourceLoader, this.additionalProfiles, null) {
|
|
|
|
@ -255,15 +253,16 @@ class ConfigDataEnvironmentTests {
|
|
|
|
|
protected ConfigDataEnvironmentContributors createContributors(
|
|
|
|
|
List<ConfigDataEnvironmentContributor> contributors) {
|
|
|
|
|
Map<String, Object> source = new LinkedHashMap<>();
|
|
|
|
|
source.put(property, "only");
|
|
|
|
|
source.put(property, "included");
|
|
|
|
|
ConfigData data = new ConfigData(Collections.singleton(new MapPropertySource("test", source)));
|
|
|
|
|
contributors.add(ConfigDataEnvironmentContributor.ofUnboundImport(ConfigDataLocation.of("test"),
|
|
|
|
|
mock(ConfigDataResource.class), false, data, 0));
|
|
|
|
|
return super.createContributors(contributors);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
assertThatNoException().isThrownBy(configDataEnvironment::processAndApply);
|
|
|
|
|
};
|
|
|
|
|
configDataEnvironment.processAndApply();
|
|
|
|
|
assertThat(this.environment.getActiveProfiles()).containsExactly("included");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|