Support for resource patterns in @PropertySource locations
Closes gh-21325
This commit is contained in:
@@ -234,6 +234,14 @@ class PropertySourceAnnotationTests {
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
void multipleResourcesFromPropertySourcePattern() { // gh-21325
|
||||
ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(ResourcePatternConfig.class);
|
||||
ctx.getBean(ResourcePatternConfig.class);
|
||||
assertEnvironmentContainsProperties(ctx, "from.p1", "from.p2", "from.p3", "from.p4", "from.p5");
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
void withNamedPropertySources() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithNamedPropertySources.class);
|
||||
@@ -277,15 +285,15 @@ class PropertySourceAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void orderingWithAndWithoutNameAndFourResourceLocations() {
|
||||
void orderingWithFourResourceLocations() {
|
||||
// SPR-12198: p4 should 'win' as it was registered last
|
||||
AnnotationConfigApplicationContext ctxWithoutName = new AnnotationConfigApplicationContext(ConfigWithFourResourceLocations.class);
|
||||
assertEnvironmentProperty(ctxWithoutName, "testbean.name", "p4TestBean");
|
||||
ctxWithoutName.close();
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithFourResourceLocations.class);
|
||||
assertEnvironmentProperty(ctx, "testbean.name", "p4TestBean");
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
void orderingDoesntReplaceExisting() throws Exception {
|
||||
void orderingDoesntReplaceExisting() {
|
||||
// SPR-12198: mySource should 'win' as it was registered manually
|
||||
AnnotationConfigApplicationContext ctxWithoutName = new AnnotationConfigApplicationContext();
|
||||
MapPropertySource mySource = new MapPropertySource("mine", Map.of("testbean.name", "myTestBean"));
|
||||
@@ -522,6 +530,12 @@ class PropertySourceAnnotationTests {
|
||||
static class MultipleComposedAnnotationsConfig {
|
||||
}
|
||||
|
||||
|
||||
@PropertySource("classpath*:org/springframework/context/annotation/p?.properties")
|
||||
static class ResourcePatternConfig {
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@PropertySources({
|
||||
@PropertySource(name = "psName", value = "classpath:org/springframework/context/annotation/p1.properties"),
|
||||
|
||||
Reference in New Issue
Block a user