how do I Mock endpoints with blueprint in camel?
<p>I'm writing an application using camel for deployment (eventually) in a fuse container.  The nature of the project requires that I mix and match Java and XML DSL.  </p>

<p>I'm having trouble getting the mock framework to work properly with blueprint.</p>

<p>Here's my unit test, based completely on the example <a href="http://camel.apache.org/mock.html" rel="nofollow">here</a>.</p>

<pre><code>public class MockNotWorking extends CamelBlueprintTestSupport {

   @Test
   public void testAdvisedMockEndpointsWithPattern() throws Exception {

    context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            mockEndpoints("log*");
        }
    });

    getMockEndpoint("mock:log:foo").expectedBodiesReceived("Bye World");
    getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");

    template.sendBody("direct:start", "Hello World");

    // additional test to ensure correct endpoints in registry
    assertNotNull(context.hasEndpoint("direct:start"));
    assertNotNull(context.hasEndpoint("log:foo"));
    assertNotNull(context.hasEndpoint("mock:result"));
    // only the log:foo endpoint was mocked
    assertNotNull(context.hasEndpoint("mock:log:foo"));
    assertNull(context.hasEndpoint("mock:direct:start"));
    assertNull(context.hasEndpoint("mock:direct:foo"));

    assertMockEndpointsSatisfied();

   }


  @Override
  protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
              from("direct:start").to("direct:foo").to("log:foo").to("mock:result");

            from("direct:foo").transform(constant("Bye World"));
        }
    };
  }

  protected String getBlueprintDescriptor() {
    return "OSGI-INF/blueprint/blueprint.xml";
  }
}
</code></pre>

<p>I have copied verbatim the example <a href="http://camel.apache.org/mock.html" rel="nofollow">here</a>, and modified it very slightly so we extend <code>CamelBlueprintTestSupport</code> instead of <code>CamelTestSupport</code>.  This requires over-riding <code>getBlueprintDescriptor</code> to point to my blueprint xml, in which I have defined one very basic (and completely irrelevant to the test) route:</p>

<pre><code>&lt;blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"&gt;

&lt;camelContext id="validationRoute" xmlns="http://camel.apache.org/schema/blueprint" &gt;

    &lt;route id="validation"&gt;
        &lt;from uri="direct:validation" /&gt;
        &lt;log message="validating..." /&gt;
    &lt;/route&gt;
&lt;/camelContext&gt;

&lt;/blueprint&gt;
</code></pre>

<p>The test fails with:</p>

<pre><code>java.lang.AssertionError: mock://log:foo Received message count. Expected: &lt;1&gt; but was: &lt;0&gt;
</code></pre>

<p>So this means the message did not reach the mock endpoint.  Change <code>CamelBlueprintTestSupport</code> for <code>CamelTestSupport</code> and it works.</p>

<p>So how do I get mocks like this working correctly with blueprint?</p>