use of org.springframework.tests.sample.beans.TestBean in project spring-framework by spring-projects.
the class PropertyPlaceholderConfigurerTests method localPropertiesViaResource.
@Test
public void localPropertiesViaResource() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
bf.registerBeanDefinition("testBean", genericBeanDefinition(TestBean.class).addPropertyValue("name", "${my.name}").getBeanDefinition());
PropertyPlaceholderConfigurer pc = new PropertyPlaceholderConfigurer();
Resource resource = new ClassPathResource("PropertyPlaceholderConfigurerTests.properties", this.getClass());
pc.setLocation(resource);
pc.postProcessBeanFactory(bf);
}
use of org.springframework.tests.sample.beans.TestBean in project spring-framework by spring-projects.
the class PropertyPlaceholderConfigurerTests method nullValueIsPreserved.
@Test
public void nullValueIsPreserved() {
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
ppc.setNullValue("customNull");
getModifiableSystemEnvironment().put("my.name", "customNull");
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
bf.registerBeanDefinition("testBean", rootBeanDefinition(TestBean.class).addPropertyValue("name", "${my.name}").getBeanDefinition());
ppc.postProcessBeanFactory(bf);
assertThat(bf.getBean(TestBean.class).getName(), nullValue());
getModifiableSystemEnvironment().remove("my.name");
}
use of org.springframework.tests.sample.beans.TestBean in project spring-framework by spring-projects.
the class PropertyPlaceholderConfigurerTests method setSystemSystemPropertiesMode_toOverride_andSetSearchSystemEnvironment_toFalse.
@Test
public void setSystemSystemPropertiesMode_toOverride_andSetSearchSystemEnvironment_toFalse() {
registerWithGeneratedName(p1BeanDef, bf);
// will now fall all the way back to system environment
System.clearProperty(P1);
ppc.setSearchSystemEnvironment(false);
ppc.setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE);
ppc.postProcessBeanFactory(bf);
TestBean bean = bf.getBean(TestBean.class);
// has to resort to local props
assertThat(bean.getName(), equalTo(P1_LOCAL_PROPS_VAL));
}
use of org.springframework.tests.sample.beans.TestBean in project spring-framework by spring-projects.
the class PropertyPlaceholderConfigurerTests method setSystemPropertiesMode_defaultIsFallback.
@Test
public void setSystemPropertiesMode_defaultIsFallback() {
registerWithGeneratedName(p1BeanDef, bf);
ppc.postProcessBeanFactory(bf);
TestBean bean = bf.getBean(TestBean.class);
assertThat(bean.getName(), equalTo(P1_LOCAL_PROPS_VAL));
}
use of org.springframework.tests.sample.beans.TestBean in project spring-framework by spring-projects.
the class PropertyPlaceholderConfigurerTests method resolveFromLocalProperties.
@Test
public void resolveFromLocalProperties() {
// eliminate entries from system props/environment
tearDown();
registerWithGeneratedName(p1BeanDef, bf);
ppc.postProcessBeanFactory(bf);
TestBean bean = bf.getBean(TestBean.class);
assertThat(bean.getName(), equalTo(P1_LOCAL_PROPS_VAL));
}
Aggregations