KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > betwixt > strategy > TestDefaultNameMapper


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
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 JavaDoc 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 JavaDoc[] 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 JavaDoc result = mapper.mapTypeToElementName(values[i]);
51             assertEquals(values[i], result);
52         }
53     }
54     
55     public void testBadCharBadFirstOne() {
56         String JavaDoc name="$LoadsOfMoney";
57         DefaultNameMapper mapper = new DefaultNameMapper();
58         String JavaDoc out = mapper.mapTypeToElementName(name);
59         assertEquals("Expected", "LoadsOfMoney", out);
60     }
61     
62     public void testBadCharBadFirstTwo() {
63         String JavaDoc name="$LOADSŁOF$MONEY";
64         DefaultNameMapper mapper = new DefaultNameMapper();
65         String JavaDoc out = mapper.mapTypeToElementName(name);
66         assertEquals("Expected", "LOADSOFMONEY", out);
67     }
68     
69     public void testBadCharGoodFirstOne() {
70         String JavaDoc name="L$oads%OfMone$y$";
71         DefaultNameMapper mapper = new DefaultNameMapper();
72         String JavaDoc out = mapper.mapTypeToElementName(name);
73         assertEquals("Expected", "LoadsOfMoney", out);
74     }
75     
76     public void testBadCharGoodFirstTwo() {
77         String JavaDoc name="LOADSOFMONE$$Y";
78         DefaultNameMapper mapper = new DefaultNameMapper();
79         String JavaDoc out = mapper.mapTypeToElementName(name);
80         assertEquals("Expected", "LOADSOFMONEY", out);
81     }
82 }
83
84
Popular Tags