THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Wiki Markup |
---|
{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringTraceUsingPropertyTest-context.xml} |
Overriding a property setting using a JVM System Property
Available as of Camel 2.5
It is possible to override a property value at runtime using a JVM System property without the need to restart the application to pick up the change. This may also be accomplished from the command line by creating a JVM System property of the same name as the property it replaces with a new value. An example of this is given below
Code Block |
---|
PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
pc.setCache(false);
System.setProperty("cool.end", "mock:override");
System.setProperty("cool.result", "override");
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("properties:cool.end");
from("direct:foo").to("properties:mock:{{cool.result}}");
}
});
context.start();
getMockEndpoint("mock:override").expectedMessageCount(2);
template.sendBody("direct:start", "Hello World");
template.sendBody("direct:foo", "Hello Foo");
System.clearProperty("cool.end");
System.clearProperty("cool.result");
assertMockEndpointsSatisfied();
|
Unit tests
See the unit tests in camel-core and camel-spring
...