Browse Source

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
pull/535/merge
Dave Syer 12 years ago
parent
commit
63de33ef3e
  1. 13
      spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java
  2. 2
      spring-boot/src/test/resources/enabletwoprofiles.properties

13
spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java

@ -110,6 +110,19 @@ public class ConfigFileApplicationListenerTests { @@ -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");

2
spring-boot/src/test/resources/enabletwoprofiles.properties

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