KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > map > TestUnmodifiableOrderedMap


1 /*
2  * Copyright 2003-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.map;
17
18 import java.util.HashMap JavaDoc;
19 import java.util.Map JavaDoc;
20
21 import junit.framework.Test;
22 import junit.framework.TestSuite;
23
24 import org.apache.commons.collections.OrderedMap;
25 import org.apache.commons.collections.Unmodifiable;
26
27 /**
28  * Extension of {@link AbstractTestOrderedMap} for exercising the
29  * {@link UnmodifiableOrderedMap} implementation.
30  *
31  * @since Commons Collections 3.0
32  * @version $Revision: 1.5 $ $Date: 2004/04/09 10:46:32 $
33  *
34  * @author Stephen Colebourne
35  */

36 public class TestUnmodifiableOrderedMap extends AbstractTestOrderedMap {
37     
38     public TestUnmodifiableOrderedMap(String JavaDoc testName) {
39         super(testName);
40     }
41     
42     public static Test suite() {
43         return new TestSuite(TestUnmodifiableOrderedMap.class);
44     }
45     
46     public static void main(String JavaDoc args[]) {
47         String JavaDoc[] testCaseName = { TestUnmodifiableOrderedMap.class.getName()};
48         junit.textui.TestRunner.main(testCaseName);
49     }
50     
51     //-------------------------------------------------------------------
52

53     public Map JavaDoc makeEmptyMap() {
54         return UnmodifiableOrderedMap.decorate(ListOrderedMap.decorate(new HashMap JavaDoc()));
55     }
56     
57     public boolean isPutChangeSupported() {
58         return false;
59     }
60     
61     public boolean isPutAddSupported() {
62         return false;
63     }
64     
65     public boolean isRemoveSupported() {
66         return false;
67     }
68     
69     public Map JavaDoc makeFullMap() {
70         OrderedMap m = ListOrderedMap.decorate(new HashMap JavaDoc());
71         addSampleMappings(m);
72         return UnmodifiableOrderedMap.decorate(m);
73     }
74     
75     //-----------------------------------------------------------------------
76
public void testUnmodifiable() {
77         assertTrue(makeEmptyMap() instanceof Unmodifiable);
78         assertTrue(makeFullMap() instanceof Unmodifiable);
79     }
80     
81     public void testDecorateFactory() {
82         Map JavaDoc map = makeFullMap();
83         assertSame(map, UnmodifiableOrderedMap.decorate((OrderedMap) map));
84         
85         try {
86             UnmodifiableOrderedMap.decorate(null);
87             fail();
88         } catch (IllegalArgumentException JavaDoc ex) {}
89     }
90
91     public String JavaDoc getCompatibilityVersion() {
92         return "3.1";
93     }
94
95 // public void testCreate() throws Exception {
96
// resetEmpty();
97
// writeExternalFormToDisk(
98
// (java.io.Serializable) map,
99
// "D:/dev/collections/data/test/UnmodifiableOrderedMap.emptyCollection.version3.1.obj");
100
// resetFull();
101
// writeExternalFormToDisk(
102
// (java.io.Serializable) map,
103
// "D:/dev/collections/data/test/UnmodifiableOrderedMap.fullCollection.version3.1.obj");
104
// }
105
}
Popular Tags