use of cn.taketoday.core.env.PropertySource in project today-infrastructure by TAKETODAY.
the class ConfigDataLoadersTests method createConfigData.
private static ConfigData createConfigData(ConfigDataLoader<?> loader, ConfigDataResource resource) {
MockPropertySource propertySource = new MockPropertySource();
propertySource.setProperty("loader", loader);
propertySource.setProperty("resource", resource);
List<PropertySource<?>> propertySources = Arrays.asList(propertySource);
return new ConfigData(propertySources);
}
use of cn.taketoday.core.env.PropertySource in project today-infrastructure by TAKETODAY.
the class PropertySourcesPlaceholderConfigurerTests method withNonEnumerablePropertySource.
@Test
public void withNonEnumerablePropertySource() {
StandardBeanFactory bf = new StandardBeanFactory();
bf.registerBeanDefinition("testBean", genericBeanDefinition(TestBean.class).addPropertyValue("name", "${foo}").getBeanDefinition());
PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer();
PropertySource<?> ps = new PropertySource<>("simplePropertySource", new Object()) {
@Override
public Object getProperty(String key) {
return "bar";
}
};
MockEnvironment env = new MockEnvironment();
env.getPropertySources().addFirst(ps);
ppc.setEnvironment(env);
ppc.postProcessBeanFactory(bf);
assertThat(bf.getBean(TestBean.class).getName()).isEqualTo("bar");
}
Aggregations