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: package org.apache.commons.collections.map;
017:
018: import java.util.HashMap;
019: import java.util.Map;
020:
021: import junit.framework.Test;
022: import junit.framework.TestSuite;
023:
024: import org.apache.commons.collections.OrderedMap;
025: import org.apache.commons.collections.Unmodifiable;
026:
027: /**
028: * Extension of {@link AbstractTestOrderedMap} for exercising the
029: * {@link UnmodifiableOrderedMap} implementation.
030: *
031: * @since Commons Collections 3.0
032: * @version $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
033: *
034: * @author Stephen Colebourne
035: */
036: public class TestUnmodifiableOrderedMap extends AbstractTestOrderedMap {
037:
038: public TestUnmodifiableOrderedMap(String testName) {
039: super (testName);
040: }
041:
042: public static Test suite() {
043: return new TestSuite(TestUnmodifiableOrderedMap.class);
044: }
045:
046: public static void main(String args[]) {
047: String[] testCaseName = { TestUnmodifiableOrderedMap.class
048: .getName() };
049: junit.textui.TestRunner.main(testCaseName);
050: }
051:
052: //-------------------------------------------------------------------
053:
054: public Map makeEmptyMap() {
055: return UnmodifiableOrderedMap.decorate(ListOrderedMap
056: .decorate(new HashMap()));
057: }
058:
059: public boolean isPutChangeSupported() {
060: return false;
061: }
062:
063: public boolean isPutAddSupported() {
064: return false;
065: }
066:
067: public boolean isRemoveSupported() {
068: return false;
069: }
070:
071: public Map makeFullMap() {
072: OrderedMap m = ListOrderedMap.decorate(new HashMap());
073: addSampleMappings(m);
074: return UnmodifiableOrderedMap.decorate(m);
075: }
076:
077: //-----------------------------------------------------------------------
078: public void testUnmodifiable() {
079: assertTrue(makeEmptyMap() instanceof Unmodifiable);
080: assertTrue(makeFullMap() instanceof Unmodifiable);
081: }
082:
083: public void testDecorateFactory() {
084: Map map = makeFullMap();
085: assertSame(map, UnmodifiableOrderedMap
086: .decorate((OrderedMap) map));
087:
088: try {
089: UnmodifiableOrderedMap.decorate(null);
090: fail();
091: } catch (IllegalArgumentException ex) {
092: }
093: }
094:
095: public String getCompatibilityVersion() {
096: return "3.1";
097: }
098:
099: // public void testCreate() throws Exception {
100: // resetEmpty();
101: // writeExternalFormToDisk(
102: // (java.io.Serializable) map,
103: // "D:/dev/collections/data/test/UnmodifiableOrderedMap.emptyCollection.version3.1.obj");
104: // resetFull();
105: // writeExternalFormToDisk(
106: // (java.io.Serializable) map,
107: // "D:/dev/collections/data/test/UnmodifiableOrderedMap.fullCollection.version3.1.obj");
108: // }
109: }
|