Test for property placeholder with defaults

Test property placeholder with multiple locations and default values.

Issue: SPR-10619
This commit is contained in:
Phillip Webb 2013-06-03 09:37:43 -07:00
parent ae74a2158a
commit d7ec20a286
2 changed files with 20 additions and 0 deletions

View File

@ -265,4 +265,23 @@ public class PropertySourcesPlaceholderConfigurerTests {
thrown.expect(IllegalStateException.class);
ppc.getAppliedPropertySources();
}
@Test
public void multipleLocationsWithDefaultResolvedValue() throws Exception {
// SPR-10619
PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer();
ClassPathResource doesNotHave = new ClassPathResource("test.properties", getClass());
ClassPathResource setToTrue = new ClassPathResource("placeholder.properties", getClass());
ppc.setLocations(new Resource[] { doesNotHave, setToTrue });
ppc.setIgnoreResourceNotFound(true);
ppc.setIgnoreUnresolvablePlaceholders(true);
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
bf.registerBeanDefinition("testBean",
genericBeanDefinition(TestBean.class)
.addPropertyValue("jedi", "${jedi:false}")
.getBeanDefinition());
ppc.postProcessBeanFactory(bf);
assertThat(bf.getBean(TestBean.class).isJedi(), equalTo(true));
}
}

View File

@ -1,3 +1,4 @@
targetName=wrappedAssemblerOne
logicName=logicTwo
realLogicName=realLogic
jedi=true