title: Can Not Get @Component As A Bean In Unit Test For Spring Boot Application with Apache Camel
body: <p>I am doing unit test for my Spring Boot application with Camel. When the application runs, it can get bean which is configured as a @Component</p>
  
  <pre><code>@Component("agencyExporterProcessor")
  public class AgencyExporterProcessor {}
  </code></pre>
  
  <p>and I get the bean like this :</p>
  
  <pre><code> from(getTriggerExportEndpoint())
              .routeId(getTriggerExportId())
              // When shutting down, Camel will wait until the batch completed
              .shutdownRunningTask(ShutdownRunningTask.CompleteAllTasks)
              .log("[SamCustomExporter] - RouteId:${routeId} - Begin at ${date:now:MM/dd/yyyy HH:mm:ss.SSS}")
              .setHeader(Messaging.Names.SAM_DATA_AGENCY_CONFIGURATION_HEADER_KEY.toString(), constant(getConfiguration()))
  
              // Initialize a list to store exported CSV file names
              .bean(agencyExporterProcessor, "prepareExportedFileList")
  </code></pre>
  
  <p>But when I test, the route cannot get the bean"</p>
  
  <pre><code>org.apache.camel.FailedToCreateRouteException: Failed to create route agencyExporterRoute_triggerExport at: &gt;&gt;&gt; Bean[ref:agencyExporterProcessor method:prepareExportedFileList] &lt;&lt;&lt; in route: Route(agencyExporterRoute_triggerExport)[[From[direct:agency... because of No bean could be found in the registry for: agencyExporterProcessor
  </code></pre>
  
  <p>This is how I configured my unit test class:</p>
  
  <pre><code>@DirtiesContext
  @RunWith(SpringRunner.class)
  @EnableAutoConfiguration
  @SpringBootApplication
  @SpringBootTest(classes = SamCustomExporterSpringApplication.class, 
  webEnvironment = SpringBootTest.WebEnvironment.NONE)
  public class AgencyExporterRouteTest extends BaseRouteTestSupport {}
  </code></pre>
  
  <p>Please give advice!!!! Many thanks</p>