mvn camel:run
is not a good idea generally. The right place to test a route is a unit test.
Apache Camel comes with a very sophisticated test framework. It's great, no doubt about it! But, I wanted something more.
I saw many examples published on many sites where people copied and pasted the original routes modifying from source and adding mock endpoints. I was scared particularly by one quite complex route defined in XML configuration file. The test route was almost a copy and paste. Almost, because it got unsynchronised somewhere during the development (I guess) and the test route was different from the original one. This approach seemed to me to be very error-prone.
I wanted not to copy and paste my routes, but automatically modify them slightly and then test. I wanted to dynamically change my original routes instead of copy and pasting parts of the original ones. Here is what I intended to do:
- dynamically override from endpoint and manually fire the route directly from my test;
- dynamically add mock endpoint at the end of the route so that I can verify if the messages were ok.
See how I did it.
