Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access test case variables in Camel Routes definitions #243

gucce opened this Issue May 22, 2017 · 1 comment


None yet
2 participants
Copy link

gucce commented May 22, 2017


It is possible to define Camel routes in a testcase definition by using <camel:create-routes>, see documentation. However, it is not possible to use testcase specific variables within that route definition.


The following is not possible. ${fileId} will not be replaced with 1.

        <variable name="fileId" value="1"/>

            <routeContext xmlns="">
                <route id="testRoute">
                    <from uri="sftp://someurl?fileName=File_${fileId}.xml"/>
                    <to uri="file:target/"/>


Find a way to replace the variables within the Camel route definition.

BTW Camel does not support the default Spring Property Placeholder, see documentation.


To get all properties from you can do as follows in your Citrus context:

<camelContext id="citrusCamelContext" xmlns="">
    <!-- camel doesn't use the spring default property-placeholder -->
    <propertyPlaceholder id="camelProperties" location=""/>

This way you can access the same from within the Camel context.
⚠️ NOTE Camel uses a different notation for variables, like this {{variable_to_be_replaced}}.


    <routeContext xmlns="">
        <route id="someCamelRoute">
            <from uri="seda:{{seda.queue}"/>
            <to uri="file:{{file.path}}"/>

However, there is still no way to access test (local) variables from within a test case. The only workaround I have found so far is setting the test variables again as JVM properties with a groovy script since Camel reads the JVM properties by default as well:

    // workaround for Camel route which can't access citrus test variables but JVM system properties
    System.setProperty('testVar', '${testVar}')

Then in the finally block I clear them:


NOTE There are two drawbacks to this approach:

  1. Obviously, variables are duplicated and its tedious.
  2. System properties are JVM specific, i.e. global. So there may be collisions with other properties especially with other Citrus tests if they run in parallel, so a best practice is to use a test specific prefix.

@christophd christophd added the READY label May 28, 2017

@christophd christophd added this to the v2.7.2 milestone May 28, 2017

@christophd christophd added IN PROGRESS and removed READY labels Jul 4, 2017

@christophd christophd self-assigned this Jul 4, 2017

@christophd christophd changed the title Testcase Camel Routes definitions cannot access test case variables Access test case variables in Camel Routes definitions Jul 5, 2017

@christophd christophd closed this in 8d5bc1e Jul 5, 2017

@christophd christophd removed the IN PROGRESS label Jul 5, 2017


This comment has been minimized.

Copy link
Contributor Author

gucce commented Jul 5, 2017


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.