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