Introduce ConfigurableEnvironment#addActiveProfile
Provides a convenient mechanism for activating an additional profile while preserving those that are already active, as opposed to calling #setActiveProfiles with the contents of #getActiveProfiles plus the new profile. Issue: SPR-8548
This commit is contained in:
@@ -120,6 +120,21 @@ public class EnvironmentTests {
|
||||
environment.setDefaultProfiles("");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addActiveProfile() {
|
||||
assertThat(environment.getActiveProfiles().length, is(0));
|
||||
environment.setActiveProfiles("local", "embedded");
|
||||
assertThat(Arrays.asList(environment.getActiveProfiles()), hasItems("local", "embedded"));
|
||||
assertThat(environment.getActiveProfiles().length, is(2));
|
||||
environment.addActiveProfile("p1");
|
||||
assertThat(Arrays.asList(environment.getActiveProfiles()), hasItems("p1"));
|
||||
assertThat(environment.getActiveProfiles().length, is(3));
|
||||
environment.addActiveProfile("p2");
|
||||
environment.addActiveProfile("p3");
|
||||
assertThat(Arrays.asList(environment.getActiveProfiles()), hasItems("p2", "p3"));
|
||||
assertThat(environment.getActiveProfiles().length, is(5));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reservedDefaultProfile() {
|
||||
assertThat(environment.getDefaultProfiles(), equalTo(new String[]{RESERVED_DEFAULT_PROFILE_NAME}));
|
||||
|
||||
Reference in New Issue
Block a user