Skip to content

Commit d7ec20a

Browse files
committed
Test for property placeholder with defaults
Test property placeholder with multiple locations and default values. Issue: SPR-10619
1 parent ae74a21 commit d7ec20a

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,4 +265,23 @@ public void getAppliedPropertySourcesTooEarly() throws Exception {
265265
thrown.expect(IllegalStateException.class);
266266
ppc.getAppliedPropertySources();
267267
}
268+
269+
@Test
270+
public void multipleLocationsWithDefaultResolvedValue() throws Exception {
271+
// SPR-10619
272+
PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer();
273+
ClassPathResource doesNotHave = new ClassPathResource("test.properties", getClass());
274+
ClassPathResource setToTrue = new ClassPathResource("placeholder.properties", getClass());
275+
ppc.setLocations(new Resource[] { doesNotHave, setToTrue });
276+
ppc.setIgnoreResourceNotFound(true);
277+
ppc.setIgnoreUnresolvablePlaceholders(true);
278+
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
279+
bf.registerBeanDefinition("testBean",
280+
genericBeanDefinition(TestBean.class)
281+
.addPropertyValue("jedi", "${jedi:false}")
282+
.getBeanDefinition());
283+
ppc.postProcessBeanFactory(bf);
284+
assertThat(bf.getBean(TestBean.class).isJedi(), equalTo(true));
285+
}
286+
268287
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
targetName=wrappedAssemblerOne
22
logicName=logicTwo
33
realLogicName=realLogic
4+
jedi=true

0 commit comments

Comments
 (0)