1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.betwixt.strategy;
18
19 import junit.framework.Test;
20 import junit.framework.TestCase;
21 import junit.framework.TestSuite;
22
23 /***
24 * Testcase that covers the DefaultNameMapper.
25 *
26 * @author <a href="mailto:martin@mvdb.net">Martin van den Bemt</a>
27 * @version $Id: TestDefaultNameMapper.java,v 1.6 2004/02/28 13:38:36 yoavs Exp $
28 */
29 public class TestDefaultNameMapper extends TestCase
30 {
31
32 public static Test suite() {
33 return new TestSuite(TestDefaultNameMapper.class);
34 }
35
36 public TestDefaultNameMapper(String testName)
37 {
38 super(testName);
39 }
40 /***
41 * Just put in some strings and expect them back unchanged.
42 * This looks stupid, but enables us to check for unexpected
43 * changes, which breaks the orignal behaviour.
44 */
45 public void testDefault() {
46 String[] values = { "foo", "Foo", "FooBar", "fooBar",
47 "FOOBAR", "FOOBar", "FoOBaR"};
48 DefaultNameMapper mapper = new DefaultNameMapper();
49 for (int i=0; i < values.length; i++) {
50 String result = mapper.mapTypeToElementName(values[i]);
51 assertEquals(values[i], result);
52 }
53 }
54
55 public void testBadCharBadFirstOne() {
56 String name="$LoadsOfMoney";
57 DefaultNameMapper mapper = new DefaultNameMapper();
58 String out = mapper.mapTypeToElementName(name);
59 assertEquals("Expected", "LoadsOfMoney", out);
60 }
61
62 public void testBadCharBadFirstTwo() {
63 String name="$LOADSŁOF$MONEY";
64 DefaultNameMapper mapper = new DefaultNameMapper();
65 String out = mapper.mapTypeToElementName(name);
66 assertEquals("Expected", "LOADSOFMONEY", out);
67 }
68
69 public void testBadCharGoodFirstOne() {
70 String name="L$oads%OfMone$y$";
71 DefaultNameMapper mapper = new DefaultNameMapper();
72 String out = mapper.mapTypeToElementName(name);
73 assertEquals("Expected", "LoadsOfMoney", out);
74 }
75
76 public void testBadCharGoodFirstTwo() {
77 String name="LOADSOFMONE$$Y";
78 DefaultNameMapper mapper = new DefaultNameMapper();
79 String out = mapper.mapTypeToElementName(name);
80 assertEquals("Expected", "LOADSOFMONEY", out);
81 }
82 }
83