Hi Stephan,

> My problem arised in the route tests where I mock away the whole bean. I
> can mock the method call, but I cannot add entries to the header- or
> property-maps. So if the header or property entry is expected later in the
> route, it fails.

Keep in mind that in tests you can send messages via ProducerTemplate
with some arbitatry headers/properties. Since headers and properties
are propagated with the messages down the route, you can set test
fixtures this way.

producerTemplate.sendBodyAndHeader("direct:test", "message",
"expected_header_key", "expected_header_value");

In production environment "expected_header_key" could be set by your
bean, but for unit tests you would pass it explicitly as a fixture to
the producer template initiating the test.

This approach usually works for me. For more complicated cases (for
example when you need to alter the header within the route), you can
use AdviceWith [1] or interceptors [2].

Cheers.

[1] http://camel.apache.org/advicewith.html
[2] http://camel.apache.org/intercept.html

-- 
Henryk Konsek
http://henryk-konsek.blogspot.com

Reply via email to