PropertyResourceConfigurerTests accepts "." in operating system name
Issue: SPR-12794
This commit is contained in:
parent
c7fcf7cd4c
commit
6fe85c2dd4
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -27,7 +27,6 @@ import java.util.prefs.BackingStoreException;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
import java.util.prefs.PreferencesFactory;
|
import java.util.prefs.PreferencesFactory;
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.beans.MutablePropertyValues;
|
import org.springframework.beans.MutablePropertyValues;
|
||||||
|
@ -53,13 +52,13 @@ import static org.springframework.tests.TestResourceUtils.*;
|
||||||
* {@link PropertyPlaceholderConfigurer}, {@link PropertyOverrideConfigurer} and
|
* {@link PropertyPlaceholderConfigurer}, {@link PropertyOverrideConfigurer} and
|
||||||
* {@link PreferencesPlaceholderConfigurer}.
|
* {@link PreferencesPlaceholderConfigurer}.
|
||||||
*
|
*
|
||||||
* @see PropertyPlaceholderConfigurerTests
|
|
||||||
* @since 02.10.2003
|
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
|
* @since 02.10.2003
|
||||||
|
* @see PropertyPlaceholderConfigurerTests
|
||||||
*/
|
*/
|
||||||
public final class PropertyResourceConfigurerTests {
|
public class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
System.setProperty("java.util.prefs.PreferencesFactory", MockPreferencesFactory.class.getName());
|
System.setProperty("java.util.prefs.PreferencesFactory", MockPreferencesFactory.class.getName());
|
||||||
|
@ -70,23 +69,15 @@ public final class PropertyResourceConfigurerTests {
|
||||||
private static final Resource XTEST_PROPS = qualifiedResource(CLASS, "xtest.properties"); // does not exist
|
private static final Resource XTEST_PROPS = qualifiedResource(CLASS, "xtest.properties"); // does not exist
|
||||||
private static final Resource TEST_PROPS_XML = qualifiedResource(CLASS, "test.properties.xml");
|
private static final Resource TEST_PROPS_XML = qualifiedResource(CLASS, "test.properties.xml");
|
||||||
|
|
||||||
private DefaultListableBeanFactory factory;
|
private final DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
factory = new DefaultListableBeanFactory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurer() {
|
public void testPropertyOverrideConfigurer() {
|
||||||
BeanDefinition def1 = BeanDefinitionBuilder
|
BeanDefinition def1 = BeanDefinitionBuilder.genericBeanDefinition(TestBean.class).getBeanDefinition();
|
||||||
.genericBeanDefinition(TestBean.class)
|
|
||||||
.getBeanDefinition();
|
|
||||||
factory.registerBeanDefinition("tb1", def1);
|
factory.registerBeanDefinition("tb1", def1);
|
||||||
|
|
||||||
BeanDefinition def2 = BeanDefinitionBuilder
|
BeanDefinition def2 = BeanDefinitionBuilder.genericBeanDefinition(TestBean.class).getBeanDefinition();
|
||||||
.genericBeanDefinition(TestBean.class)
|
|
||||||
.getBeanDefinition();
|
|
||||||
factory.registerBeanDefinition("tb2", def2);
|
factory.registerBeanDefinition("tb2", def2);
|
||||||
|
|
||||||
PropertyOverrideConfigurer poc1;
|
PropertyOverrideConfigurer poc1;
|
||||||
|
@ -123,9 +114,7 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurerWithNestedProperty() {
|
public void testPropertyOverrideConfigurerWithNestedProperty() {
|
||||||
BeanDefinition def = BeanDefinitionBuilder
|
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
|
||||||
.genericBeanDefinition(IndexedTestBean.class)
|
|
||||||
.getBeanDefinition();
|
|
||||||
factory.registerBeanDefinition("tb", def);
|
factory.registerBeanDefinition("tb", def);
|
||||||
|
|
||||||
PropertyOverrideConfigurer poc;
|
PropertyOverrideConfigurer poc;
|
||||||
|
@ -143,9 +132,7 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurerWithNestedPropertyAndDotInBeanName() {
|
public void testPropertyOverrideConfigurerWithNestedPropertyAndDotInBeanName() {
|
||||||
BeanDefinition def = BeanDefinitionBuilder
|
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
|
||||||
.genericBeanDefinition(IndexedTestBean.class)
|
|
||||||
.getBeanDefinition();
|
|
||||||
factory.registerBeanDefinition("my.tb", def);
|
factory.registerBeanDefinition("my.tb", def);
|
||||||
|
|
||||||
PropertyOverrideConfigurer poc;
|
PropertyOverrideConfigurer poc;
|
||||||
|
@ -164,9 +151,7 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurerWithNestedMapPropertyAndDotInMapKey() {
|
public void testPropertyOverrideConfigurerWithNestedMapPropertyAndDotInMapKey() {
|
||||||
BeanDefinition def = BeanDefinitionBuilder
|
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
|
||||||
.genericBeanDefinition(IndexedTestBean.class)
|
|
||||||
.getBeanDefinition();
|
|
||||||
factory.registerBeanDefinition("tb", def);
|
factory.registerBeanDefinition("tb", def);
|
||||||
|
|
||||||
PropertyOverrideConfigurer poc;
|
PropertyOverrideConfigurer poc;
|
||||||
|
@ -184,9 +169,7 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurerWithHeldProperties() {
|
public void testPropertyOverrideConfigurerWithHeldProperties() {
|
||||||
BeanDefinition def = BeanDefinitionBuilder
|
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(PropertiesHolder.class).getBeanDefinition();
|
||||||
.genericBeanDefinition(PropertiesHolder.class)
|
|
||||||
.getBeanDefinition();
|
|
||||||
factory.registerBeanDefinition("tb", def);
|
factory.registerBeanDefinition("tb", def);
|
||||||
|
|
||||||
PropertyOverrideConfigurer poc;
|
PropertyOverrideConfigurer poc;
|
||||||
|
@ -200,23 +183,9 @@ public final class PropertyResourceConfigurerTests {
|
||||||
assertEquals("true", tb.getHeldProperties().getProperty("mail.smtp.auth"));
|
assertEquals("true", tb.getHeldProperties().getProperty("mail.smtp.auth"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static class PropertiesHolder {
|
|
||||||
private Properties props = new Properties();
|
|
||||||
|
|
||||||
public Properties getHeldProperties() {
|
|
||||||
return props;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHeldProperties(Properties props) {
|
|
||||||
this.props = props;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurerWithPropertiesFile() {
|
public void testPropertyOverrideConfigurerWithPropertiesFile() {
|
||||||
BeanDefinition def = BeanDefinitionBuilder
|
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
|
||||||
.genericBeanDefinition(IndexedTestBean.class)
|
|
||||||
.getBeanDefinition();
|
|
||||||
factory.registerBeanDefinition("tb", def);
|
factory.registerBeanDefinition("tb", def);
|
||||||
|
|
||||||
PropertyOverrideConfigurer poc = new PropertyOverrideConfigurer();
|
PropertyOverrideConfigurer poc = new PropertyOverrideConfigurer();
|
||||||
|
@ -230,13 +199,11 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurerWithInvalidPropertiesFile() {
|
public void testPropertyOverrideConfigurerWithInvalidPropertiesFile() {
|
||||||
BeanDefinition def = BeanDefinitionBuilder
|
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
|
||||||
.genericBeanDefinition(IndexedTestBean.class)
|
|
||||||
.getBeanDefinition();
|
|
||||||
factory.registerBeanDefinition("tb", def);
|
factory.registerBeanDefinition("tb", def);
|
||||||
|
|
||||||
PropertyOverrideConfigurer poc = new PropertyOverrideConfigurer();
|
PropertyOverrideConfigurer poc = new PropertyOverrideConfigurer();
|
||||||
poc.setLocations(new Resource[] { TEST_PROPS, XTEST_PROPS });
|
poc.setLocations(TEST_PROPS, XTEST_PROPS);
|
||||||
poc.setIgnoreResourceNotFound(true);
|
poc.setIgnoreResourceNotFound(true);
|
||||||
poc.postProcessBeanFactory(factory);
|
poc.postProcessBeanFactory(factory);
|
||||||
|
|
||||||
|
@ -247,9 +214,7 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurerWithPropertiesXmlFile() {
|
public void testPropertyOverrideConfigurerWithPropertiesXmlFile() {
|
||||||
BeanDefinition def = BeanDefinitionBuilder
|
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
|
||||||
.genericBeanDefinition(IndexedTestBean.class)
|
|
||||||
.getBeanDefinition();
|
|
||||||
factory.registerBeanDefinition("tb", def);
|
factory.registerBeanDefinition("tb", def);
|
||||||
|
|
||||||
PropertyOverrideConfigurer poc = new PropertyOverrideConfigurer();
|
PropertyOverrideConfigurer poc = new PropertyOverrideConfigurer();
|
||||||
|
@ -263,9 +228,7 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyOverrideConfigurerWithConvertProperties() {
|
public void testPropertyOverrideConfigurerWithConvertProperties() {
|
||||||
BeanDefinition def = BeanDefinitionBuilder
|
BeanDefinition def = BeanDefinitionBuilder.genericBeanDefinition(IndexedTestBean.class).getBeanDefinition();
|
||||||
.genericBeanDefinition(IndexedTestBean.class)
|
|
||||||
.getBeanDefinition();
|
|
||||||
factory.registerBeanDefinition("tb", def);
|
factory.registerBeanDefinition("tb", def);
|
||||||
|
|
||||||
ConvertingOverrideConfigurer bfpp = new ConvertingOverrideConfigurer();
|
ConvertingOverrideConfigurer bfpp = new ConvertingOverrideConfigurer();
|
||||||
|
@ -389,7 +352,6 @@ public final class PropertyResourceConfigurerTests {
|
||||||
cas.addGenericArgumentValue("${var}name${age}");
|
cas.addGenericArgumentValue("${var}name${age}");
|
||||||
|
|
||||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||||
|
|
||||||
pvs.add("stringArray", new String[] {"${os.name}", "${age}"});
|
pvs.add("stringArray", new String[] {"${os.name}", "${age}"});
|
||||||
|
|
||||||
List<Object> friends = new ManagedList<Object>();
|
List<Object> friends = new ManagedList<Object>();
|
||||||
|
@ -409,7 +371,7 @@ public final class PropertyResourceConfigurerTests {
|
||||||
someMap.put("key1", new RuntimeBeanReference("${ref}"));
|
someMap.put("key1", new RuntimeBeanReference("${ref}"));
|
||||||
someMap.put("key2", "${age}name");
|
someMap.put("key2", "${age}name");
|
||||||
MutablePropertyValues innerPvs = new MutablePropertyValues();
|
MutablePropertyValues innerPvs = new MutablePropertyValues();
|
||||||
innerPvs.add("touchy", "${os.name}");
|
innerPvs.add("country", "${os.name}");
|
||||||
RootBeanDefinition innerBd = new RootBeanDefinition(TestBean.class);
|
RootBeanDefinition innerBd = new RootBeanDefinition(TestBean.class);
|
||||||
innerBd.setPropertyValues(innerPvs);
|
innerBd.setPropertyValues(innerPvs);
|
||||||
someMap.put("key3", innerBd);
|
someMap.put("key3", innerBd);
|
||||||
|
@ -459,30 +421,28 @@ public final class PropertyResourceConfigurerTests {
|
||||||
TestBean inner2 = (TestBean) tb2.getSomeMap().get("mykey4");
|
TestBean inner2 = (TestBean) tb2.getSomeMap().get("mykey4");
|
||||||
assertEquals(0, inner1.getAge());
|
assertEquals(0, inner1.getAge());
|
||||||
assertEquals(null, inner1.getName());
|
assertEquals(null, inner1.getName());
|
||||||
assertEquals(System.getProperty("os.name"), inner1.getTouchy());
|
assertEquals(System.getProperty("os.name"), inner1.getCountry());
|
||||||
assertEquals(98, inner2.getAge());
|
assertEquals(98, inner2.getAge());
|
||||||
assertEquals("namemyvarmyvar${", inner2.getName());
|
assertEquals("namemyvarmyvar${", inner2.getName());
|
||||||
assertEquals(System.getProperty("os.name"), inner2.getTouchy());
|
assertEquals(System.getProperty("os.name"), inner2.getCountry());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyPlaceholderConfigurerWithSystemPropertyFallback() {
|
public void testPropertyPlaceholderConfigurerWithSystemPropertyFallback() {
|
||||||
factory.registerBeanDefinition("tb",
|
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
|
||||||
genericBeanDefinition(TestBean.class)
|
.addPropertyValue("country", "${os.name}").getBeanDefinition());
|
||||||
.addPropertyValue("touchy", "${os.name}").getBeanDefinition());
|
|
||||||
|
|
||||||
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
||||||
ppc.postProcessBeanFactory(factory);
|
ppc.postProcessBeanFactory(factory);
|
||||||
|
|
||||||
TestBean tb = (TestBean) factory.getBean("tb");
|
TestBean tb = (TestBean) factory.getBean("tb");
|
||||||
assertEquals(System.getProperty("os.name"), tb.getTouchy());
|
assertEquals(System.getProperty("os.name"), tb.getCountry());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyPlaceholderConfigurerWithSystemPropertyNotUsed() {
|
public void testPropertyPlaceholderConfigurerWithSystemPropertyNotUsed() {
|
||||||
factory.registerBeanDefinition("tb",
|
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
|
||||||
genericBeanDefinition(TestBean.class)
|
.addPropertyValue("country", "${os.name}").getBeanDefinition());
|
||||||
.addPropertyValue("touchy", "${os.name}").getBeanDefinition());
|
|
||||||
|
|
||||||
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
@ -491,14 +451,13 @@ public final class PropertyResourceConfigurerTests {
|
||||||
ppc.postProcessBeanFactory(factory);
|
ppc.postProcessBeanFactory(factory);
|
||||||
|
|
||||||
TestBean tb = (TestBean) factory.getBean("tb");
|
TestBean tb = (TestBean) factory.getBean("tb");
|
||||||
assertEquals("myos", tb.getTouchy());
|
assertEquals("myos", tb.getCountry());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyPlaceholderConfigurerWithOverridingSystemProperty() {
|
public void testPropertyPlaceholderConfigurerWithOverridingSystemProperty() {
|
||||||
factory.registerBeanDefinition("tb",
|
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
|
||||||
genericBeanDefinition(TestBean.class)
|
.addPropertyValue("country", "${os.name}").getBeanDefinition());
|
||||||
.addPropertyValue("touchy", "${os.name}").getBeanDefinition());
|
|
||||||
|
|
||||||
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
@ -508,14 +467,13 @@ public final class PropertyResourceConfigurerTests {
|
||||||
ppc.postProcessBeanFactory(factory);
|
ppc.postProcessBeanFactory(factory);
|
||||||
|
|
||||||
TestBean tb = (TestBean) factory.getBean("tb");
|
TestBean tb = (TestBean) factory.getBean("tb");
|
||||||
assertEquals(System.getProperty("os.name"), tb.getTouchy());
|
assertEquals(System.getProperty("os.name"), tb.getCountry());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyPlaceholderConfigurerWithUnresolvableSystemProperty() {
|
public void testPropertyPlaceholderConfigurerWithUnresolvableSystemProperty() {
|
||||||
factory.registerBeanDefinition("tb",
|
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
|
||||||
genericBeanDefinition(TestBean.class)
|
.addPropertyValue("touchy", "${user.dir}").getBeanDefinition());
|
||||||
.addPropertyValue("touchy", "${user.dir}").getBeanDefinition());
|
|
||||||
|
|
||||||
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
||||||
ppc.setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_NEVER);
|
ppc.setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_NEVER);
|
||||||
|
@ -532,9 +490,8 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyPlaceholderConfigurerWithUnresolvablePlaceholder() {
|
public void testPropertyPlaceholderConfigurerWithUnresolvablePlaceholder() {
|
||||||
factory.registerBeanDefinition("tb",
|
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
|
||||||
genericBeanDefinition(TestBean.class)
|
.addPropertyValue("name", "${ref}").getBeanDefinition());
|
||||||
.addPropertyValue("name", "${ref}").getBeanDefinition());
|
|
||||||
|
|
||||||
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
||||||
|
|
||||||
|
@ -550,9 +507,8 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyPlaceholderConfigurerWithIgnoreUnresolvablePlaceholder() {
|
public void testPropertyPlaceholderConfigurerWithIgnoreUnresolvablePlaceholder() {
|
||||||
factory.registerBeanDefinition("tb",
|
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
|
||||||
genericBeanDefinition(TestBean.class)
|
.addPropertyValue("name", "${ref}").getBeanDefinition());
|
||||||
.addPropertyValue("name", "${ref}").getBeanDefinition());
|
|
||||||
|
|
||||||
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
||||||
ppc.setIgnoreUnresolvablePlaceholders(true);
|
ppc.setIgnoreUnresolvablePlaceholders(true);
|
||||||
|
@ -564,9 +520,8 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyPlaceholderConfigurerWithEmptyStringAsNull() {
|
public void testPropertyPlaceholderConfigurerWithEmptyStringAsNull() {
|
||||||
factory.registerBeanDefinition("tb",
|
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
|
||||||
genericBeanDefinition(TestBean.class)
|
.addPropertyValue("name", "").getBeanDefinition());
|
||||||
.addPropertyValue("name", "").getBeanDefinition());
|
|
||||||
|
|
||||||
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
||||||
ppc.setNullValue("");
|
ppc.setNullValue("");
|
||||||
|
@ -578,9 +533,8 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyPlaceholderConfigurerWithEmptyStringInPlaceholderAsNull() {
|
public void testPropertyPlaceholderConfigurerWithEmptyStringInPlaceholderAsNull() {
|
||||||
factory.registerBeanDefinition("tb",
|
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
|
||||||
genericBeanDefinition(TestBean.class)
|
.addPropertyValue("name", "${ref}").getBeanDefinition());
|
||||||
.addPropertyValue("name", "${ref}").getBeanDefinition());
|
|
||||||
|
|
||||||
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
||||||
ppc.setNullValue("");
|
ppc.setNullValue("");
|
||||||
|
@ -595,9 +549,8 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyPlaceholderConfigurerWithNestedPlaceholderInKey() {
|
public void testPropertyPlaceholderConfigurerWithNestedPlaceholderInKey() {
|
||||||
factory.registerBeanDefinition("tb",
|
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
|
||||||
genericBeanDefinition(TestBean.class)
|
.addPropertyValue("name", "${my${key}key}").getBeanDefinition());
|
||||||
.addPropertyValue("name", "${my${key}key}").getBeanDefinition());
|
|
||||||
|
|
||||||
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
@ -612,8 +565,7 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyPlaceholderConfigurerWithPlaceholderInAlias() {
|
public void testPropertyPlaceholderConfigurerWithPlaceholderInAlias() {
|
||||||
factory.registerBeanDefinition("tb",
|
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class).getBeanDefinition());
|
||||||
genericBeanDefinition(TestBean.class).getBeanDefinition());
|
|
||||||
factory.registerAlias("tb", "${alias}");
|
factory.registerAlias("tb", "${alias}");
|
||||||
|
|
||||||
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
||||||
|
@ -629,8 +581,7 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyPlaceholderConfigurerWithSelfReferencingPlaceholderInAlias() {
|
public void testPropertyPlaceholderConfigurerWithSelfReferencingPlaceholderInAlias() {
|
||||||
factory.registerBeanDefinition("tb",
|
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class).getBeanDefinition());
|
||||||
genericBeanDefinition(TestBean.class).getBeanDefinition());
|
|
||||||
factory.registerAlias("tb", "${alias}");
|
factory.registerAlias("tb", "${alias}");
|
||||||
|
|
||||||
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
||||||
|
@ -646,11 +597,10 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyPlaceholderConfigurerWithCircularReference() {
|
public void testPropertyPlaceholderConfigurerWithCircularReference() {
|
||||||
factory.registerBeanDefinition("tb",
|
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
|
||||||
genericBeanDefinition(TestBean.class)
|
.addPropertyValue("age", "${age}")
|
||||||
.addPropertyValue("age", "${age}")
|
.addPropertyValue("name", "name${var}")
|
||||||
.addPropertyValue("name", "name${var}")
|
.getBeanDefinition());
|
||||||
.getBeanDefinition());
|
|
||||||
|
|
||||||
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
@ -670,9 +620,8 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyPlaceholderConfigurerWithDefaultProperties() {
|
public void testPropertyPlaceholderConfigurerWithDefaultProperties() {
|
||||||
factory.registerBeanDefinition("tb",
|
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
|
||||||
genericBeanDefinition(TestBean.class)
|
.addPropertyValue("touchy", "${test}").getBeanDefinition());
|
||||||
.addPropertyValue("touchy", "${test}").getBeanDefinition());
|
|
||||||
|
|
||||||
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
@ -686,9 +635,8 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyPlaceholderConfigurerWithInlineDefault() {
|
public void testPropertyPlaceholderConfigurerWithInlineDefault() {
|
||||||
factory.registerBeanDefinition("tb",
|
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
|
||||||
genericBeanDefinition(TestBean.class)
|
.addPropertyValue("touchy", "${test:mytest}").getBeanDefinition());
|
||||||
.addPropertyValue("touchy", "${test:mytest}").getBeanDefinition());
|
|
||||||
|
|
||||||
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
|
||||||
ppc.postProcessBeanFactory(factory);
|
ppc.postProcessBeanFactory(factory);
|
||||||
|
@ -699,9 +647,8 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyPlaceholderConfigurerWithAliases() {
|
public void testPropertyPlaceholderConfigurerWithAliases() {
|
||||||
factory.registerBeanDefinition("tb",
|
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
|
||||||
genericBeanDefinition(TestBean.class)
|
.addPropertyValue("touchy", "${test}").getBeanDefinition());
|
||||||
.addPropertyValue("touchy", "${test}").getBeanDefinition());
|
|
||||||
|
|
||||||
factory.registerAlias("tb", "${myAlias}");
|
factory.registerAlias("tb", "${myAlias}");
|
||||||
factory.registerAlias("${myTarget}", "alias2");
|
factory.registerAlias("${myTarget}", "alias2");
|
||||||
|
@ -724,12 +671,11 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPreferencesPlaceholderConfigurer() {
|
public void testPreferencesPlaceholderConfigurer() {
|
||||||
factory.registerBeanDefinition("tb",
|
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
|
||||||
genericBeanDefinition(TestBean.class)
|
.addPropertyValue("name", "${myName}")
|
||||||
.addPropertyValue("name", "${myName}")
|
.addPropertyValue("age", "${myAge}")
|
||||||
.addPropertyValue("age", "${myAge}")
|
.addPropertyValue("touchy", "${myTouchy}")
|
||||||
.addPropertyValue("touchy", "${myTouchy}")
|
.getBeanDefinition());
|
||||||
.getBeanDefinition());
|
|
||||||
|
|
||||||
PreferencesPlaceholderConfigurer ppc = new PreferencesPlaceholderConfigurer();
|
PreferencesPlaceholderConfigurer ppc = new PreferencesPlaceholderConfigurer();
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
@ -752,12 +698,11 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPreferencesPlaceholderConfigurerWithCustomTreePaths() {
|
public void testPreferencesPlaceholderConfigurerWithCustomTreePaths() {
|
||||||
factory.registerBeanDefinition("tb",
|
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
|
||||||
genericBeanDefinition(TestBean.class)
|
.addPropertyValue("name", "${myName}")
|
||||||
.addPropertyValue("name", "${myName}")
|
.addPropertyValue("age", "${myAge}")
|
||||||
.addPropertyValue("age", "${myAge}")
|
.addPropertyValue("touchy", "${myTouchy}")
|
||||||
.addPropertyValue("touchy", "${myTouchy}")
|
.getBeanDefinition());
|
||||||
.getBeanDefinition());
|
|
||||||
|
|
||||||
PreferencesPlaceholderConfigurer ppc = new PreferencesPlaceholderConfigurer();
|
PreferencesPlaceholderConfigurer ppc = new PreferencesPlaceholderConfigurer();
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
@ -782,12 +727,11 @@ public final class PropertyResourceConfigurerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPreferencesPlaceholderConfigurerWithPathInPlaceholder() {
|
public void testPreferencesPlaceholderConfigurerWithPathInPlaceholder() {
|
||||||
factory.registerBeanDefinition("tb",
|
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class)
|
||||||
genericBeanDefinition(TestBean.class)
|
.addPropertyValue("name", "${mypath/myName}")
|
||||||
.addPropertyValue("name", "${mypath/myName}")
|
.addPropertyValue("age", "${myAge}")
|
||||||
.addPropertyValue("age", "${myAge}")
|
.addPropertyValue("touchy", "${myotherpath/myTouchy}")
|
||||||
.addPropertyValue("touchy", "${myotherpath/myTouchy}")
|
.getBeanDefinition());
|
||||||
.getBeanDefinition());
|
|
||||||
|
|
||||||
PreferencesPlaceholderConfigurer ppc = new PreferencesPlaceholderConfigurer();
|
PreferencesPlaceholderConfigurer ppc = new PreferencesPlaceholderConfigurer();
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
@ -811,6 +755,20 @@ public final class PropertyResourceConfigurerTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static class PropertiesHolder {
|
||||||
|
|
||||||
|
private Properties props = new Properties();
|
||||||
|
|
||||||
|
public Properties getHeldProperties() {
|
||||||
|
return props;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeldProperties(Properties props) {
|
||||||
|
this.props = props;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class ConvertingOverrideConfigurer extends PropertyOverrideConfigurer {
|
private static class ConvertingOverrideConfigurer extends PropertyOverrideConfigurer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -819,26 +777,28 @@ public final class PropertyResourceConfigurerTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link PreferencesFactory} to create {@link MockPreferences}.
|
* {@link PreferencesFactory} to create {@link MockPreferences}.
|
||||||
*/
|
*/
|
||||||
public static class MockPreferencesFactory implements PreferencesFactory {
|
public static class MockPreferencesFactory implements PreferencesFactory {
|
||||||
|
|
||||||
private Preferences systemRoot = new MockPreferences();
|
private final Preferences userRoot = new MockPreferences();
|
||||||
|
|
||||||
private Preferences userRoot = new MockPreferences();
|
private final Preferences systemRoot = new MockPreferences();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Preferences systemRoot() {
|
public Preferences systemRoot() {
|
||||||
return systemRoot;
|
return this.systemRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Preferences userRoot() {
|
public Preferences userRoot() {
|
||||||
return userRoot;
|
return this.userRoot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mock implementation of {@link Preferences} that behaves the same regardless of the
|
* Mock implementation of {@link Preferences} that behaves the same regardless of the
|
||||||
* underlying operating system and will never throw security exceptions.
|
* underlying operating system and will never throw security exceptions.
|
||||||
|
@ -904,4 +864,5 @@ public final class PropertyResourceConfigurerTests {
|
||||||
protected void flushSpi() throws BackingStoreException {
|
protected void flushSpi() throws BackingStoreException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue