@ -130,6 +130,18 @@ public class PropertySourceAnnotationTests {
assertThat ( ctx . getEnvironment ( ) . containsProperty ( "from.p2" ) , is ( true ) ) ;
assertThat ( ctx . getEnvironment ( ) . containsProperty ( "from.p2" ) , is ( true ) ) ;
}
}
/ * *
* SPR - 10820
* /
@Test
public void orderingWithAndWithoutNameAndMultipleResourceLocations ( ) {
// p2 should 'win' as it was registered last
AnnotationConfigApplicationContext ctxWithName = new AnnotationConfigApplicationContext ( ConfigWithNameAndMultipleResourceLocations . class ) ;
AnnotationConfigApplicationContext ctxWithoutName = new AnnotationConfigApplicationContext ( ConfigWithMultipleResourceLocations . class ) ;
assertThat ( ctxWithoutName . getEnvironment ( ) . getProperty ( "testbean.name" ) , equalTo ( "p2TestBean" ) ) ;
assertThat ( ctxWithName . getEnvironment ( ) . getProperty ( "testbean.name" ) , equalTo ( "p2TestBean" ) ) ;
}
@Test ( expected = IllegalArgumentException . class )
@Test ( expected = IllegalArgumentException . class )
public void withEmptyResourceLocations ( ) {
public void withEmptyResourceLocations ( ) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext ( ) ;
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext ( ) ;
@ -209,6 +221,15 @@ public class PropertySourceAnnotationTests {
static class ConfigWithNameAndMultipleResourceLocations {
static class ConfigWithNameAndMultipleResourceLocations {
}
}
@Configuration
@PropertySource (
value = {
"classpath:org/springframework/context/annotation/p1.properties" ,
"classpath:org/springframework/context/annotation/p2.properties"
} )
static class ConfigWithMultipleResourceLocations {
}
@Configuration
@Configuration
@PropertySource ( value = { } )
@PropertySource ( value = { } )