Apache Camel MockEndpoint mock the output
<p>Let's say I have an apache camel route like this:</p>

<pre><code>from("direct:start")
    .routeId("aRouteId")
    .bean(someBusinnessTransformationBean).id("transformationBean")
    .bean(aPersistenceBean).id("persistenceBean")
    .to("direct:target");
</code></pre>

<p>And then, on my unit tests, I'm doing something like:</p>

<pre><code>public class RouteTest extends CamelTestSupport {
    @Override
    public boolean isDumpRouteCoverage() { return true }

    @Override
    public boolean isUsedAdviceWith() { return true }

    @EndpointInject(uri = "mock:mockTransformationBean")
    protected MockEndpoint mockTransformationBean;

    @EndpointInject(uri = "mock:mockPersistenceBean")
    protected MockEndpoint mockPersistenceBean;

    @Test
    public void testRoute() throws Exception {
        context.getRouteDefinition("aRouteId").adviceWith(context, new AdviceWithRouteBuilder() {
            @Override
            public void configure() throws Exception {
                weaveById("transformationBean")
                    .replace()
                    .multicast()
                    .to(mockTransformationBean);

                weaveById("persistenceBean")
                    .replace()
                    .multicast()
                    .to(mockPersistenceBean);
            }
        });

        context.start();

        // Asserts the expectedMessageCount

        // Send a message with template.sendBody...

        assertMockEndpointSatisfied();
    }
}
</code></pre>

<p><strong>Question:</strong></p>

<p>How could I unit test this route properly, instead of just ensure the messageCount and received body (on the first bean).</p>

<p>Like, how could I mock the response of a MockEndpoint as I could do when using Mockito for unit testing:</p>

<pre><code>when(mockTransformationBean.someHandler(...)).thenReturn(anExpectedObjectForMyUnitTestPropose);
</code></pre>

<p>Cheers, Nikolas</p>