INT-1614 synchronize method now accepts the loacl directory as an argument rather than having its own direct reference
This commit is contained in:
@@ -128,7 +128,6 @@ class FtpInboundSynchronizingMessageSourceFactoryBean
|
||||
QueuedFtpClientPool queuedFtpClientPool = new QueuedFtpClientPool(15, this.clientFactory);
|
||||
FtpInboundRemoteFileSystemSynchronizer synchronizer = new FtpInboundRemoteFileSystemSynchronizer();
|
||||
synchronizer.setClientPool(queuedFtpClientPool);
|
||||
synchronizer.setLocalDirectory(this.localDirectoryResource);
|
||||
synchronizer.setShouldDeleteSourceFile(ackRemoteDir);
|
||||
synchronizer.setFilter(compositeFilter);
|
||||
messageSource.setRemotePredicate(compositeFilter);
|
||||
|
||||
@@ -62,7 +62,7 @@ public class FtpInboundRemoteFileSystemSynchronizer extends AbstractInboundRemot
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void syncRemoteToLocalFileSystem() {
|
||||
protected void syncRemoteToLocalFileSystem(Resource localDirectory) {
|
||||
try {
|
||||
FTPClient client = this.clientPool.getClient();
|
||||
Assert.state(client != null,
|
||||
@@ -73,7 +73,7 @@ public class FtpInboundRemoteFileSystemSynchronizer extends AbstractInboundRemot
|
||||
try {
|
||||
for (FTPFile ftpFile : fileList) {
|
||||
if ((ftpFile != null) && ftpFile.isFile()) {
|
||||
copyFileToLocalDirectory(client, ftpFile, this.getLocalDirectory());
|
||||
copyFileToLocalDirectory(client, ftpFile, localDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.integration.file.filters.FileListFilter;
|
||||
import org.springframework.integration.ftp.client.DefaultFtpClientFactory;
|
||||
import org.springframework.integration.ftp.client.QueuedFtpClientPool;
|
||||
@@ -48,9 +49,7 @@ public class FtpInboundRemoteFileSystemSynchronizerTest {
|
||||
file.delete();
|
||||
}
|
||||
FtpInboundRemoteFileSystemSynchronizer syncronizer = new FtpInboundRemoteFileSystemSynchronizer();
|
||||
syncronizer.setLocalDirectory(new FileSystemResource(System.getProperty("java.io.tmpdir")));
|
||||
FileListFilter filter = new FtpPatternMatchingFileListFilter("foo.txt");
|
||||
//
|
||||
syncronizer.setFilter(filter);
|
||||
|
||||
DefaultFtpClientFactory factory = mock(DefaultFtpClientFactory.class);
|
||||
@@ -71,7 +70,8 @@ public class FtpInboundRemoteFileSystemSynchronizerTest {
|
||||
syncronizer.setShouldDeleteSourceFile(true);
|
||||
syncronizer.afterPropertiesSet();
|
||||
|
||||
syncronizer.syncRemoteToLocalFileSystem();
|
||||
Resource localDirectory = new FileSystemResource(System.getProperty("java.io.tmpdir"));
|
||||
syncronizer.syncRemoteToLocalFileSystem(localDirectory);
|
||||
|
||||
verify(ftpClient, times(1)).retrieveFile(Mockito.anyString(), Mockito.any(OutputStream.class));
|
||||
verify(ftpClient, times(1)).deleteFile(Mockito.anyString());
|
||||
|
||||
Reference in New Issue
Block a user