File tree Expand file tree Collapse file tree
microsphere-java-core/src/test/java/io/microsphere/io/filter Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package io .microsphere .io .filter ;
2+
3+ import org .junit .jupiter .api .Test ;
4+
5+ import java .io .File ;
6+ import java .io .IOException ;
7+
8+ import static io .microsphere .io .filter .DirectoryFileFilter .INSTANCE ;
9+ import static io .microsphere .util .SystemUtils .JAVA_HOME ;
10+ import static io .microsphere .util .SystemUtils .JAVA_IO_TMPDIR ;
11+ import static io .microsphere .util .SystemUtils .USER_DIR ;
12+ import static java .io .File .createTempFile ;
13+ import static org .junit .jupiter .api .Assertions .assertFalse ;
14+ import static org .junit .jupiter .api .Assertions .assertTrue ;
15+
16+ /**
17+ * {@link DirectoryFileFilter} Test
18+ *
19+ * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
20+ * @see DirectoryFileFilter
21+ * @since 1.0.0
22+ */
23+ public class DirectoryFileFilterTest {
24+
25+ @ Test
26+ public void testAcceptOnNull () {
27+ assertFalse (INSTANCE .accept (null ));
28+ }
29+
30+ @ Test
31+ public void testAcceptOnDirectory () {
32+ assertTrue (INSTANCE .accept (new File (JAVA_HOME )));
33+ assertTrue (INSTANCE .accept (new File (USER_DIR )));
34+ assertTrue (INSTANCE .accept (new File (JAVA_IO_TMPDIR )));
35+ }
36+
37+ @ Test
38+ public void testAcceptOnFile () throws IOException {
39+ File testFile = createTempFile ("test" , "txt" );
40+ assertFalse (INSTANCE .accept (testFile ));
41+ testFile .deleteOnExit ();
42+ }
43+
44+ }
You can’t perform that action at this time.
0 commit comments