Extended the test to show the user how to properly make use of the Spring PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_XYZ setting.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c6b751b9 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c6b751b9 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c6b751b9 Branch: refs/heads/camel-2.12.x Commit: c6b751b91bcd2642d09773e3045e2da60b9646bd Parents: 2654c81 Author: Babak Vahdat <bvah...@apache.org> Authored: Tue Oct 8 10:20:49 2013 +0200 Committer: Babak Vahdat <bvah...@apache.org> Committed: Sun Oct 13 20:49:46 2013 +0200 ---------------------------------------------------------------------- ...pringPropertyPlaceholderConfigurer3Test.java | 24 ++++++++++++++++++-- ...SpringPropertyPlaceholderConfigurer3Test.xml | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/c6b751b9/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java ---------------------------------------------------------------------- diff --git a/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java b/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java index b22037d..dcf02dc 100644 --- a/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java +++ b/components/camel-spring/src/test/java/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.java @@ -21,7 +21,6 @@ import java.util.Properties; import org.apache.camel.CamelContext; import org.apache.camel.spring.SpringTestSupport; import org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer; - import org.springframework.context.support.AbstractXmlApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -31,12 +30,33 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; public class CamelSpringPropertyPlaceholderConfigurer3Test extends SpringTestSupport { @Override + protected void setUp() throws Exception { + // inside the used properties file (cheese.properties) we've defined the following key/value mapping: + // hi2=Guten Tag + // however as we make use of the PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE mode + // (which is NOT the default mode) we expect that setting the system property below should override + // the mapping being defined above. that's we expect the following key/value mapping taking effect: + // hi2=Gute Nacht + System.setProperty("hi2", "Gute Nacht"); + + super.setUp(); + } + + @Override + protected void tearDown() throws Exception { + // clear the property properly to avoid any side effect by the other tests + System.clearProperty("hi2"); + + super.tearDown(); + } + + @Override protected AbstractXmlApplicationContext createApplicationContext() { return new ClassPathXmlApplicationContext("org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml"); } public void testCamelSpringPropertyPlaceholderConfigurerTest() throws Exception { - getMockEndpoint("mock:result").expectedBodiesReceived("Guten Tag Camel"); + getMockEndpoint("mock:result").expectedBodiesReceived("Gute Nacht Camel"); template.sendBody("direct:bar", "Camel"); http://git-wip-us.apache.org/repos/asf/camel/blob/c6b751b9/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml ---------------------------------------------------------------------- diff --git a/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml b/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml index b95b2d8..ae5a476 100644 --- a/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml +++ b/components/camel-spring/src/test/resources/org/apache/camel/component/properties/CamelSpringPropertyPlaceholderConfigurer3Test.xml @@ -26,6 +26,7 @@ <bean id="myBridgePropertyPlaceholder" class="org.apache.camel.component.properties.CamelSpringPropertyPlaceholderConfigurer3Test$MyBridgePropertyPlaceholderConfigurer"> <property name="location" value="classpath:org/apache/camel/component/properties/cheese.properties"/> + <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/> </bean> <!-- a bean that uses Spring property placeholder -->