Search in sources :

Example 6 with RegexPatternFileListFilter

use of org.springframework.integration.file.filters.RegexPatternFileListFilter in project spring-integration by spring-projects.

the class PatternMatchingFileListFilterTests method matchSingleFile.

@Test
public void matchSingleFile() {
    File[] files = new File[] { new File("/some/path/test.txt") };
    Pattern pattern = Pattern.compile("[a-z]+\\.txt");
    RegexPatternFileListFilter filter = new RegexPatternFileListFilter(pattern);
    List<File> accepted = filter.filterFiles(files);
    assertEquals(1, accepted.size());
}
Also used : Pattern(java.util.regex.Pattern) RegexPatternFileListFilter(org.springframework.integration.file.filters.RegexPatternFileListFilter) File(java.io.File) Test(org.junit.Test)

Example 7 with RegexPatternFileListFilter

use of org.springframework.integration.file.filters.RegexPatternFileListFilter in project spring-integration by spring-projects.

the class PatternMatchingFileListFilterTests method matchSubset.

@Test
public void matchSubset() {
    File[] files = new File[] { new File("/some/path/foo.txt"), new File("/some/path/foo.not"), new File("/some/path/bar.txt"), new File("/some/path/bar.not") };
    Pattern pattern = Pattern.compile("[a-z]+\\.txt");
    RegexPatternFileListFilter filter = new RegexPatternFileListFilter(pattern);
    List<File> accepted = filter.filterFiles(files);
    assertEquals(2, accepted.size());
    assertTrue(accepted.contains(new File("/some/path/foo.txt")));
    assertTrue(accepted.contains(new File("/some/path/bar.txt")));
}
Also used : Pattern(java.util.regex.Pattern) RegexPatternFileListFilter(org.springframework.integration.file.filters.RegexPatternFileListFilter) File(java.io.File) Test(org.junit.Test)

Aggregations

RegexPatternFileListFilter (org.springframework.integration.file.filters.RegexPatternFileListFilter)7 File (java.io.File)6 Test (org.junit.Test)6 Pattern (java.util.regex.Pattern)4 CompositeFileListFilter (org.springframework.integration.file.filters.CompositeFileListFilter)4 FileListFilter (org.springframework.integration.file.filters.FileListFilter)4 ArrayList (java.util.ArrayList)3 AcceptOnceFileListFilter (org.springframework.integration.file.filters.AcceptOnceFileListFilter)3 Collection (java.util.Collection)2 BeanFactory (org.springframework.beans.factory.BeanFactory)2 PropertiesPersistingMetadataStore (org.springframework.integration.metadata.PropertiesPersistingMetadataStore)2 LsEntry (com.jcraft.jsch.ChannelSftp.LsEntry)1 Set (java.util.Set)1 FTPFile (org.apache.commons.net.ftp.FTPFile)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 Expression (org.springframework.expression.Expression)1 ExpressionParser (org.springframework.expression.ExpressionParser)1 SpelParserConfiguration (org.springframework.expression.spel.SpelParserConfiguration)1 SpelExpressionParser (org.springframework.expression.spel.standard.SpelExpressionParser)1 RecursiveDirectoryScanner (org.springframework.integration.file.RecursiveDirectoryScanner)1