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:
@@ -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");
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
spring.profiles.active=myprofile,another
|
||||
my.property=fromtwopropertiesfile
|
||||
Reference in New Issue
Block a user