1   /*
2    * $Id: RegExpFileFilterTest.java,v 1.1 2004/03/17 21:15:43 johndavidtaylor Exp $
3    * Created on Mar 9, 2004 by jdt The alipes project (c) 2004
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   * $Log: RegExpFileFilterTest.java,v $
62   * Revision 1.1  2004/03/17 21:15:43  johndavidtaylor
63   * Copied across from incubation in beanpeeler
64   *
65   * Revision 1.3  2004/03/14 18:49:15  johndavidtaylor
66   * corrected comments
67   *
68   * Revision 1.2  2004/03/11 16:35:47  johndavidtaylor
69   * brought up to standard
70   * Revision 1.1 2004/03/09 22:29:32
71   * johndavidtaylor Added stuff for file wildcards/regexps
72   *  
73   */