1
2
3
4
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
76
77
78
79
80
81
82