1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.sf.jour.rt.view;
22
23 import junit.framework.TestCase;
24
25
26 import org.apache.log4j.Logger;
27
28 /***
29 * TODO Add docs
30 *
31 * Created on 16.12.2004
32 * Contributing Author(s):
33 *
34 * Misha Lifschitz <mishalifschitz at users.sourceforge.net> (Inital implementation)
35 * Vlad Skarzhevskyy <vlads at users.sourceforge.net> (Inital implementation)
36 *
37 * @author vlads
38 * @version $Revision: 1.1 $ ($Author: vlads $) $Date: 2004/12/16 17:40:20 $
39 */
40 public class ReplacementListTest extends TestCase {
41
42 protected static final Logger log = Logger.getLogger(ReplacementListTest.class);
43
44 private void verify(String[] patterns, String text, String expect) {
45 ReplacementList l = new ReplacementList();
46 l.buildList(patterns);
47 String actual = l.subst(text);
48 log.debug("[" + text + "] -> [" + actual + "]");
49 assertEquals("for " + text, expect, actual);
50 }
51
52 public void testSignaturePatterns() {
53
54 verify(new String[] {"Bar", "Foo"}, "Bar", "Foo");
55
56 String[] patterns = new String[] {
57 "^(Bar)$", "foo$1",
58 "(Foo)(.*)", "Bar$2",
59 "Ljava/lang/String", "S",
60 "Ljava/lang/([^/]*)", "$1",
61 "Ljava/util/Vector", "Vector",
62 "Lamdocs/APILink/implementation", "dox~"
63 };
64 verify(patterns, "Bar", "fooBar");
65 verify(patterns, "Foo", "Bar");
66 verify(patterns, "FooBar", "BarBar");
67 verify(patterns, "(Ljava/lang/String;)V", "(S;)V");
68 verify(patterns, "(Ljava/lang/Bar;)V", "(Bar;)V");
69 verify(patterns, "(Ljava/util/Vector;)V", "(Vector;)V");
70 verify(patterns, "(Ljava/util/Vector;Ljava/lang/String;Ljava/lang/String;)V", "(Vector;S;S;)V");
71 }
72 }