KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > TestTreeMap


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 package org.apache.commons.collections;
17
18 import java.util.TreeMap JavaDoc;
19
20 import org.apache.commons.collections.map.AbstractTestMap;
21
22 /**
23  * Tests TreeMap.
24  *
25  * @version $Revision: 1.13 $ $Date: 2004/02/18 01:20:35 $
26  *
27  * @author Jason van Zyl
28  */

29 public abstract class TestTreeMap extends AbstractTestMap {
30     
31     public TestTreeMap(String JavaDoc testName) {
32         super(testName);
33     }
34
35     public static void main(String JavaDoc args[]) {
36         String JavaDoc[] testCaseName = { TestTreeMap.class.getName()};
37         junit.textui.TestRunner.main(testCaseName);
38     }
39
40     public boolean isAllowNullKey() {
41         return false;
42     }
43
44     protected TreeMap JavaDoc map = null;
45
46     public void setUp() {
47         map = (TreeMap JavaDoc) makeEmptyMap();
48     }
49
50     public void testNewMap() {
51         assertTrue("New map is empty", map.isEmpty());
52         assertEquals("New map has size zero", map.size(), 0);
53     }
54
55     public void testSearch() {
56         map.put("first", "First Item");
57         map.put("second", "Second Item");
58         assertEquals("Top item is 'Second Item'", map.get("first"), "First Item");
59         assertEquals("Next Item is 'First Item'", map.get("second"), "Second Item");
60     }
61 }
62
Popular Tags