in my spring-boot project i have the following class :
@Configuration
@EnableIntegration
public class ConsumeFiles {
@Bean
public IntegrationFlow inboundFileFromDirectory(@Value("${period}") long period,
@Value("${poller.max.messages.per.poll}") int maxMessagesPerPoll,
MessageSource<File> fileReadingFromSrc) {
return IntegrationFlow.from(fileReadingFromSrc,
c -> c.poller(Pollers.fixedDelay(period)
))
.transform(Files.toStringTransformer())
.channel("channel-1")
.get();
}
@ServiceActivator(inputChannel = "channel-1")
public void controleSignature(final Message<File> file) throws IOException {
// do things
}
@Bean
public MessageSource<File> fileReadingFromSrc() {
FileReadingMessageSource source = new FileReadingMessageSource();
source.setDirectory(new File(CONST_PATH));
source.setAutoCreateDirectory(true);
return source;
}
}
pretty basic : it monitors a directory, and when a file is dropped in it the flow starts (eg: control signature file and do other things) i would like to unit test a such class. i have already read a lot of resources on spring pages but i am really bad with testing. can someone please advice in a really simple way ?