@@ -229,6 +229,13 @@ public void withSameSourceImportedInDifferentOrder() throws Exception {
229
229
assertThat (ctx .getEnvironment ().getProperty ("testbean.name" ), equalTo ("p2TestBean" ));
230
230
}
231
231
232
+ @ Test
233
+ public void orderingWithAndWithoutNameAndFourResourceLocations () {
234
+ // SPR-12198: p4 should 'win' as it was registered last
235
+ AnnotationConfigApplicationContext ctxWithoutName = new AnnotationConfigApplicationContext (ConfigWithFourResourceLocations .class );
236
+ assertThat (ctxWithoutName .getEnvironment ().getProperty ("testbean.name" ), equalTo ("p4TestBean" ));
237
+ }
238
+
232
239
233
240
@ Configuration
234
241
@ PropertySource (value ="classpath:${unresolvable}/p1.properties" )
@@ -367,8 +374,8 @@ static class ConfigWithPropertySources {
367
374
368
375
@ Configuration
369
376
@ PropertySources ({
370
- @ PropertySource (name = "psName" , value = "classpath:org/springframework/context/annotation/p1.properties" ),
371
- @ PropertySource (name = "psName" , value = "classpath:org/springframework/context/annotation/p2.properties" ),
377
+ @ PropertySource (name = "psName" , value = "classpath:org/springframework/context/annotation/p1.properties" ),
378
+ @ PropertySource (name = "psName" , value = "classpath:org/springframework/context/annotation/p2.properties" ),
372
379
})
373
380
static class ConfigWithNamedPropertySources {
374
381
}
@@ -401,7 +408,7 @@ static class ConfigWithEmptyResourceLocations {
401
408
}
402
409
403
410
404
- @ Import ({ ConfigImportedWithSameSourceImportedInDifferentOrder .class } )
411
+ @ Import (ConfigImportedWithSameSourceImportedInDifferentOrder .class )
405
412
@ PropertySources ({
406
413
@ PropertySource ("classpath:org/springframework/context/annotation/p1.properties" ),
407
414
@ PropertySource ("classpath:org/springframework/context/annotation/p2.properties" )
@@ -420,4 +427,16 @@ public static class ConfigWithSameSourceImportedInDifferentOrder {
420
427
public static class ConfigImportedWithSameSourceImportedInDifferentOrder {
421
428
}
422
429
430
+
431
+ @ Configuration
432
+ @ PropertySource (
433
+ value = {
434
+ "classpath:org/springframework/context/annotation/p1.properties" ,
435
+ "classpath:org/springframework/context/annotation/p2.properties" ,
436
+ "classpath:org/springframework/context/annotation/p3.properties" ,
437
+ "classpath:org/springframework/context/annotation/p4.properties"
438
+ })
439
+ static class ConfigWithFourResourceLocations {
440
+ }
441
+
423
442
}
0 commit comments