|
|
@ -153,8 +153,8 @@ public class ConfigFileApplicationListenerTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void yamlProfileCanBeChanged() throws Exception {
|
|
|
|
public void yamlProfileCanBeChanged() throws Exception {
|
|
|
|
EnvironmentTestUtils
|
|
|
|
EnvironmentTestUtils.addEnviroment(this.environment,
|
|
|
|
.addEnviroment(this.environment, "spring.profiles.active:prod");
|
|
|
|
"spring.profiles.active:prod");
|
|
|
|
this.initializer.setNames("testsetprofiles");
|
|
|
|
this.initializer.setNames("testsetprofiles");
|
|
|
|
this.initializer.onApplicationEvent(this.event);
|
|
|
|
this.initializer.onApplicationEvent(this.event);
|
|
|
|
assertThat(Arrays.asList(this.environment.getActiveProfiles()).toString(),
|
|
|
|
assertThat(Arrays.asList(this.environment.getActiveProfiles()).toString(),
|
|
|
@ -189,6 +189,25 @@ public class ConfigFileApplicationListenerTests {
|
|
|
|
assertThat(this.environment.getProperty("foo"), equalTo("bucket"));
|
|
|
|
assertThat(this.environment.getProperty("foo"), equalTo("bucket"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void specificResourceAsFile() throws Exception {
|
|
|
|
|
|
|
|
String location = "file:src/test/resources/specificlocation.properties";
|
|
|
|
|
|
|
|
EnvironmentTestUtils.addEnviroment(this.environment, "spring.config.location:"
|
|
|
|
|
|
|
|
+ location);
|
|
|
|
|
|
|
|
this.initializer.onApplicationEvent(this.event);
|
|
|
|
|
|
|
|
assertThat(this.environment.getPropertySources().contains(location), is(true));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void specificResourceDefaultsToFile() throws Exception {
|
|
|
|
|
|
|
|
String location = "src/test/resources/specificlocation.properties";
|
|
|
|
|
|
|
|
EnvironmentTestUtils.addEnviroment(this.environment, "spring.config.location:"
|
|
|
|
|
|
|
|
+ location);
|
|
|
|
|
|
|
|
this.initializer.onApplicationEvent(this.event);
|
|
|
|
|
|
|
|
assertThat(this.environment.getPropertySources().contains("file:" + location),
|
|
|
|
|
|
|
|
is(true));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void propertySourceAnnotation() throws Exception {
|
|
|
|
public void propertySourceAnnotation() throws Exception {
|
|
|
|
SpringApplication application = new SpringApplication(WithPropertySource.class);
|
|
|
|
SpringApplication application = new SpringApplication(WithPropertySource.class);
|
|
|
|