001: /*
002: * Copyright 2003-2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.commons.math.util;
018:
019: import junit.framework.TestCase;
020:
021: /**
022: * @version $Revision: 155427 $ $Date: 2005-02-26 06:11:52 -0700 (Sat, 26 Feb 2005) $
023: */
024: public class TransformerMapTest extends TestCase {
025: /**
026: *
027: */
028: public void testPutTransformer() {
029: NumberTransformer expected = new DefaultTransformer();
030:
031: TransformerMap map = new TransformerMap();
032: map.putTransformer(TransformerMapTest.class, expected);
033: assertEquals(expected, map
034: .getTransformer(TransformerMapTest.class));
035: }
036:
037: /**
038: *
039: */
040: public void testContainsClass() {
041: NumberTransformer expected = new DefaultTransformer();
042: TransformerMap map = new TransformerMap();
043: map.putTransformer(TransformerMapTest.class, expected);
044: assertTrue(map.containsClass(TransformerMapTest.class));
045: }
046:
047: /**
048: *
049: */
050: public void testContainsTransformer() {
051: NumberTransformer expected = new DefaultTransformer();
052: TransformerMap map = new TransformerMap();
053: map.putTransformer(TransformerMapTest.class, expected);
054: assertTrue(map.containsTransformer(expected));
055: }
056:
057: /**
058: *
059: */
060: public void testRemoveTransformer() {
061: NumberTransformer expected = new DefaultTransformer();
062:
063: TransformerMap map = new TransformerMap();
064: map.putTransformer(TransformerMapTest.class, expected);
065: assertTrue(map.containsClass(TransformerMapTest.class));
066: assertTrue(map.containsTransformer(expected));
067: map.removeTransformer(TransformerMapTest.class);
068: assertFalse(map.containsClass(TransformerMapTest.class));
069: assertFalse(map.containsTransformer(expected));
070: }
071:
072: /**
073: *
074: */
075: public void testClear() {
076: NumberTransformer expected = new DefaultTransformer();
077:
078: TransformerMap map = new TransformerMap();
079: map.putTransformer(TransformerMapTest.class, expected);
080: assertTrue(map.containsClass(TransformerMapTest.class));
081: map.clear();
082: assertFalse(map.containsClass(TransformerMapTest.class));
083: }
084:
085: /**
086: *
087: */
088: public void testClasses() {
089: NumberTransformer expected = new DefaultTransformer();
090: TransformerMap map = new TransformerMap();
091: map.putTransformer(TransformerMapTest.class, expected);
092: assertTrue(map.classes().contains(TransformerMapTest.class));
093: }
094:
095: /**
096: *
097: */
098: public void testTransformers() {
099: NumberTransformer expected = new DefaultTransformer();
100: TransformerMap map = new TransformerMap();
101: map.putTransformer(TransformerMapTest.class, expected);
102: assertTrue(map.transformers().contains(expected));
103: }
104: }
|