use of org.springframework.integration.file.filters.FileListFilter in project spring-integration by spring-projects.
the class PatternMatchingFileListFilterTests method patternEditorInContext.
@Test
@SuppressWarnings("unchecked")
public void patternEditorInContext() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("patternMatchingFileListFilterTests.xml", this.getClass());
FileListFilter<File> filter = (FileListFilter<File>) context.getBean("filter");
File[] files = new File[] { new File("/some/path/foo.txt") };
List<File> accepted = filter.filterFiles(files);
assertEquals(1, accepted.size());
context.close();
}
use of org.springframework.integration.file.filters.FileListFilter in project spring-integration by spring-projects.
the class FileInboundChannelAdapterWithPatternParserTests method compositeFilterSetSize.
@Test
@SuppressWarnings("unchecked")
public void compositeFilterSetSize() {
DirectFieldAccessor scannerAccessor = new DirectFieldAccessor(accessor.getPropertyValue("scanner"));
Set<FileListFilter<File>> filters = (Set<FileListFilter<File>>) new DirectFieldAccessor(scannerAccessor.getPropertyValue("filter")).getPropertyValue("fileFilters");
assertEquals(2, filters.size());
}
use of org.springframework.integration.file.filters.FileListFilter in project spring-integration by spring-projects.
the class FileInboundChannelAdapterWithPatternParserTests method patternFilter.
@Test
@SuppressWarnings("unchecked")
public void patternFilter() {
DirectFieldAccessor scannerAccessor = new DirectFieldAccessor(accessor.getPropertyValue("scanner"));
Set<FileListFilter<?>> filters = (Set<FileListFilter<?>>) new DirectFieldAccessor(scannerAccessor.getPropertyValue("filter")).getPropertyValue("fileFilters");
String pattern = null;
for (FileListFilter<?> filter : filters) {
if (filter instanceof SimplePatternFileListFilter) {
pattern = (String) new DirectFieldAccessor(filter).getPropertyValue("path");
}
}
assertNotNull("expected SimplePatternFileListFilterTest", pattern);
assertEquals("*.txt", pattern.toString());
}
use of org.springframework.integration.file.filters.FileListFilter 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.FileListFilter in project spring-integration by spring-projects.
the class FileInboundChannelAdapterWithClasspathInPropertiesTests method inputDirectory.
@Test
@SuppressWarnings("unchecked")
public void inputDirectory() throws Exception {
File expected = new ClassPathResource("").getFile();
File actual = (File) accessor.getPropertyValue("directory");
assertEquals("'directory' should be set", expected, actual);
FileListFilter<File> fileListFilter = TestUtils.getPropertyValue(this.source, "scanner.filter", FileListFilter.class);
assertThat(fileListFilter, instanceOf(CompositeFileListFilter.class));
Set<FileListFilter<File>> fileFilters = TestUtils.getPropertyValue(fileListFilter, "fileFilters", Set.class);
assertEquals(2, fileFilters.size());
Iterator<FileListFilter<File>> iterator = fileFilters.iterator();
iterator.next();
FileListFilter<File> expressionFilter = iterator.next();
assertThat(expressionFilter, instanceOf(ExpressionFileListFilter.class));
assertEquals("true", TestUtils.getPropertyValue(expressionFilter, "expression.expression", String.class));
assertSame(this.beanFactory, TestUtils.getPropertyValue(expressionFilter, "beanFactory"));
}
Aggregations