use of org.springframework.integration.file.filters.AcceptOnceFileListFilter in project spring-integration by spring-projects.
the class FileInboundChannelAdapterParserTests method filter.
@Test
public void filter() throws Exception {
DefaultDirectoryScanner scanner = (DefaultDirectoryScanner) accessor.getPropertyValue("scanner");
DirectFieldAccessor scannerAccessor = new DirectFieldAccessor(scanner);
Object filter = scannerAccessor.getPropertyValue("filter");
assertTrue("'filter' should be set and be of instance AcceptOnceFileListFilter but got " + filter.getClass().getSimpleName(), filter instanceof AcceptOnceFileListFilter);
assertThat(scanner.getClass().getName(), containsString("FileReadingMessageSource$WatchServiceDirectoryScanner"));
FileReadingMessageSource.WatchEventType[] watchEvents = (FileReadingMessageSource.WatchEventType[]) this.accessor.getPropertyValue("watchEvents");
assertEquals(2, watchEvents.length);
for (FileReadingMessageSource.WatchEventType watchEvent : watchEvents) {
assertNotEquals(FileReadingMessageSource.WatchEventType.CREATE, watchEvent);
assertThat(watchEvent, isOneOf(FileReadingMessageSource.WatchEventType.MODIFY, FileReadingMessageSource.WatchEventType.DELETE));
}
}
use of org.springframework.integration.file.filters.AcceptOnceFileListFilter in project spring-integration by spring-projects.
the class FileInboundChannelAdapterWithPatternParserTests method acceptOnceFilter.
@Test
@SuppressWarnings("unchecked")
public void acceptOnceFilter() {
DirectFieldAccessor scannerAccessor = new DirectFieldAccessor(accessor.getPropertyValue("scanner"));
Set<FileListFilter<File>> filters = (Set<FileListFilter<File>>) new DirectFieldAccessor(scannerAccessor.getPropertyValue("filter")).getPropertyValue("fileFilters");
boolean hasAcceptOnceFilter = false;
for (FileListFilter<File> filter : filters) {
if (filter instanceof AcceptOnceFileListFilter) {
hasAcceptOnceFilter = true;
}
}
assertTrue("expected AcceptOnceFileListFilter", hasAcceptOnceFilter);
}
use of org.springframework.integration.file.filters.AcceptOnceFileListFilter in project spring-integration by spring-projects.
the class FileInboundChannelAdapterWithPreventDuplicatesFlagTests method defaultAndTrue.
@Test
public void defaultAndTrue() throws Exception {
FileListFilter<File> filter = this.extractFilter("defaultAndTrue");
assertFalse(filter instanceof CompositeFileListFilter);
assertTrue(filter instanceof AcceptOnceFileListFilter);
File testFile = new File("test");
File[] files = new File[] { testFile, testFile, testFile };
List<File> result = filter.filterFiles(files);
assertEquals(1, result.size());
}
Aggregations