vendredi 14 septembre 2018

How to create a test case for spring integration?

I have an Ftp Configuration file like

 public class FtpConfig {

    @Bean
    public DefaultFtpSessionFactory ftpSessionFactory() {
        DefaultFtpSessionFactory sessionFactory = new DefaultFtpSessionFactory();
        sessionFactory.setHost("host");
        sessionFactory.setPort(21);
        sessionFactory.setUsername("ftpuser");
        sessionFactory.setPassword("pass");
        return sessionFactory;
    }

@ServiceActivator(inputChannel = "fromFtpChannel")
    @Bean
    public FtpOutboundGateway getFiles() {
        FtpOutboundGateway gateway = new FtpOutboundGateway(ftpSessionFactory(), "get", "payload");
        gateway.setOptions(AbstractRemoteFileOutboundGateway.Option.STREAM.getOption());
        gateway.setOutputChannelName("fileoutput");
        return gateway;
    }
}

And a Messaging Gateway

@MessagingGateway
public interface ReadFilesGateway {
    @Gateway(requestChannel = "fromFtpChannel", replyChannel = "fileoutput")
    InputStream readFiles(String directory);
}

The Messaging gateway is used to download files from the ftp server, to view the files as inputStream. A service FileService uses the gateway to read the files. How to write a possible testcase for the service, or the Messaging Gateway?

Aucun commentaire:

Enregistrer un commentaire