INT-4115: (S)FtpPersistentFileFilter by Default
JIRA: https://jira.spring.io/browse/INT-4115 Apply `(S)FtpPersistentAcceptOnceFileListFilter` for the `(S)FtpInboundFileSynchronizer` by default to avoid cases to sync the same remote files to the local directory again. Especially when `localFileName` strategy is applied and we end up with new local files, but with the same remote content Accept `(S)FtpPersistentAcceptOnceFileListFilter` for streaming adapters Make `doSetFilter()` as `protected final` Fix tests after rebase Fix "What's New" after rebase Compose `PersistentAcceptOnceFileListFilter` together with the regex or pattern filters Document such a behavior Address PR comments for formatting and typo
This commit is contained in:
committed by
Gary Russell
parent
d3fb8b8f9e
commit
10ce68d3e3
@@ -26,14 +26,20 @@ import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
import org.springframework.integration.file.filters.CompositeFileListFilter;
|
||||
import org.springframework.integration.file.filters.ExpressionFileListFilter;
|
||||
import org.springframework.integration.file.filters.FileListFilter;
|
||||
import org.springframework.integration.file.remote.session.CachingSessionFactory;
|
||||
import org.springframework.integration.sftp.filters.SftpPersistentAcceptOnceFileListFilter;
|
||||
import org.springframework.integration.sftp.filters.SftpSimplePatternFileListFilter;
|
||||
import org.springframework.integration.sftp.inbound.SftpStreamingMessageSource;
|
||||
import org.springframework.integration.sftp.session.DefaultSftpSessionFactory;
|
||||
@@ -76,7 +82,16 @@ public class SftpStreamingInboundChannelAdapterParserTests {
|
||||
|
||||
assertNotNull(TestUtils.getPropertyValue(source, "comparator"));
|
||||
assertThat(TestUtils.getPropertyValue(source, "remoteFileSeparator", String.class), equalTo("X"));
|
||||
assertThat(TestUtils.getPropertyValue(source, "filter"), instanceOf(SftpSimplePatternFileListFilter.class));
|
||||
|
||||
FileListFilter<?> filter = TestUtils.getPropertyValue(source, "filter", FileListFilter.class);
|
||||
assertNotNull(filter);
|
||||
assertThat(filter, instanceOf(CompositeFileListFilter.class));
|
||||
Set<?> fileFilters = TestUtils.getPropertyValue(filter, "fileFilters", Set.class);
|
||||
|
||||
Iterator<?> filtersIterator = fileFilters.iterator();
|
||||
assertThat(filtersIterator.next(), instanceOf(SftpSimplePatternFileListFilter.class));
|
||||
assertThat(filtersIterator.next(), instanceOf(SftpPersistentAcceptOnceFileListFilter.class));
|
||||
|
||||
assertSame(this.csf, TestUtils.getPropertyValue(source, "remoteFileTemplate.sessionFactory"));
|
||||
assertEquals(31, TestUtils.getPropertyValue(source, "maxFetchSize"));
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
import org.springframework.integration.file.FileHeaders;
|
||||
import org.springframework.integration.file.filters.AcceptAllFileListFilter;
|
||||
import org.springframework.integration.file.remote.FileInfo;
|
||||
import org.springframework.integration.file.remote.session.SessionFactory;
|
||||
import org.springframework.integration.scheduling.PollerMetadata;
|
||||
@@ -129,6 +130,7 @@ public class SftpStreamingMessageSourceTests extends SftpTestSupport {
|
||||
public MessageSource<InputStream> sftpMessageSource() {
|
||||
SftpStreamingMessageSource messageSource = new SftpStreamingMessageSource(template(),
|
||||
Comparator.comparing(FileInfo::getFilename));
|
||||
messageSource.setFilter(new AcceptAllFileListFilter<>());
|
||||
messageSource.setRemoteDirectory("sftpSource/");
|
||||
return messageSource;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user