INT-1614 synchronize method now accepts the loacl directory as an argument rather than having its own direct reference
This commit is contained in:
@@ -59,7 +59,6 @@ public class SftpInboundChannelAdapterParser extends AbstractPollingInboundChann
|
||||
"org.springframework.integration.sftp.inbound.SftpInboundSynchronizer");
|
||||
synchronizerBuilder.addConstructorArgReference(sessionPollName);
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(synchronizerBuilder, element, "remote-directory", "remotePath");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(synchronizerBuilder, element, "local-directory");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(synchronizerBuilder, element, "auto-delete-remote-files-on-sync", "shouldDeleteSourceFile");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(synchronizerBuilder, element, "filter");
|
||||
BeanDefinitionBuilder messageSourceBuilder = BeanDefinitionBuilder.rootBeanDefinition(
|
||||
|
||||
@@ -118,7 +118,7 @@ public class SftpInboundSynchronizer extends AbstractInboundRemoteFileSystemSych
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void syncRemoteToLocalFileSystem() {
|
||||
protected void syncRemoteToLocalFileSystem(Resource localDirectory) {
|
||||
SftpSession session = null;
|
||||
try {
|
||||
session = sessionPool.getSession();
|
||||
@@ -132,7 +132,7 @@ public class SftpInboundSynchronizer extends AbstractInboundRemoteFileSystemSych
|
||||
Collection<ChannelSftp.LsEntry> files = this.filterFiles(entries);
|
||||
for (ChannelSftp.LsEntry lsEntry : files) {
|
||||
if ((lsEntry != null) && !lsEntry.getAttrs().isDir() && !lsEntry.getAttrs().isLink()) {
|
||||
copyFromRemoteToLocalDirectory(session, lsEntry, this.getLocalDirectory());
|
||||
copyFromRemoteToLocalDirectory(session, lsEntry, 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.sftp.session.SftpSession;
|
||||
import org.springframework.integration.sftp.session.SftpSessionPool;
|
||||
@@ -51,7 +52,6 @@ public class SftpInboundRemoteFileSystemSynchronizerTests {
|
||||
}
|
||||
SftpSessionPool sessionPool = mock(SftpSessionPool.class);
|
||||
SftpInboundSynchronizer syncronizer = new SftpInboundSynchronizer(sessionPool);
|
||||
syncronizer.setLocalDirectory(new FileSystemResource(System.getProperty("java.io.tmpdir")));
|
||||
syncronizer.setRemotePath("foo/bar");
|
||||
|
||||
FileListFilter filter = mock(FileListFilter.class);
|
||||
@@ -79,7 +79,8 @@ public class SftpInboundRemoteFileSystemSynchronizerTests {
|
||||
syncronizer.setShouldDeleteSourceFile(true);
|
||||
syncronizer.afterPropertiesSet();
|
||||
|
||||
syncronizer.syncRemoteToLocalFileSystem();
|
||||
Resource localDirectory = new FileSystemResource(System.getProperty("java.io.tmpdir"));
|
||||
syncronizer.syncRemoteToLocalFileSystem(localDirectory);
|
||||
|
||||
verify(sessionPool, times(1)).getSession();
|
||||
verify(sftpSession, atLeast(1)).getChannel();
|
||||
|
||||
Reference in New Issue
Block a user