File tree Expand file tree Collapse file tree
src/test/java/org/apache/commons/io/filefilter Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717package org .apache .commons .io .filefilter ;
1818
1919import java .util .ArrayList ;
20+ import java .util .Collections ;
2021import java .util .List ;
2122
2223import org .junit .jupiter .api .BeforeEach ;
24+ import org .junit .jupiter .api .Test ;
25+
26+ import static org .junit .jupiter .api .Assertions .assertEquals ;
2327
2428/**
2529 * Tests {@link AndFileFilter}.
@@ -294,4 +298,18 @@ public void setUpTestFilters() {
294298 testFilenameResults .add (9 , Boolean .FALSE );
295299 }
296300 }
301+
302+ @ Test
303+ public void setTestFiltersClearsOld () {
304+ // test that new filters correctly clear old filters
305+ final List <IOFileFilter > simpleEmptyFileFilter = Collections .singletonList (EmptyFileFilter .EMPTY );
306+ final AndFileFilter andFileFilter = new AndFileFilter (simpleEmptyFileFilter );
307+ // make sure the filters at this point are the same
308+ assertEquals (simpleEmptyFileFilter , andFileFilter .getFileFilters ());
309+
310+ final List <IOFileFilter > simpleNonEmptyFilter = Collections .singletonList (EmptyFileFilter .NOT_EMPTY );
311+ // when calling the setter the filters should reference the new filters
312+ andFileFilter .setFileFilters (simpleNonEmptyFilter );
313+ assertEquals (simpleNonEmptyFilter , andFileFilter .getFileFilters ());
314+ }
297315}
You can’t perform that action at this time.
0 commit comments