Robot Framework
Since Camel 3.0
Both producer and consumer are supported
The robotframework: component allows for processing camel exchanges in acceptance test suites which are already implemented with its own DSL. The depending keyword libraries that can be used inside test suites implemented in Robot DSL, could have been implemented either via Java or Pyhton.
This component will let you execute business logic of acceptance test cases in Robot language on which you can pass parameters to feed data via power of Camel Routes. However, there is no reverse binding of parameters back where you can pass values back into Camel exchange. Therefore, for that reason, it actually acts like a template language passing camel exchanges by binding data into the test cases implemented.
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-robotframework</artifactId>
<version>x.x.x</version> <!-- use the same version as your Camel core version -->
</dependency>
URI format
robotframework:templateName[?options]
Where templateName is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: file://folder/myfile.robot).
Configuring Options
Camel components are configured on two separate levels:
-
component level
-
endpoint level
Configuring Component Options
At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.
For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.
Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.
You can configure components using:
-
the Component DSL.
-
in a configuration file (
application.properties
,*.yaml
files, etc). -
directly in the Java code.
Configuring Endpoint Options
You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.
Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.
A good practice when configuring options is to use Property Placeholders.
Property placeholders provide a few benefits:
-
They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.
-
They allow externalizing the configuration from the code.
-
They help the code to become more flexible and reusable.
The following two sections list all the options, firstly for the component followed by the endpoint.
Component Options
The Robot Framework component supports 51 options, which are listed below.
Name | Description | Default | Type |
---|---|---|---|
Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API. | false | boolean | |
Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean | |
A text String to read more arguments from. | String | ||
Creates combined statistics based on tags. Use the format tags:title List. | String | ||
Tests that have the given tags are considered critical. List. | String | ||
A debug String that is written during execution. | String | ||
Sets the documentation of the top-level tests suites. | String | ||
Sets dryrun mode on use. In the dry run mode tests are run without executing keywords originating from test libraries. Useful for validating test data syntax. | false | boolean | |
Selects the tests cases by tags. List. | String | ||
Sets robot to stop execution immediately if a critical test fails. | false | boolean | |
Selects the tests cases by tags. List. | String | ||
Sets a single listener for monitoring tests execution. | String | ||
Sets multiple listeners for monitoring tests execution. Use the format ListenerWithArgs:arg1:arg2 or simply ListenerWithoutArgs List. | String | ||
Sets the path to the generated log String. | String | ||
Sets the threshold level for logging. | String | ||
Sets a title for the generated tests log. | String | ||
Sets free metadata for the top level tests suites. comma seperated list of string resulting as List. | String | ||
Using ANSI colors in console. Normally colors work in unixes but not in Windows. Default is 'on'. 'on' - use colors in unixes but not in Windows 'off' - never use colors 'force' - always use colors (also in Windows). | String | ||
Width of the monitor output. Default is 78. | 78 | String | |
Sets the name of the top-level tests suites. | String | ||
Tests that have the given tags are not critical. List. | String | ||
If true, sets the return code to zero regardless of failures in test cases. Error codes are returned normally. | false | boolean | |
Sets the path to the generated output String. | String | ||
Configures where generated reports are to be placed. | String | ||
Sets the test execution order to be randomized. Valid values are all, suite, and test. | String | ||
Sets the path to the generated report String. | String | ||
Sets background colors for the generated report and summary. | String | ||
Sets a title for the generated tests report. | String | ||
Executes tests also if the top level test suite is empty. Useful e.g. with --include/--exclude when it is not an error that no test matches the condition. | false | boolean | |
Re-run failed tests, based on output.xml String. | String | ||
Sets the execution mode for this tests run. Note that this setting has been deprecated in Robot Framework 2.8. Use separate dryryn, skipTeardownOnExit, exitOnFailure, and randomize settings instead. | String | ||
Sets whether the teardowns are skipped if the test execution is prematurely stopped. | false | boolean | |
Splits output and log files. | String | ||
Selects the tests suites by name. List. | String | ||
Defines how many levels to show in the Statistics by Suite table in outputs. | String | ||
Sets a title for the generated summary report. | String | ||
Adds documentation to the specified tags. List. | String | ||
Sets the tags(s) to all executed tests cases. List. | String | ||
Excludes these tags from the Statistics by Tag and Test Details by Tag tables in outputs. List. | String | ||
Includes only these tags in the Statistics by Tag and Test Details by Tag tables in outputs. List. | String | ||
Adds external links to the Statistics by Tag table in outputs. Use the format pattern:link:title List. | String | ||
Selects the tests cases by name. List. | String | ||
Adds a timestamp to all output files. | false | boolean | |
Sets variables using variables files. Use the format path:args List. | String | ||
Sets individual variables. Use the format name:value List. | String | ||
Show a warning when an invalid String is skipped. | false | boolean | |
Sets the path to the generated XUnit compatible result String, relative to outputDirectory. The String is in xml format. By default, the String name is derived from the testCasesDirectory parameter, replacing blanks in the directory name by underscores. | String | ||
Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean | |
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | |
Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean | |
The configuration. | RobotFrameworkCamelConfiguration |
Endpoint Options
The Robot Framework endpoint is configured using URI syntax:
robotframework:resourceUri
With the following path and query parameters:
Path Parameters (1 parameters)
Name | Description | Default | Type |
---|---|---|---|
Required Path to the resource. You can prefix with: classpath, file, http, ref, or bean. classpath, file and http loads the resource using these protocols (classpath is default). ref will lookup the resource in the registry. bean will call a method on a bean to be used as the resource. For bean you can specify the method name after dot, eg bean:myBean.myMethod. | String |
Query Parameters (68 parameters)
Name | Description | Default | Type |
---|---|---|---|
Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API. | false | boolean | |
Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | boolean | |
A text String to read more arguments from. | String | ||
Creates combined statistics based on tags. Use the format tags:title List. | String | ||
Sets whether to use resource content cache or not. | false | boolean | |
Tests that have the given tags are considered critical. List. | String | ||
A debug String that is written during execution. | String | ||
Sets the documentation of the top-level tests suites. | String | ||
Sets dryrun mode on use. In the dry run mode tests are run without executing keywords originating from test libraries. Useful for validating test data syntax. | false | boolean | |
Selects the tests cases by tags. List. | String | ||
Sets robot to stop execution immediately if a critical test fails. | false | boolean | |
Selects the tests cases by tags. List. | String | ||
Sets a single listener for monitoring tests execution. | String | ||
Sets multiple listeners for monitoring tests execution. Use the format ListenerWithArgs:arg1:arg2 or simply ListenerWithoutArgs List. | String | ||
Sets the path to the generated log String. | String | ||
Sets the threshold level for logging. | String | ||
Sets a title for the generated tests log. | String | ||
Sets free metadata for the top level tests suites. comma seperated list of string resulting as List. | String | ||
Using ANSI colors in console. Normally colors work in unixes but not in Windows. Default is 'on'. 'on' - use colors in unixes but not in Windows 'off' - never use colors 'force' - always use colors (also in Windows). | String | ||
Width of the monitor output. Default is 78. | 78 | String | |
Sets the name of the top-level tests suites. | String | ||
Tests that have the given tags are not critical. List. | String | ||
If true, sets the return code to zero regardless of failures in test cases. Error codes are returned normally. | false | boolean | |
Sets the path to the generated output String. | String | ||
Configures where generated reports are to be placed. | String | ||
Sets the test execution order to be randomized. Valid values are all, suite, and test. | String | ||
Sets the path to the generated report String. | String | ||
Sets background colors for the generated report and summary. | String | ||
Sets a title for the generated tests report. | String | ||
Executes tests also if the top level test suite is empty. Useful e.g. with --include/--exclude when it is not an error that no test matches the condition. | false | boolean | |
Re-run failed tests, based on output.xml String. | String | ||
Sets the execution mode for this tests run. Note that this setting has been deprecated in Robot Framework 2.8. Use separate dryryn, skipTeardownOnExit, exitOnFailure, and randomize settings instead. | String | ||
Sets whether the teardowns are skipped if the test execution is prematurely stopped. | false | boolean | |
Splits output and log files. | String | ||
Selects the tests suites by name. List. | String | ||
Defines how many levels to show in the Statistics by Suite table in outputs. | String | ||
Sets a title for the generated summary report. | String | ||
Adds documentation to the specified tags. List. | String | ||
Sets the tags(s) to all executed tests cases. List. | String | ||
Excludes these tags from the Statistics by Tag and Test Details by Tag tables in outputs. List. | String | ||
Includes only these tags in the Statistics by Tag and Test Details by Tag tables in outputs. List. | String | ||
Adds external links to the Statistics by Tag table in outputs. Use the format pattern:link:title List. | String | ||
Selects the tests cases by name. List. | String | ||
Adds a timestamp to all output files. | false | boolean | |
Sets variables using variables files. Use the format path:args List. | String | ||
Sets individual variables. Use the format name:value List. | String | ||
Show a warning when an invalid String is skipped. | false | boolean | |
Sets the path to the generated XUnit compatible result String, relative to outputDirectory. The String is in xml format. By default, the String name is derived from the testCasesDirectory parameter, replacing blanks in the directory name by underscores. | String | ||
If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead. | false | boolean | |
Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean | |
To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | ExceptionHandler | ||
Sets the exchange pattern when the consumer creates an exchange. Enum values:
| ExchangePattern | ||
A pluggable org.apache.camel.PollingConsumerPollingStrategy allowing you to provide your custom implementation to control error handling usually occurred during the poll operation before an Exchange have been created and being routed in Camel. | PollingConsumerPollStrategy | ||
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean | |
The number of subsequent error polls (failed due some error) that should happen before the backoffMultipler should kick-in. | int | ||
The number of subsequent idle polls that should happen before the backoffMultipler should kick-in. | int | ||
To let the scheduled polling consumer backoff if there has been a number of subsequent idles/errors in a row. The multiplier is then the number of polls that will be skipped before the next actual attempt is happening again. When this option is in use then backoffIdleThreshold and/or backoffErrorThreshold must also be configured. | int | ||
Milliseconds before the next poll. | 500 | long | |
If greedy is enabled, then the ScheduledPollConsumer will run immediately again, if the previous run polled 1 or more messages. | false | boolean | |
Milliseconds before the first poll starts. | 1000 | long | |
Specifies a maximum limit of number of fires. So if you set it to 1, the scheduler will only fire once. If you set it to 5, it will only fire five times. A value of zero or negative means fire forever. | 0 | long | |
The consumer logs a start/complete log line when it polls. This option allows you to configure the logging level for that. Enum values:
| TRACE | LoggingLevel | |
Allows for configuring a custom/shared thread pool to use for the consumer. By default each consumer has its own single threaded thread pool. | ScheduledExecutorService | ||
To use a cron scheduler from either camel-spring or camel-quartz component. Use value spring or quartz for built in scheduler. | none | Object | |
To configure additional properties when using a custom scheduler or any of the Quartz, Spring based scheduler. | Map | ||
Whether the scheduler should be auto started. | true | boolean | |
Time unit for initialDelay and delay options. Enum values:
| MILLISECONDS | TimeUnit | |
Controls if fixed delay or fixed rate is used. See ScheduledExecutorService in JDK for details. | true | boolean |
Message Headers
The Robot Framework component supports 3 message header(s), which is/are listed below:
Name | Description | Default | Type |
---|---|---|---|
Constant: | The robot variables. | List | |
Constant: | The return code. | Integer | |
CamelRobotResourceUri (common) Constant: | The new resource URI. | String |
Samples
For example, you could use something like:
from("direct:setVariableCamelBody")
.to("robotframework:src/test/resources/org/apache/camel/component/robotframework/set_variable_camel_body.robot")
To use a robot test case to execute and collect the results and pass them to generate a custom report if such need happens
It’s possible to specify what template the component should use dynamically via a header, so for example:
from("direct:in")
.setHeader(RobotFrameworkCamelConstants.CAMEL_ROBOT_RESOURCE_URI).constant("path/to/my/template.robot")
.to("robotframework:dummy?allowTemplateFromHeader=true");
Robotframework component helps you pass values into robot test cases with the similar approach how you would be able to pass values using Camel Simple Language. Components support passing values in three different ways. Exchange body, headers, and properties.
from("direct:in")
.setBody(constant("Hello Robot"))
.setHeader(RobotFrameworkCamelConstants.CAMEL_ROBOT_RESOURCE_URI).constant("path/to/my/template.robot")
.to("robotframework:dummy?allowTemplateFromHeader=true");
And the template.robot
file:
*** Test Cases ***
Set Variable Camel Body Test Case
${myvar} = Set Variable ${body}
Should Be True ${myvar} == ${body}
from("direct:in")
.setHeader("testHeader", constant("testHeaderValue"))
.setHeader(RobotFrameworkCamelConstants.CAMEL_ROBOT_RESOURCE_URI).constant("path/to/my/template.robot")
.to("robotframework:dummy?allowTemplateFromHeader=true");
And the template.robot
file:
*** Test Cases ***
Set Variable Camel Header Test Case
${myvar} = Set Variable ${headers.testHeader}
Should Be True ${myvar} == ${headers.testHeader}
from("direct:in")
.setProperty"testProperty", constant("testPropertyValue"))
.setHeader(RobotFrameworkCamelConstants.CAMEL_ROBOT_RESOURCE_URI).constant("path/to/my/template.robot")
.to("robotframework:dummy?allowTemplateFromHeader=true");
And the template.robot
file:
*** Test Cases ***
Set Variable Camel Header Test Case
${myvar} = Set Variable ${properties.testProperty}
Should Be True ${myvar} == ${properties.testProperty}
Please note that when you pass values through Camel Exchange to test cases, they will be available as case-sensitive body
, headers.[yourHeaderName]
and properties.[yourPropertyName]
Spring Boot Auto-Configuration
When using robotframework with Spring Boot make sure to use the following Maven dependency to have support for auto configuration:
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-robotframework-starter</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
The component supports 52 options, which are listed below.
Name | Description | Default | Type |
---|---|---|---|
Sets whether the context map should allow access to all details. By default only the message body and headers can be accessed. This option can be enabled for full access to the current Exchange and CamelContext. Doing so impose a potential security risk as this opens access to the full power of CamelContext API. | false | Boolean | |
Whether to allow to use resource template from header or not (default false). Enabling this allows to specify dynamic templates via message header. However this can be seen as a potential security vulnerability if the header is coming from a malicious user, so use this with care. | false | Boolean | |
A text String to read more arguments from. | String | ||
Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | Boolean | |
Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | Boolean | |
Creates combined statistics based on tags. Use the format tags:title List. | String | ||
The configuration. The option is a org.apache.camel.component.robotframework.RobotFrameworkCamelConfiguration type. | RobotFrameworkCamelConfiguration | ||
Tests that have the given tags are considered critical. List. | String | ||
A debug String that is written during execution. | String | ||
Sets the documentation of the top-level tests suites. | String | ||
Sets dryrun mode on use. In the dry run mode tests are run without executing keywords originating from test libraries. Useful for validating test data syntax. | false | Boolean | |
Whether to enable auto configuration of the robotframework component. This is enabled by default. | Boolean | ||
Selects the tests cases by tags. List. | String | ||
Sets robot to stop execution immediately if a critical test fails. | false | Boolean | |
Selects the tests cases by tags. List. | String | ||
Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. | false | Boolean | |
Sets a single listener for monitoring tests execution. | String | ||
Sets multiple listeners for monitoring tests execution. Use the format ListenerWithArgs:arg1:arg2 or simply ListenerWithoutArgs List. | String | ||
Sets the path to the generated log String. | String | ||
Sets the threshold level for logging. | String | ||
Sets a title for the generated tests log. | String | ||
Sets free metadata for the top level tests suites. comma seperated list of string resulting as List. | String | ||
Using ANSI colors in console. Normally colors work in unixes but not in Windows. Default is 'on'. 'on' - use colors in unixes but not in Windows 'off' - never use colors 'force' - always use colors (also in Windows). | String | ||
Width of the monitor output. Default is 78. | 78 | String | |
Sets the name of the top-level tests suites. | String | ||
If true, sets the return code to zero regardless of failures in test cases. Error codes are returned normally. | false | Boolean | |
Tests that have the given tags are not critical. List. | String | ||
Sets the path to the generated output String. | String | ||
Configures where generated reports are to be placed. | String | ||
Sets the test execution order to be randomized. Valid values are all, suite, and test. | String | ||
Sets the path to the generated report String. | String | ||
Sets background colors for the generated report and summary. | String | ||
Sets a title for the generated tests report. | String | ||
Executes tests also if the top level test suite is empty. Useful e.g. with --include/--exclude when it is not an error that no test matches the condition. | false | Boolean | |
Re-run failed tests, based on output.xml String. | String | ||
Sets the execution mode for this tests run. Note that this setting has been deprecated in Robot Framework 2.8. Use separate dryryn, skipTeardownOnExit, exitOnFailure, and randomize settings instead. | String | ||
Sets whether the teardowns are skipped if the test execution is prematurely stopped. | false | Boolean | |
Splits output and log files. | String | ||
Defines how many levels to show in the Statistics by Suite table in outputs. | String | ||
Selects the tests suites by name. List. | String | ||
Sets a title for the generated summary report. | String | ||
Adds documentation to the specified tags. List. | String | ||
Excludes these tags from the Statistics by Tag and Test Details by Tag tables in outputs. List. | String | ||
Includes only these tags in the Statistics by Tag and Test Details by Tag tables in outputs. List. | String | ||
Adds external links to the Statistics by Tag table in outputs. Use the format pattern:link:title List. | String | ||
Sets the tags(s) to all executed tests cases. List. | String | ||
Selects the tests cases by name. List. | String | ||
Adds a timestamp to all output files. | false | Boolean | |
Sets variables using variables files. Use the format path:args List. | String | ||
Sets individual variables. Use the format name:value List. | String | ||
Show a warning when an invalid String is skipped. | false | Boolean | |
Sets the path to the generated XUnit compatible result String, relative to outputDirectory. The String is in xml format. By default, the String name is derived from the testCasesDirectory parameter, replacing blanks in the directory name by underscores. | String |