use of cn.taketoday.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition in project today-infrastructure by TAKETODAY.
the class PropertyResourceConfigurerTests method testPropertyOverrideConfigurerWithConvertProperties.
@Test
public void testPropertyOverrideConfigurerWithConvertProperties() {
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
factory.registerBeanDefinition("tb", def);
ConvertingOverrideConfigurer bfpp = new ConvertingOverrideConfigurer();
Properties props = new Properties();
props.setProperty("tb.array[0].name", "99");
props.setProperty("tb.list[1].name", "test");
bfpp.setProperties(props);
bfpp.postProcessBeanFactory(factory);
IndexedTestBean tb = (IndexedTestBean) factory.getBean("tb");
assertThat(tb.getArray()[0].getName()).isEqualTo("X99");
assertThat(((TestBean) tb.getList().get(1)).getName()).isEqualTo("Xtest");
}
use of cn.taketoday.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition in project today-infrastructure by TAKETODAY.
the class PropertyResourceConfigurerTests method testPropertyOverrideConfigurerWithPropertiesFile.
@Test
public void testPropertyOverrideConfigurerWithPropertiesFile() {
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
factory.registerBeanDefinition("tb", def);
PropertyOverrideConfigurer poc = new PropertyOverrideConfigurer();
poc.setLocation(TEST_PROPS);
poc.postProcessBeanFactory(factory);
IndexedTestBean tb = (IndexedTestBean) factory.getBean("tb");
assertThat(tb.getArray()[0].getAge()).isEqualTo(99);
assertThat(((TestBean) tb.getList().get(1)).getName()).isEqualTo("test");
}
use of cn.taketoday.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition in project today-infrastructure by TAKETODAY.
the class PropertyResourceConfigurerTests method testPropertyOverrideConfigurerWithNestedPropertyAndDotInBeanName.
@Test
public void testPropertyOverrideConfigurerWithNestedPropertyAndDotInBeanName() {
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
factory.registerBeanDefinition("my.tb", def);
PropertyOverrideConfigurer poc;
poc = new PropertyOverrideConfigurer();
Properties props = new Properties();
props.setProperty("my.tb_array[0].age", "99");
props.setProperty("my.tb_list[1].name", "test");
poc.setProperties(props);
poc.setBeanNameSeparator("_");
poc.postProcessBeanFactory(factory);
IndexedTestBean tb = (IndexedTestBean) factory.getBean("my.tb");
assertThat(tb.getArray()[0].getAge()).isEqualTo(99);
assertThat(((TestBean) tb.getList().get(1)).getName()).isEqualTo("test");
}
use of cn.taketoday.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition in project today-infrastructure by TAKETODAY.
the class PropertyResourceConfigurerTests method testPropertyOverrideConfigurerWithInvalidPropertiesFile.
@Test
public void testPropertyOverrideConfigurerWithInvalidPropertiesFile() {
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
factory.registerBeanDefinition("tb", def);
PropertyOverrideConfigurer poc = new PropertyOverrideConfigurer();
poc.setLocations(TEST_PROPS, XTEST_PROPS);
poc.setIgnoreResourceNotFound(true);
poc.postProcessBeanFactory(factory);
IndexedTestBean tb = (IndexedTestBean) factory.getBean("tb");
assertThat(tb.getArray()[0].getAge()).isEqualTo(99);
assertThat(((TestBean) tb.getList().get(1)).getName()).isEqualTo("test");
}
use of cn.taketoday.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition in project today-infrastructure by TAKETODAY.
the class PropertyResourceConfigurerTests method testPropertyOverrideConfigurerWithPropertiesXmlFile.
@Test
public void testPropertyOverrideConfigurerWithPropertiesXmlFile() {
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
factory.registerBeanDefinition("tb", def);
PropertyOverrideConfigurer poc = new PropertyOverrideConfigurer();
poc.setLocation(TEST_PROPS_XML);
poc.postProcessBeanFactory(factory);
IndexedTestBean tb = (IndexedTestBean) factory.getBean("tb");
assertThat(tb.getArray()[0].getAge()).isEqualTo(99);
assertThat(((TestBean) tb.getList().get(1)).getName()).isEqualTo("test");
}
Aggregations