A common way of testing routes is to use JUnit. Fuse IDE includes a wizard that simplifies creating a JUnit test case for your routes. The wizard generates the starting point code and configuration to run the test.
To create a new JUnit test case for your route:
In Package Explorer, select the camel-context.xml file in your routing project.
Right-click it to open the context menu, and then select > to open the New Camel JUnit Test Case wizard, as shown in Figure 7, “New Camel JUnit Test Case wizard”.
![]() | Tip |
|---|---|
Alternatively, you can open the wizard by selecting > > from the menu bar. |
In Source folder, accept the default location of the source code for the test case, or enter another location.
![]() | Tip |
|---|---|
You can click |
In Package, accept the default package name for the generated test code, or enter another package name.
![]() | Tip |
|---|---|
You can click |
In Camel XML file under test, accept the default pathname of the routing context file that contains the route you want to test, or enter another pathname.
![]() | Tip |
|---|---|
You can click |
In Name, accept the default name for the generated test class, or enter another name.
Select the method stubs you want to include in the generated code.
If you want to include the default generated comments in the generated code, check the Generate comments box.
Click
to open the Test Endpoints page, shown in Figure 8, “New Camel JUnit Test Case page”.
Under Available endpoints, select the endpoints you want to test. Click the checkbox next to any selected endpoint to deselect it.
Click
.
![]() | Tip |
|---|---|
If prompted, add JUnit to the build path. |
The artifacts for the test are added to your project and appear in Package
Explorer under src/test/java. The class implementing the test case
opens in the Java editor.