diff --git a/org.springframework.context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests-custom.properties b/org.springframework.context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests-custom.properties new file mode 100644 index 00000000000..17a2bc67bcc --- /dev/null +++ b/org.springframework.context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests-custom.properties @@ -0,0 +1,3 @@ +hostname=localhost +foo=a +bar=b \ No newline at end of file diff --git a/org.springframework.context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests-custom.xml b/org.springframework.context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests-custom.xml new file mode 100644 index 00000000000..e0c4ef6ea23 --- /dev/null +++ b/org.springframework.context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests-custom.xml @@ -0,0 +1,16 @@ + + + + + + + + + + diff --git a/org.springframework.context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java b/org.springframework.context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java index cacb17f224c..68755bc06f9 100644 --- a/org.springframework.context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java +++ b/org.springframework.context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java @@ -118,4 +118,29 @@ public class AutowiredConfigurationTests { return new TestBean(name); } } + + @Test + public void testCustomProperties() { + ClassPathXmlApplicationContext factory = new ClassPathXmlApplicationContext( + "AutowiredConfigurationTests-custom.xml", AutowiredConfigurationTests.class); + + TestBean testBean = factory.getBean("testBean", TestBean.class); + assertThat(testBean.getName(), equalTo("localhost")); + } + + @Configuration + static class PropertiesConfig { + + private String hostname; + + @Value("#{myProps.hostname}") + public void setHostname(String hostname) { + this.hostname = hostname; + } + + @Bean + public TestBean testBean() { + return new TestBean(hostname); + } + } }