What do you mean by "Processor is not starting"? Is there an exception?

Usually when I want to truly *unit* test a processor, I simply instantiate
the processor in a test method, then pass an exchange to its `process`
method that contains whatever headers and body are needed to exercise the
processor's code.



On Fri, Mar 4, 2022 at 5:58 AM Alaeddine HAOUAS <4codynam...@gmail.com>
wrote:

> Hi,
>
> I have an issue in a unit test, to verify a Processor.
> Context is a Spring-boot application used to control a Camel route, that
> triggers eventually a Camel processor.
>
> In a JUnit test, I achieved to have the RouteBuilder started and tested
> successfully until the instruction setting up the Processor. Processor is
> not starting, so I can't verify it.
>
> How can I successfully trigger/test the processor ?
>
> The code :
>
> @Component
> public class CsvRouteBuilder extends RouteBuilder {
> //....
>
> private void process(.....) {
>         // .....
>
>         String fromRoute = String.join("", "file:",
> orgParPath.toAbsolutePath().toString(),
>                 "?moveFailed=", ERROR, "&move=", ARCHIVE, "&delay=",
>                 delayIntervalMilliSec);
>
>         // initializing the context
>
>         final Processor processor =
> CsvProcessor.builder().csvExecutionContext(context)
>                 .csvHdConnectProxyRestTemplate(hdConnectProxy)
>                 .executorService(executorService).build();
>
>         from(fromRoute).unmarshal().csv().process(processor);
> }
>
> //.... another class
> @Builder
> public class CsvProcessor implements Processor {
> // ...
> // The custom processor has nothing exotic, it is just implementing the
> process method.
> }
>
> //.... another class
> @ExtendWith(SpringExtension.class)
> @CamelSpringBootTest
> @UseAdviceWith
> @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
> classes = Application.class)
> @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class,
> HibernateJpaAutoConfiguration.class})
> @DisableJmx
> @ContextConfiguration(classes = {TestConfig.class})
> @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
> public class CsvRouteBuilderTest {
>
>     @Autowired
>     ProducerTemplate producerTemplate;
>
>     @Autowired
>     private TestRestTemplate restTemplate;
>
>     @Autowired
>     private CsvRouteBuilder route;
>
> // ....
> }
>
> Regards
> Alaeddine
>

Reply via email to