Refined tests for property source ordering
Issue: SPR-12198
(cherry picked from commit 205e681)
This commit is contained in:
parent
354c3e03e9
commit
f259ca1b1f
|
|
@ -161,16 +161,6 @@ public class PropertySourceAnnotationTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
@Test
|
||||||
public void withNameAndMultipleResourceLocations() {
|
public void withNameAndMultipleResourceLocations() {
|
||||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithNameAndMultipleResourceLocations.class);
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithNameAndMultipleResourceLocations.class);
|
||||||
|
|
@ -222,13 +212,22 @@ public class PropertySourceAnnotationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void withSameSourceImportedInDifferentOrder() throws Exception {
|
public void withSameSourceImportedInDifferentOrder() {
|
||||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithSameSourceImportedInDifferentOrder.class);
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ConfigWithSameSourceImportedInDifferentOrder.class);
|
||||||
assertThat(ctx.getEnvironment().containsProperty("from.p1"), is(true));
|
assertThat(ctx.getEnvironment().containsProperty("from.p1"), is(true));
|
||||||
assertThat(ctx.getEnvironment().containsProperty("from.p2"), is(true));
|
assertThat(ctx.getEnvironment().containsProperty("from.p2"), is(true));
|
||||||
assertThat(ctx.getEnvironment().getProperty("testbean.name"), equalTo("p2TestBean"));
|
assertThat(ctx.getEnvironment().getProperty("testbean.name"), equalTo("p2TestBean"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void orderingWithAndWithoutNameAndMultipleResourceLocations() {
|
||||||
|
// SPR-10820: 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
|
@Test
|
||||||
public void orderingWithAndWithoutNameAndFourResourceLocations() {
|
public void orderingWithAndWithoutNameAndFourResourceLocations() {
|
||||||
// SPR-12198: p4 should 'win' as it was registered last
|
// SPR-12198: p4 should 'win' as it was registered last
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue