title: Junit Mock JDBC Repository in Apache Camel
body: <p>I am trying to mock the jdbc repository in camel but it is still calling the db calls without mocking.Please help me to correct it.</p>
  
  <p><strong>Route:</strong></p>
  
  <pre><code>@Component
  public class Router10 extends RouteBuilder {
  
      @Autowired
      CustomerRepository repository;
  
      @Override
      public void configure() throws Exception {
  
          from("file:src/main/resources/in?delete=true").routeId("route1").process((exchange) -&gt; {
              List&lt;Customer&gt; names = repository.findAll();
              System.out.println("names:"+names.size());
              exchange.getOut().setBody(names);
          }).split(simple("${body}")).to("direct:process1");
  
          from("direct:process1").routeId("process1").process((exchange) -&gt; {
              exchange.getOut().setBody(exchange.getIn().getBody(Customer.class).toString());
          }).to("file:src/main/resources/out?fileName=test_out.txt&amp;fileExist=Append");
  
      }
  }
  </code></pre>
  
  <p><strong>JUnit:</strong></p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class })
  @SpringBootTest(classes = Router10.class)
  @ActiveProfiles("test")
  @EnableAutoConfiguration
  public class RouterTest2 extends AbstractTestExecutionListener {
  
      @Autowired
      public CustomerRepository repository;
  
      @Override
      public void beforeTestClass(TestContext testContext) {
           List&lt;Customer&gt; list = new ArrayList&lt;&gt;(); 
           list.add(new Customer("F1","L1"));
           list.add(new Customer("F2","L2"));
          Mockito.when(repository.findAll()).thenReturn(list);
      }
  
  
      @Test
      public void test() throws Exception {
          Thread.sleep(2000);
          File outDir = new File("src/main/resources/out");
          Assert.assertTrue(outDir.isDirectory());
      }    
  }
  </code></pre>