I am struggling to understand something I fear is very basic, but I just don't
see it. Hoping someone can help me understand this.
Properties... I can use them in route definitions, but I don't seem to be able
to obtain their values in regular Java code.
Example (using Camel 2.16.3):
I have a route builder:
public class MyRouteBuilder extends RouteBuilder {
public void configure() {
from("file:{{dataFile}}?noop=true")
.to("file:target/messages/others");
}
}
And a unit test:
@RunWith(JUnit4.class)
public class UnitTest extends CamelTestSupport {
private String fileName;
@Override
protected RouteBuilder createRouteBuilder() {
return new MyRouteBuilder();
}
@Override
public Boolean ignoreMissingLocationWithPropertiesComponent() {
return true;
}
@Override
protected Properties useOverridePropertiesWithPropertiesComponent()
{
Properties override = new Properties();
override.put("dataFile", "overridden-file");
return override;
}
@Test
public void testPropertyGetting() throws Exception {
fileName = context().getProperty("dataFile");
assert(fileName != null);
}
}
When I run this test, the output includes:
INFO Route: route1 started and consuming from:
Endpoint[file://overridden-file?noop=true]
So the override property set above did get filled into the route definition.
However, when I try to get the property in the testPropertyGetting() method,
the value is null
Why???
-Steve