01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: public static Test suite() {
33: return new TestSuite(TestDefaultNameMapper.class);
34: }
35:
36: public TestDefaultNameMapper(String testName) {
37: super (testName);
38: }
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", "FOOBAR",
47: "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: }
|