Merge branch '2.0.x'

This commit is contained in:
Madhura Bhave 2018-06-18 17:18:16 -07:00
commit 3a01914b63
2 changed files with 13 additions and 1 deletions

View File

@ -371,8 +371,8 @@ public class ConfigFileApplicationListener
}
Binder binder = Binder.get(this.environment);
Set<Profile> activeProfiles = new LinkedHashSet<>();
activeProfiles.addAll(getProfiles(binder, ACTIVE_PROFILES_PROPERTY));
activeProfiles.addAll(getProfiles(binder, INCLUDE_PROFILES_PROPERTY));
activeProfiles.addAll(getProfiles(binder, ACTIVE_PROFILES_PROPERTY));
return activeProfiles;
}

View File

@ -401,6 +401,18 @@ public class ConfigFileApplicationListenerTests {
validateProfilePrecedence(null, "dev", "other");
}
@Test
public void profilesAddedToEnvironmentViaActiveAndIncludeProperty() {
// Active profile property takes precedence
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment,
"spring.profiles.active=dev", "spring.profiles.include=other");
this.initializer.postProcessEnvironment(this.environment, this.application);
assertThat(this.environment.getActiveProfiles()).contains("dev", "other");
assertThat(this.environment.getProperty("my.property"))
.isEqualTo("fromdevpropertiesfile");
validateProfilePrecedence(null, "other", "dev");
}
@Test
public void profilesAddedToEnvironmentAndViaPropertyDuplicate() {
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment,