@ -383,8 +383,8 @@ class ConfigDataEnvironmentPostProcessorIntegrationTests {
List < String > names = StreamSupport . stream ( context . getEnvironment ( ) . getPropertySources ( ) . spliterator ( ) , false )
List < String > names = StreamSupport . stream ( context . getEnvironment ( ) . getPropertySources ( ) . spliterator ( ) , false )
. map ( org . springframework . core . env . PropertySource : : getName ) . collect ( Collectors . toList ( ) ) ;
. map ( org . springframework . core . env . PropertySource : : getName ) . collect ( Collectors . toList ( ) ) ;
assertThat ( names ) . contains (
assertThat ( names ) . contains (
"Config resource 'class path:configdata/profiles/testsetprofiles.yml ' via location 'classpath:configdata/profiles/' (document #0)",
"Config resource 'class path resource [configdata/profiles/testsetprofiles.yml] ' via location 'classpath:configdata/profiles/' (document #0)",
"Config resource 'class path:configdata/profiles/testsetprofiles.yml ' via location 'classpath:configdata/profiles/' (document #1)") ;
"Config resource 'class path resource [configdata/profiles/testsetprofiles.yml] ' via location 'classpath:configdata/profiles/' (document #1)") ;
}
}
@Test
@Test
@ -411,7 +411,7 @@ class ConfigDataEnvironmentPostProcessorIntegrationTests {
String location = "file:src/test/resources/specificlocation.properties" ;
String location = "file:src/test/resources/specificlocation.properties" ;
ConfigurableApplicationContext context = this . application . run ( "--spring.config.location=" + location ) ;
ConfigurableApplicationContext context = this . application . run ( "--spring.config.location=" + location ) ;
assertThat ( context . getEnvironment ( ) ) . has ( matchingPropertySource (
assertThat ( context . getEnvironment ( ) ) . has ( matchingPropertySource (
"Config resource 'file :src/test/resources/specificlocation.properties ' via location '" + location
"Config resource 'file [src/test/resources/specificlocation.properties] ' via location '" + location
+ "'" ) ) ;
+ "'" ) ) ;
}
}
@ -420,7 +420,8 @@ class ConfigDataEnvironmentPostProcessorIntegrationTests {
String location = "src/test/resources/specificlocation.properties" ;
String location = "src/test/resources/specificlocation.properties" ;
ConfigurableApplicationContext context = this . application . run ( "--spring.config.location=" + location ) ;
ConfigurableApplicationContext context = this . application . run ( "--spring.config.location=" + location ) ;
assertThat ( context . getEnvironment ( ) ) . has ( matchingPropertySource (
assertThat ( context . getEnvironment ( ) ) . has ( matchingPropertySource (
"Config resource 'src/test/resources/specificlocation.properties' via location '" + location + "'" ) ) ;
"Config resource 'file [src/test/resources/specificlocation.properties]' via location '" + location
+ "'" ) ) ;
}
}
@Test
@Test
@ -619,6 +620,16 @@ class ConfigDataEnvironmentPostProcessorIntegrationTests {
assertThat ( origin . getParent ( ) . toString ( ) ) . contains ( "application-import-with-placeholder" ) ;
assertThat ( origin . getParent ( ) . toString ( ) ) . contains ( "application-import-with-placeholder" ) ;
}
}
@Test
void runWhenHasWildcardLocationLoadsFromAllMatchingLocations ( ) {
ConfigurableApplicationContext context = this . application . run (
"--spring.config.location=optional:file:src/test/resources/config/*/" ,
"--spring.config.name=testproperties" ) ;
ConfigurableEnvironment environment = context . getEnvironment ( ) ;
assertThat ( environment . getProperty ( "first.property" ) ) . isEqualTo ( "apple" ) ;
assertThat ( environment . getProperty ( "second.property" ) ) . isEqualTo ( "ball" ) ;
}
private Condition < ConfigurableEnvironment > matchingPropertySource ( final String sourceName ) {
private Condition < ConfigurableEnvironment > matchingPropertySource ( final String sourceName ) {
return new Condition < ConfigurableEnvironment > ( "environment containing property source " + sourceName ) {
return new Condition < ConfigurableEnvironment > ( "environment containing property source " + sourceName ) {