1
2
3
4
5
6 package org.abraracourcix.alipes.common;
7 import java.io.File;
8 import java.io.FileFilter;
9 import java.io.IOException;
10 import junit.framework.TestCase;
11 /***
12 *
13 * JUnit test for RegExpFileFilterTest
14 * @author jdt
15 */
16 public final class RegExpFileFilterTest extends TestCase {
17 /***
18 * fire up the textui
19 *
20 * @param args
21 * ignored
22 */
23 public static void main(final String[] args) {
24 junit.textui.TestRunner.run(RegExpFileFilterTest.class);
25 }
26 /***
27 * Try a couple of simple regexps
28 *
29 * @throws IOException
30 * apparently
31 */
32 public void testAccept() throws IOException {
33 final FileFilter filter = new RegExpFileFilter("temp.txt", new File("files"));
34 assertTrue(filter.accept(new File("files/temp.txt")));
35 assertFalse(filter.accept(new File("fillets/temp.txt")));
36 }
37 /***
38 * Try a more complicated regexp
39 *
40 * @throws IOException
41 * sometimes
42 */
43 public void testAccept2() throws IOException {
44 final FileFilter filter = new RegExpFileFilter("[Aa]bc", new File("files"));
45 assertTrue(filter.accept(new File("files/abc")));
46 assertTrue(filter.accept(new File("files/Abc")));
47 assertFalse(filter.accept(new File("files/cbc")));
48 assertFalse(filter.accept(new File("fillets/temp.txt")));
49 }
50 /***
51 * test that we can construct the RegExpFileFilter without problems
52 *
53 * @throws IOException
54 * occasionally
55 */
56 public void testRegExpFileFilter() throws IOException {
57 new RegExpFileFilter("regexp", new File(""));
58 }
59 }
60
61
62
63
64
65
66
67
68
69
70
71
72
73