1   /* $Id: RegExpCreatorTest.java,v 1.1 2004/03/17 21:15:43 johndavidtaylor Exp $
2    * Created on Mar 10, 2004 by jdt
3    * The alipes project
4    * (c) 2004 
5    *
6    */
7   package org.abraracourcix.alipes.common;
8   
9   import org.apache.commons.logging.Log;
10  import org.apache.commons.logging.LogFactory;
11  
12  import junit.framework.TestCase;
13  
14  /***
15   * JUnit test
16   * @author jdt
17   *
18   */
19  public class RegExpCreatorTest extends TestCase {
20      /***
21       * Fire up textui
22       * @param args ignored
23       */
24      public static void main(String[] args) {
25          junit.textui.TestRunner.run(RegExpCreatorTest.class);
26      }
27      /***
28       * test the one and only method
29       *
30       */
31      public void testGetRegExp1() {
32          doTest("*.txt", ".*//.txt");
33      }
34      /***
35       * test the one and only method
36       *
37       */
38      public void testGetRegExp4() {
39          doTest("?fred.*", ".fred//..*");
40      }
41      /***
42       * test the one and only method
43       *
44       */
45      public void testGetRegExp2() {
46          doTest("?", ".");
47      }
48      /***
49       * test the one and only method
50       *
51       */
52      public void testGetRegExp3() {
53          doTest("foo.???","foo//....");
54      }
55      /***
56       * Do the test's donkey work
57       * @param wildCard the wildcard we try
58       * @param regExp the regExp we expect
59       */
60      private  void doTest(final String wildCard, final String regExp) {
61          String result = RegExpCreator.getRegExp(wildCard);
62          log.debug("Wildcard: "+wildCard);
63          log.debug("regExp: "+regExp);
64          log.debug("result: "+result);
65          assertEquals(regExp, result);
66      }
67      /***
68       * Commons Log
69       */
70      private static Log log = LogFactory.getLog("Test");
71  }
72  
73  
74  /*
75   *  $Log: RegExpCreatorTest.java,v $
76   *  Revision 1.1  2004/03/17 21:15:43  johndavidtaylor
77   *  Copied across from incubation in beanpeeler
78   *
79   *  Revision 1.1  2004/03/11 09:49:24  johndavidtaylor
80   *  Loads of updates
81   *
82   */