commit
110c36e607
|
|
@ -148,15 +148,16 @@ public class Profiles implements Iterable<String> {
|
|||
return reversed;
|
||||
}
|
||||
|
||||
private List<String> asUniqueItemList(Collection<String> strings) {
|
||||
return asUniqueItemList(strings, null);
|
||||
private List<String> asUniqueItemList(Collection<String> profiles) {
|
||||
return asUniqueItemList(profiles, null);
|
||||
}
|
||||
|
||||
private List<String> asUniqueItemList(Collection<String> strings, Collection<String> additional) {
|
||||
LinkedHashSet<String> uniqueItems = new LinkedHashSet<>(strings);
|
||||
private List<String> asUniqueItemList(Collection<String> profiles, Collection<String> additional) {
|
||||
LinkedHashSet<String> uniqueItems = new LinkedHashSet<>();
|
||||
if (!CollectionUtils.isEmpty(additional)) {
|
||||
uniqueItems.addAll(additional);
|
||||
}
|
||||
uniqueItems.addAll(profiles);
|
||||
return Collections.unmodifiableList(new ArrayList<>(uniqueItems));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -592,15 +592,14 @@ class SpringApplicationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
void addProfilesOrder() {
|
||||
void additionalProfilesOrderedBeforeActiveProfiles() {
|
||||
SpringApplication application = new SpringApplication(ExampleConfig.class);
|
||||
application.setWebApplicationType(WebApplicationType.NONE);
|
||||
application.setAdditionalProfiles("foo");
|
||||
ConfigurableEnvironment environment = new StandardEnvironment();
|
||||
application.setEnvironment(environment);
|
||||
this.context = application.run("--spring.profiles.active=bar,spam");
|
||||
// Since Boot 2.4 additional should always be last
|
||||
assertThat(environment.getActiveProfiles()).containsExactly("bar", "spam", "foo");
|
||||
assertThat(environment.getActiveProfiles()).containsExactly("foo", "bar", "spam");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ class ConfigDataEnvironmentPostProcessorIntegrationTests {
|
|||
void runWhenProfilesPresentBeforeConfigFileProcessingAugmentsProfileActivatedByConfigFile() {
|
||||
this.application.setAdditionalProfiles("other");
|
||||
ConfigurableApplicationContext context = this.application.run("--spring.config.name=enableprofile");
|
||||
assertThat(context.getEnvironment().getActiveProfiles()).containsExactly("myprofile", "other");
|
||||
assertThat(context.getEnvironment().getActiveProfiles()).containsExactly("other", "myprofile");
|
||||
String property = context.getEnvironment().getProperty("other.property");
|
||||
assertThat(property).isEqualTo("fromotherpropertiesfile");
|
||||
property = context.getEnvironment().getProperty("the.property");
|
||||
|
|
|
|||
|
|
@ -143,9 +143,9 @@ class ProfilesTests {
|
|||
@Test
|
||||
void getActiveWhenHasAdditionalIncludesAdditional() {
|
||||
MockEnvironment environment = new MockEnvironment();
|
||||
environment.setProperty("spring.profiles.active", "a,b,c");
|
||||
environment.setProperty("spring.profiles.active", "d,e,f");
|
||||
Binder binder = Binder.get(environment);
|
||||
Profiles profiles = new Profiles(environment, binder, Arrays.asList("d", "e", "f"));
|
||||
Profiles profiles = new Profiles(environment, binder, Arrays.asList("a", "b", "c"));
|
||||
assertThat(profiles.getActive()).containsExactly("a", "b", "c", "d", "e", "f");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue