title: How do I properly use Mocks when testing Camel routes?
body: <p>I am trying to write a Camel test that checks to ensure a content based router is routing XML files correctly. Here are the enpoints and the route in my blueprint.xml:</p>
  
  <pre><code>&lt;endpoint uri="activemq:queue:INPUTQUEUE" id="jms.queue.input" /&gt;
  &lt;endpoint uri="activemq:queue:QUEUE1" id="jms.queue.1" /&gt;
  &lt;endpoint uri="activemq:queue:QUEUE2" id="jms.queue.2" /&gt;
  
  &lt;route id="general-jms.to.specific-jms"&gt;
      &lt;from ref="jms.queue.input" /&gt;
      &lt;choice&gt;
        &lt;when&gt;
          &lt;xpath&gt;//object-type = '1'&lt;/xpath&gt;
          &lt;log message="Sending message to queue: QUEUE1" /&gt;
          &lt;to ref="jms.queue.1" /&gt;
        &lt;/when&gt;
        &lt;when&gt;
          &lt;xpath&gt;//object-type = '2'&lt;/xpath&gt;
          &lt;log message="Sending message to queue: QUEUE2" /&gt;
          &lt;to ref="jms.queue.2" /&gt;
        &lt;/when&gt;
        &lt;otherwise&gt;
          &lt;log message="No output was able to be determined based on the input." /&gt;
        &lt;/otherwise&gt;
      &lt;/choice&gt;
  &lt;/route&gt;
  </code></pre>
  
  <p>Right now, all I am trying to do is send in a sample source file that has an <code>&lt;object-type&gt;</code> of 1 and verify that is it routed to the correct queue (QUEUE1) and is the correct data (should just send the entire XML file to QUEUE1). Here is my test code:</p>
  
  <pre><code>public class RouteTest extends CamelBlueprintTestSupport {
  
      @Override
      protected String getBlueprintDescriptor() {
          return "/OSGI-INF/blueprint/blueprint.xml";
      }
  
      @Override
      public String isMockEndpointsAndSkip() {
          return "activemq:queue:QUEUE1";
      }
  
      @Test
      public void testQueue1Route() throws Exception {
  
          getMockEndpoint("mock:activemq:queue:QUEUE1").expectedBodiesReceived(context.getTypeConverter().convertTo(String.class, new File("src/test/resources/queue1-test.xml")));
  
          template.sendBody("activemq:queue:INPUTQUEUE", context.getTypeConverter().convertTo(String.class, new File("src/test/resources/queue1-test.xml")));
  
          assertMockEndpointsSatisfied();
      }
  }
  </code></pre>
  
  <p>When I run this test, I see the log message that I put in the route definition that says it is sending it to QUEUE1, but the JUnit test fails with this error message: <em>java.lang.AssertionError: mock://activemq:queue:QUEUE1 Received message count. Expected: &lt;1> but was: &lt;0></em>.</p>
  
  <p>Can someone help me understand what I am doing wrong? </p>
  
  <p>My understanding is that Camel will automatically mock the QUEUE1 endpoint since I overrode the <code>isMockEndpointsAndSkip()</code> and provided the QUEUE1 endpoint uri. I thought this meant I should be able to use that endpoint in the <code>getMockEnpoint()</code> method just by appending "mock:" to the beginning of the uri. Then I should have a mocked endpoint of which I can set expections on (i.e. that is has to have the input file).</p>
  
  <p>If I am unclear on something please let me know and any help is greatly appreciated!</p>