From 7cd31594c62be1d1109e5b4bb1481895728f5b20 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 5 Apr 2016 15:45:24 +0200 Subject: [PATCH] Polish contribution Closes gh-5561 --- .../ConfigFileApplicationListenerTests.java | 33 ++++--------------- .../test/resources/testsetmultiprofiles.yml | 15 +-------- .../testsetmultiprofileswhitespace.yml | 4 +++ 3 files changed, 12 insertions(+), 40 deletions(-) create mode 100644 spring-boot/src/test/resources/testsetmultiprofileswhitespace.yml diff --git a/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java b/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java index a8b7db2906..8716c216f8 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java @@ -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> sources = propertySource - .getSource(); - assertThat(sources).hasSize(3); - List names = new ArrayList(); - 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 diff --git a/spring-boot/src/test/resources/testsetmultiprofiles.yml b/spring-boot/src/test/resources/testsetmultiprofiles.yml index 42645fb518..462f9d8785 100644 --- a/spring-boot/src/test/resources/testsetmultiprofiles.yml +++ b/spring-boot/src/test/resources/testsetmultiprofiles.yml @@ -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 \ No newline at end of file + active: dev,healthcheck \ No newline at end of file diff --git a/spring-boot/src/test/resources/testsetmultiprofileswhitespace.yml b/spring-boot/src/test/resources/testsetmultiprofileswhitespace.yml new file mode 100644 index 0000000000..8b31dc528c --- /dev/null +++ b/spring-boot/src/test/resources/testsetmultiprofileswhitespace.yml @@ -0,0 +1,4 @@ +--- +spring: + profiles: + active: dev, healthcheck \ No newline at end of file