We have a remote FTP server in which we have a folder "test/" which contains certain text files. The "test/" folder has another subdirectory "archive/" inside it.

FTPserver-> -test/ ---abc.txt ---xyz.txt ---archive/

We are able to download all the text files via Spring Integration flows in our local directory and move the file into another remote location on same ftp server. Now we are looking into ways to test the below working code.

Working Code:

@Bean
    public IntegrationFlow integrationFlow() {            
        File localDirectory = new File("tmp/");
        FtpInboundChannelAdapterSpec ftpInboundChannelAdapterSpec = Ftp.inboundAdapter(gimmeFactory())
                .remoteDirectory("test/")
                .autoCreateLocalDirectory(true)
                .regexFilter(".*\\.txt$")
                .localDirectory(localDirectory)
                .preserveTimestamp(true)
                .remoteFileSeparator("/");
        
        return IntegrationFlows
                .from(ftpInboundChannelAdapterSpec, e -> e.poller(Pollers.fixedDelay(Duration.ofSeconds(5))))
                .handle(Ftp.outboundGateway(gimmeFactory(), AbstractRemoteFileOutboundGateway.Command.LS, "'test/'")
                        .options(AbstractRemoteFileOutboundGateway.Option.NAME_ONLY))
                .split()
                .handle(Ftp.outboundGateway(gimmeFactory(), AbstractRemoteFileOutboundGateway.Command.MV, "'test/' +payload").renameExpression("'test/archive/' +payload"))
                .channel("nullChannel")
                .get();
}

I have gone through many articles but not able to get the exact solution for this. Can anyone please help me here for to test the above working code. Thanks In advance.

1

There are 1 best solutions below

2
On