title: Camel processor unit/integration testing
body: <p>I've probably completly missed something but I can't manage to test my route as I want to.</p>
  
  <p>I've got the following bean :</p>
  
  <pre><code>@Component("fileProcessor")
  public class FileProcessor {
     public boolean valid(@Header("customObject) CustomObject customObject,Exchange exchange) throws IOException{
         return false;
  }
  </code></pre>
  
  <p>I've a route calling my bean like so :</p>
  
  <pre><code>from("direct:validationFile").routeId("validationFile").validate().method("fileProcessor","valid")
          // Other stuff
          .end();
  </code></pre>
  
  <p>Here is my unit test, based on a example I found:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class})
  @ContextConfiguration(locations = { "classpath:/tu-dao-beans.xml" })
  public class FileProcessorTest extends CamelTestSupport {
  
      @EndpointInject(uri = "mock:result")
      protected MockEndpoint resultEndpoint;
  
      @Produce(uri = "direct:start")
      protected ProducerTemplate template;
  
      @Override
      public boolean isDumpRouteCoverage() {
          return true;
      }
  
      @Test
      public void testSendMatchingMessage() throws Exception {
          String expectedBody = "&lt;matched/&gt;";
          resultEndpoint.expectedBodiesReceived(expectedBody);
          template.sendBodyAndHeader(expectedBody, "foo", "bar");
          resultEndpoint.assertIsSatisfied();
      }
  
      @Test
      public void testSendNotMatchingMessage() throws Exception {
          resultEndpoint.expectedMessageCount(0);
          template.sendBodyAndHeader("&lt;notMatched/&gt;", "foo", "notMatchedHeaderValue");
          resultEndpoint.assertIsSatisfied();
      }
  
      @Override
      protected RouteBuilder createRouteBuilder() {
          return new RouteBuilder() {
              public void configure() {
  //                from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
                  from("direct:start").routeId("validationFile").validate().method("fileProcessor","valid").to("mock:result");
              }
          };
      }
  }   
  </code></pre>
  
  <p>The test fails because <code>fileProcessor</code> is not found, yet I'm pretty sure my <code>spring context</code>is properly loaded, I'm using the same <code>beans.xml</code>file for my <code>dbunit</code> tests and my DAO components are found just fine... What am I missing ?</p>
  
  <p>EDIT:
  Thanks to Jérémis B's answer I fixed my problem easily. In case someone stumble as I did here is the code I added:</p>
  
  <pre><code>@Autowired
  private FileProcessor fileProcessor;
  
  @Override
  protected JndiRegistry createRegistry() throws Exception {
      JndiRegistry registry = super.createRegistry();
      registry.bind("fileProcessor", fileProcessor);
      return registry;
  }
  </code></pre>