Home » Java » java – How to configure application.properties in camel tests?-Exceptionshub

java – How to configure application.properties in camel tests?-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment


I’m working on writing tests for the route
The problem is all my routes contain properties that described in application.properties file e.g


It works fine but when I try to write a test – seems like this route can’t find application.properties file with its properties.
The error:

java.lang.IllegalArgumentException: Property with key [oracle.queue.url] not found in properties from text: oracleQueue:{{oracle.queue.url}}

My testcase:

public class RouteTest extends CamelTestSupport {

protected RoutesBuilder createRouteBuilder() {
    MyRouteBulder route = new MyRouteBulder ();
    ApplicationContext appContext = new ClassPathXmlApplicationContext("camel-context.xml");

    PropertiesComponent pc = new PropertiesComponent();

    CamelContext context = new SpringCamelContext(appContext);

    context.addComponent("properties", pc);
    return route;

public void test() throws InterruptedException {
    MockEndpoint mockEndpoint = resolveMandatoryEndpoint("my.endpoint", MockEndpoint.class);
    template.sendBody("oracleQueue:{{oracle.queue.url}}", "hello world");



How should I set up configuration file properly?

How to&Answers:

Maybe you need an absolute path for the location.

I use this to get props

    id="properties" name="properties">
    <property name="cache" value="false"/>
    <property name="locations">