Briefly. Catch the thing after your processor.
Take a look on code snippets in my article https://link.medium.com/oeURBq6R7nb
___
Best regards,
Vyacheslav.
Alaeddine HAOUAS <4codynam...@gmail.com> 4 марта 2022 г. 14:58:37 написал:
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