Polish contribution

Closes gh-5561
This commit is contained in:
Stephane Nicoll
2016-04-05 15:45:24 +02:00
parent 4353963df6
commit 7cd31594c6
3 changed files with 12 additions and 40 deletions

View File

@@ -535,32 +535,13 @@ public class ConfigFileApplicationListenerTests {
this.initializer.setSearchNames("testsetmultiprofiles");
this.initializer.postProcessEnvironment(this.environment, this.application);
assertThat(this.environment.getActiveProfiles()).containsExactly("dev", "healthcheck");
String property = this.environment.getProperty("my.property");
String property2 = this.environment.getProperty("my.property2");
assertThat(property).isEqualTo("fromdevprofile");
assertThat(property2).isEqualTo("fromhealthcheckprofile");
ConfigurationPropertySources propertySource = (ConfigurationPropertySources) this.environment
.getPropertySources()
.get(ConfigFileApplicationListener.APPLICATION_CONFIGURATION_PROPERTY_SOURCE_NAME);
Collection<org.springframework.core.env.PropertySource<?>> sources = propertySource
.getSource();
assertThat(sources).hasSize(3);
List<String> names = new ArrayList<String>();
for (org.springframework.core.env.PropertySource<?> source : sources) {
if (source instanceof EnumerableCompositePropertySource) {
for (org.springframework.core.env.PropertySource<?> nested : ((EnumerableCompositePropertySource) source)
.getSource()) {
names.add(nested.getName());
}
}
else {
names.add(source.getName());
}
}
assertThat(names).contains(
"applicationConfig: [classpath:/testsetmultiprofiles.yml]#healthcheck",
"applicationConfig: [classpath:/testsetmultiprofiles.yml]#dev",
"applicationConfig: [classpath:/testsetmultiprofiles.yml]");
}
@Test
public void yamlSetsMultiProfilesWithWithespace() throws Exception {
this.initializer.setSearchNames("testsetmultiprofileswhitespace");
this.initializer.postProcessEnvironment(this.environment, this.application);
assertThat(this.environment.getActiveProfiles()).containsExactly("dev", "healthcheck");
}
@Test

View File

@@ -1,17 +1,4 @@
---
spring:
profiles:
active: dev, healthcheck
my:
property: fromyamlfile
property2: fromyamlfile
---
spring:
profiles: dev
my:
property: fromdevprofile
---
spring:
profiles: healthcheck
my:
property2: fromhealthcheckprofile
active: dev,healthcheck

View File

@@ -0,0 +1,4 @@
---
spring:
profiles:
active: dev, healthcheck