title: Apache Camel Springboot test: Camel context is null
body: <p>I'm trying to write a simple plain spring test for Apache Camel. My goal is just to test if the Camel Context is started.</p>
  
  <p>The code is:</p>
  
  <pre><code>@RunWith(CamelSpringRunner.class)
  @BootstrapWith(CamelTestContextBootstrapper.class)
  @ContextConfiguration()
  @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
  class CamelPocApplicationTests {
  
      @Autowired
      protected CamelContext camelContext;
  
      @Test
      void contextLoads() {
          assertEquals(ServiceStatus.Started, camelContext.getStatus());
      }
  
  }
  </code></pre>
  
  <p>but the test fails because the Camel Context is null. What am I doing wrong?</p>
  
  <p><strong>EDIT:</strong> </p>
  
  <p>I finally had time to work on this project again.
  The correct configuration is:</p>
  
  <pre><code>@RunWith(CamelSpringBootRunner.class)
  @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
  @SpringBootTest
  class CamelPocApplicationTests {
  
      @Autowired
      protected CamelContext camelContext;
  
      @Test
      void contextLoads() {
          assertEquals(ServiceStatus.Started, camelContext.getStatus());
      }
  
  }
  </code></pre>
  
  <p>This way the test works.</p>
  
  <p>Thank you guys! I refer to <a href="https://stackoverflow.com/questions/58802231/simple-unit-test-for-apache-camel-snmp-route/58826285#58826285">this answer</a> for more.</p>
  
  <p>Now my questions are:</p>
  
  <ol>
  <li>Why the Camel test <a href="https://camel.apache.org/manual/latest/testing.html#Testing-SpringTestwithXMLConfigandDeclarativeConfigurationExample" rel="nofollow noreferrer">documentation</a> states otherwise? Why isn't there the @SpringBootTest annotation and why bootstrapping with CamelTestContextBootstrapper.class makes the test failing either?</li>
  <li>What is the difference between @RunWith(CamelSpringRunner.class)
  and @RunWith(CamelSpringBootRunner.class)? I noticed the test would run the same.</li>
  </ol>