我有一个ftp配置文件,例如
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;
}
}
还有消息传递网关
@MessagingGateway
public interface ReadFilesGateway {
@Gateway(requestChannel = "fromFtpChannel", replyChannel = "fileoutput")
InputStream readFiles(String directory);
}
消息传递网关用于从ftp服务器下载文件,以输入流的形式查看文件。服务FileService使用网关读取文件。如何为服务或消息传递网关编写可能的测试用例?