title: Testing Camel routes with MockEndpoint
body: <p>Why does this test fails with "java.lang.AssertionError: mock://destino Received message count. Expected: &lt;12> but was: &lt;0>" ? I'm just trying to test if Camel can really reorder messages. </p>
  
  <p>Imports:</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.List;
  
  import org.apache.camel.CamelContext;
  import org.apache.camel.Produce;
  import org.apache.camel.ProducerTemplate;
  import org.apache.camel.builder.RouteBuilder;
  import org.apache.camel.component.mock.MockEndpoint;
  import org.apache.camel.guice.CamelModuleWithRouteTypes;
  import org.jukito.JukitoModule;
  import org.jukito.JukitoRunner;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  
  import com.google.inject.Inject;
  </code></pre>
  
  <p>The test:</p>
  
  <pre><code>@RunWith(JukitoRunner.class) public class ResequenceTest {
  
      @Inject protected CamelContext context;
      @Produce protected ProducerTemplate template;
  
      public static class Module extends JukitoModule {
          @SuppressWarnings("unchecked") protected void configureTest() {
              install(new CamelModuleWithRouteTypes(OrderingTestRouteBuilder.class));
          }
      }
  
      @Test public void testDozenMsgsOrderByIntegerBody() throws Exception {
          // fail();
              Integer[] input = new Integer[] {12, 11, 10, 9, 8, 7, 6, 5, 1, 2, 3, 4};
              List&lt;Integer&gt; expectedOutput = new ArrayList&lt;Integer&gt;();
          for (int i=1; i&lt;=12; i++) {expectedOutput.add(i);};
          for (Integer i : input) {template.sendBody("mock:receptor", i);};
          MockEndpoint resultEndpoint = context.getEndpoint("mock:destino", MockEndpoint.class);
          resultEndpoint.expectedBodiesReceived(expectedOutput);
          resultEndpoint.assertIsSatisfied();
      }
  
  }
  </code></pre>
  
  <p>The route:</p>
  
  <pre><code>class OrderingTestRouteBuilder extends RouteBuilder {
          @Override public void configure() throws Exception {
          from("direct:start")
              .to("mock:receptor")
              .resequence(body(Integer.class))
              .to("mock:destino");
      }
  }
  </code></pre>
  
  <p>Thanks,
  Rodolfo</p>