Unit testing of Routes
Last updated: 2026-11-06
Unit testing is an essential part of any professional software development process.
This section will show you how Routes can be unit tested using the Apache Camel Testing
framework.
Creating a Route
To show an example of Unit testing, you will create a Route first. This Route
reads a file from the specific directory and filters the messages of the
file.
Procedure
Results
For more information on how to create a Route, see Creating a Route.
Publishing the Route to the Artifact repository
Procedure
Results
Your item is available as an artifact in the repository.
For more information on how to publish a Route, see Publishing to an artifact repository.
Creating a Maven project for unit test
Unit tests will be put in a separate project.
You need to switch to the Java perspective and create a simple maven-based project.
Procedure
Publishing utility JAR files to local Maven repository
Start a command line console to deploy the utility JAR files into your local
Maven repository.
Procedure
- Execute following command to deploy the system routines: mvn install:install-file -DgroupId=org.talend.camel -DartifactId=systemRoutines -Dversion=1.0.0 -Dfile=./src/ext/systemRoutines.jar -Dpackaging=jar -DgeneratePom=true
- Execute following command to deploy the user routines: mvn install:install-file -DgroupId=org.talend.camel -DartifactId=userRoutines -Dversion=1.0.0 -Dfile=./src/ext/userRoutines.jar -Dpackaging=jar -DgeneratePom=true
Results
You have all the necessary dependencies to do unit tests.
button in the toolbar to run the test.