Skip to content
Advertisement

Apache Camel mock endpoint

I recently started to investigate Apache Camel and I have one issue. I start writing some test for my routes, and there are a lot of examples, where “to” part of route is written as

JavaScript

So, I wrote a test, where I am exepcting to have mock:result as last endproint.

JavaScript

Here is the questions: Is this important to write mock:result if I want to test my route??

Advertisement

Answer

You don’t need to include “mock:result” in production, there are multiple ways to test your route. One is to implement isMockEndpoints in your Camel test:

JavaScript

So if your route is like this:

JavaScript

You can check the MockEndpoint like this:

JavaScript

You can also use AdviceWith to modify your route at test time, by doing something like this:

JavaScript

Also, as Claus mentioned in his comment, make sure you set your expectations before you send your message to the route.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement