title: How to unit test this route builder in camel?
body: <p>I have the following <code>RouteBuilder</code> Class and I am using dependency injection here. How can I test this route builder? I am using JUnit and camel test classes.</p>
  
  <pre><code>public class TestRoute extends RouteBuilder {
  
      private ServiceConfiguration serviceConfiguration;
  
      public TestRoute(ServiceConfiguration serviceConfiguration) {
          this.serviceConfiguration = serviceConfiguration;
      }
  
      @Override
      public void configure() throws Exception {
          String incomingURI = serviceConfiguration.getQueueConfiguration().getURI();
          String outgoingURI = serviceConfiguration.getHTTPConfiguration().getURI();
          from(incomingURI).
          setHeader(Exchange.HTTP_METHOD, constant("PUT")).setHeader(Exchange.CONTENT_TYPE, constant("application/json")).
          to(outgoingURI);
      }
  }
  </code></pre>
  
  <p>My thoughts:</p>
  
  <p>Creating a <code>testConfiguration</code> extending <code>ServiceConfiguration</code> and pass that. But for that I need to set all the configuration and all because the <code>serviceConfiguration</code> contains many other classes. Can I use <code>Mockito</code> here? What is the correct and easy way to test this?</p>
  
  <p>EDIT: I was using the existing route, so that I don't have to write it again. Looks like that is not the correct way of testing in camel. See my test class. Of course, its not working.</p>
  
  <pre><code>public class RabbitMQRouteTest extends CamelTestSupport {
  
      @Mock
      ServiceConfiguration serviceConfiguration;
  
      @Override
      protected RouteBuilder createRouteBuilder() throws Exception {
          System.out.println("testing");
          return new TestRoute(serviceConfiguration);
      }
      @Test
      public void testConfigure() throws Exception {
          System.out.println("test");
  
          when(serviceConfiguration.getName()).thenReturn("file://target/inbox");
  
          template.sendBodyAndHeader("file://target/inbox", "Hello World",Exchange.FILE_NAME, "hello.txt");
          Thread.sleep(1000);
          File target = new File("target/outbox/hello.txt");
          assertTrue("File not moved", target.exists());
  
      }
  }
  </code></pre>