title: Test Camel Processor in Spring Boot
body: <p>I'm trying to test a Camel Processor in Spring Boot. However I am getting alot of exceptions even when following the guidance from Camel in Action and other SO answers.</p>
  
  <p>I am using Camel 3.0.0-M4</p>
  
  <p>For example here is my test:</p>
  
  <pre><code>@SpringBootTest
  @BootstrapWith(SpringBootTestContextBootstrapper.class)
  public class MyProcessorTest extends CamelTestSupport {
  
      @Produce
      ProducerTemplate template;
  
      @EndpointInject(uri = "mock:out")
      private MockEndpoint resultEndpoint;
  
      @Before
      public void setUp() throws Exception {
          super.setUp();
      }
  
      @BeforeClass
      public static void stopCamelStart() {
          SpringCamelContext.setNoStart(true);
      }
  
      @AfterClass
      public static void enableCamelStart() {
          SpringCamelContext.setNoStart(false);
      }
  
      @Before
      protected RouteBuilder createRouteBuilder() throws Exception {
          return new RouteBuilder() {
              @Override
              public void configure() throws Exception {
                  from("seda:test")
                          .process(new MyProcessor())
                          .to("mock:out");
              }
          };
      }
  
      @Test
      public void testPrepend() throws Exception {
          Map&lt;String, String&gt; body = new HashMap&lt;String, String&gt;();
          body.put("test", "body");
  
          template.sendBody("seda:test", body);
          String result = resultEndpoint.getExchanges().get(0).getIn().getBody(String.class);
  
      }
  }
  
  </code></pre>
  
  <p>I get an <code>java.lang.ArrayIndexOutOfBoundsException</code></p>
  
  <p>If I try and start the camel context <code>context.start();</code> I get a <code>java.lang.NullPointerException</code></p>
  
  <p>If I swap the route I sent the body to <code>template.sendBody("mock:out", body);</code> no processing has happened.</p>
  
  <p>If I change from <code>seda:test</code> to <code>direct:test</code> I get a very slow running test and <code>org.apache.camel.component.direct.DirectConsumerNotAvailableException: No consumers available on endpoint: direct://test</code></p>
  
  <p>Where am I going wrong??</p>