### Question:
SuffixFileFilter implements FileFilter, Serializable { @Override public boolean accept(final FileSelectInfo fileInfo) { final String name = fileInfo.getFile().getName().getBaseName(); for (final String suffix : this.suffixes) { if (caseSensitivity.checkEndsWith(name, suffix)) { return true; } } return false; } SuffixFileFilter(final List<String> suffixes);  SuffixFileFilter(final IOCase caseSensitivity, final List<String> suffixes);  SuffixFileFilter(final String... suffixes);  SuffixFileFilter(final IOCase caseSensitivity, final String... suffixes); @Override boolean accept(final FileSelectInfo fileInfo); @Override String toString();  }### Answer:
@Test public void testAcceptList() throws FileSystemException { final List<String> list = new ArrayList<>(); list.add(".txt"); list.add(".bin"); final SuffixFileFilter filter = new SuffixFileFilter(list); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.bin")))); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test2.BIN")))); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); }
@Test public void testAcceptListIOCaseInsensitive() throws FileSystemException { final List<String> list = new ArrayList<>(); list.add(".txt"); list.add(".bin"); final SuffixFileFilter filter = new SuffixFileFilter(IOCase.INSENSITIVE, list); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("TEST1.txt")))); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.bin")))); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.TXT")))); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); }
@Test public void testAcceptListIOCaseSensitive() throws FileSystemException { final List<String> list = new ArrayList<>(); list.add(".txt"); list.add(".bin"); final SuffixFileFilter filter = new SuffixFileFilter(IOCase.SENSITIVE, list); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test1.Txt")))); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test2.BIN")))); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); }
@Test public void testAcceptString() throws FileSystemException { final SuffixFileFilter filter = new SuffixFileFilter(".txt", ".xxx"); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test2.TXT")))); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.xxx")))); }
@Test public void testAcceptStringIOCaseInsensitive() throws FileSystemException { final SuffixFileFilter filter = new SuffixFileFilter(IOCase.INSENSITIVE, ".txt", ".xxx"); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.TXT")))); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.xxx")))); }
@Test public void testAcceptStringIOCaseSensitive() throws FileSystemException { final SuffixFileFilter filter = new SuffixFileFilter(IOCase.SENSITIVE, ".txt", ".xxx"); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test2.TXT")))); Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.xxx")))); }