Add further test for activating profiles

The new test asserts that a profile defined in one profile can be
switched off in another. Seems to work.

More gh-483
This commit is contained in:
Dave Syer
2014-03-20 15:41:22 +00:00
parent d08d98492d
commit 63de33ef3e
2 changed files with 15 additions and 0 deletions

View File

@@ -110,6 +110,19 @@ public class ConfigFileApplicationListenerTests {
assertThat(property, equalTo("fromotherpropertiesfile"));
}
@Test
public void loadTwoPropertiesFilesWithProfilesAndSwitchOneOff() throws Exception {
EnvironmentTestUtils.addEnvironment(this.environment, "spring.config.location:"
+ "classpath:enabletwoprofiles.properties,"
+ "classpath:enableprofile.properties");
this.initializer.onApplicationEvent(this.event);
assertEquals("myprofile",
StringUtils.arrayToCommaDelimitedString(this.environment
.getActiveProfiles()));
String property = this.environment.getProperty("my.property");
assertThat(property, equalTo("fromtwopropertiesfile"));
}
@Test
public void localFileTakesPrecedenceOverClasspath() throws Exception {
File localFile = new File(new File("."), "application.properties");

View File

@@ -0,0 +1,2 @@
spring.profiles.active=myprofile,another
my.property=fromtwopropertiesfile