use of cn.taketoday.core.env.MockPropertySource in project today-infrastructure by TAKETODAY.
the class PropertySourcesPlaceholderConfigurerTests method explicitPropertySourcesExcludesLocalProperties.
@Test
@SuppressWarnings("serial")
public void explicitPropertySourcesExcludesLocalProperties() {
StandardBeanFactory bf = new StandardBeanFactory();
bf.registerBeanDefinition("testBean", genericBeanDefinition(TestBean.class).addPropertyValue("name", "${my.name}").getBeanDefinition());
PropertySources propertySources = new PropertySources();
propertySources.addLast(new MockPropertySource());
PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer();
ppc.setPropertySources(propertySources);
ppc.setProperties(new Properties() {
{
put("my.name", "local");
}
});
ppc.setIgnoreUnresolvablePlaceholders(true);
ppc.postProcessBeanFactory(bf);
assertThat(bf.getBean(TestBean.class).getName()).isEqualTo("${my.name}");
}
Aggregations