1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */ 
17   
18  package org.apache.commons.betwixt.strategy;
19  
20  import junit.framework.Test;
21  import junit.framework.TestCase;
22  import junit.framework.TestSuite;
23  
24  /**
25   * Testcase that covers the DefaultNameMapper.
26   * 
27   * @author <a href="mailto:martin@mvdb.net">Martin van den Bemt</a>
28   * @version $Id: TestDefaultNameMapper.java 438373 2006-08-30 05:17:21Z bayard $
29   */
30  public class TestDefaultNameMapper extends TestCase
31  {
32      
33      public static Test suite() {
34          return new TestSuite(TestDefaultNameMapper.class);
35      }
36  
37      public TestDefaultNameMapper(String testName)
38      {
39          super(testName);
40      }
41      /**
42       * Just put in some strings and expect them back unchanged.
43       * This looks stupid, but enables us to check for unexpected
44       * changes, which breaks the orignal behaviour.
45       */
46      public void testDefault() {
47          String[] values = { "foo", "Foo", "FooBar", "fooBar", 
48                              "FOOBAR", "FOOBar", "FoOBaR"};
49          DefaultNameMapper mapper = new DefaultNameMapper();
50          for (int i=0; i < values.length; i++) {
51              String result = mapper.mapTypeToElementName(values[i]);
52              assertEquals(values[i], result);
53          }
54      }
55      
56      public void testBadCharBadFirstOne() {
57          String name="$LoadsOfMoney";
58          DefaultNameMapper mapper = new DefaultNameMapper();
59          String out = mapper.mapTypeToElementName(name);
60          assertEquals("Expected", "LoadsOfMoney", out);
61      }
62      
63      public void testBadCharBadFirstTwo() {
64          String name="$LOADSŁOF$MONEY";
65          DefaultNameMapper mapper = new DefaultNameMapper();        
66          String out = mapper.mapTypeToElementName(name);
67          assertEquals("Expected", "LOADSOFMONEY", out);
68      }
69      
70      public void testBadCharGoodFirstOne() {
71          String name="L$oads%OfMone$y$";
72          DefaultNameMapper mapper = new DefaultNameMapper();        
73          String out = mapper.mapTypeToElementName(name);
74          assertEquals("Expected", "LoadsOfMoney", out);
75      }
76      
77      public void testBadCharGoodFirstTwo() {
78          String name="LOADSOFMONE$$Y";
79          DefaultNameMapper mapper = new DefaultNameMapper();        
80          String out = mapper.mapTypeToElementName(name);
81          assertEquals("Expected", "LOADSOFMONEY", out);
82      }
83  }
84