0

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

from("oracleQueue:{{oracle.queue.url}}").to("my.endpoint")

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 {

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

    PropertiesComponent pc = new PropertiesComponent();
    pc.setLocation("application.properties");

    CamelContext context = new SpringCamelContext(appContext);

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


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

}

}

How should I set up configuration file properly?

1 Answers1

0

Maybe you need an absolute path for the location.

I use this to get props

<bean
    class="org.apache.camel.component.properties.PropertiesComponent"
    id="properties" name="properties">
    <property name="cache" value="false"/>
    <property name="locations">
        <list>
            <value>file:${CONF}/broker.properties</value>
            <value>file:${CONF}/sops/domains/properties/a92fe32d-01c9-4c00-b2c0-b17a71503bbe.properties;optional=true</value>
        </list>
    </property>
</bean>
Lukyanov Mikhail
  • 500
  • 7
  • 17