In this post we look at how we create integration tests and component documentation for the WildFly Camel subsystem. In part 1 we got to the point where we had successfully created some JBoss Modules XML definitions.
1. Adding a new integration test package
Create a new package for your component integration tests within the
itests/standalone/basic module. Typically the package name follows the name of the Camel component being tested (E.g geocoder for camel-geocoder etc).
2. Add a new integration test class
Next add a test class to the new package. Here’s an example from the camel-geocoder component tests.
The critical thing is that we always want to execute the test within the WildFly container. Hence we use the Arquillian test runner.
The rest of the test is self explanatory. We create a camel context and then test that a simple route returns the results we expect.
If possible, try to test both the consumer and producer (when available). For data formats, test the marshal and unmarshal scenarios.
The aim of the test is to verify that the module definitions we created are correct and that there are no class loading problems. It’s not so important to delve too deeply into testing component functionality.
3. Adding component documentation
Each time a new component is added, it should be added to the user guide. The project documentation is written with AsciiDoc. Create a new
adoc file within
docs/guide/components, the file name convention is
camel-<component name>.adoc. E.g
All that’s required is a basic sentence explaining what the component does, together with a link to the Apache Camel component documentation page. We usually borrow the component description from the Apache Camel documentation to keep things simple. You can look at the other component
adoc files for examples.
Finally, add a link to the new camel component
adoc file within the table of contents in
4. Finishing up
If your tests pass, great! Run the full project test suite to verify that everything still works.
Else you may need to adjust your module definitions, rebuild and retest.
When you’re done, commit all modified project files and submit a pull request.