/*
 *  Copyright 2003-2004 The Apache Software Foundation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.apache.commons.collections.map;

import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

import junit.framework.Test;

import org.apache.commons.collections.BulkTest;

/**
 * Extension of {@link TestSortedMap} for exercising the {@link FixedSizeSortedMap}
 * implementation.
 *
 * @since Commons Collections 3.0
 * @version $Revision: 1.6 $ $Date: 2004/04/02 23:12:34 $
 * 
 * @author Stephen Colebourne
 */
public class TestFixedSizeSortedMap extends AbstractTestSortedMap {

    public TestFixedSizeSortedMap(String testName) {
        super(testName);
    }

    public static Test suite() {
        return BulkTest.makeSuite(TestFixedSizeSortedMap.class);
    }

    public static void main(String args[]) {
        String[] testCaseName = { TestFixedSizeSortedMap.class.getName()};
        junit.textui.TestRunner.main(testCaseName);
    }

    public Map makeEmptyMap() {
        return FixedSizeSortedMap.decorate(new TreeMap());
    }

    public Map makeFullMap() {
        SortedMap map = new TreeMap();
        addSampleMappings(map);
        return FixedSizeSortedMap.decorate(map);
    }
    
    public boolean isPutAddSupported() {
        return false;
    }

    public boolean isRemoveSupported() {
        return false;
    }

    public String getCompatibilityVersion() {
        return "3.1";
    }
    
    public String[] ignoredTests() {
        // TreeMap has a bug (it doesn't deserialize SubMaps properly), thus ignore...
        return new String [] {
            "TestFixedSizeSortedMap.bulkTestHeadMap.testEmptyMapCompatibility",
            "TestFixedSizeSortedMap.bulkTestHeadMap.testFullMapCompatibility",
            "TestFixedSizeSortedMap.bulkTestHeadMap.testSerializeDeserializeThenCompare",
            "TestFixedSizeSortedMap.bulkTestTailMap.testEmptyMapCompatibility",
            "TestFixedSizeSortedMap.bulkTestTailMap.testFullMapCompatibility",
            "TestFixedSizeSortedMap.bulkTestTailMap.testSerializeDeserializeThenCompare",
            "TestFixedSizeSortedMap.bulkTestSubMap.testEmptyMapCompatibility",
            "TestFixedSizeSortedMap.bulkTestSubMap.testFullMapCompatibility",
            "TestFixedSizeSortedMap.bulkTestSubMap.testSerializeDeserializeThenCompare",
        };
    }

//    public void testCreate() throws Exception {
//        resetEmpty();
//        writeExternalFormToDisk(
//            (java.io.Serializable) map,
//            "D:/dev/collections/data/test/FixedSizeSortedMap.emptyCollection.version3.1.obj");
//        resetFull();
//        writeExternalFormToDisk(
//            (java.io.Serializable) map,
//            "D:/dev/collections/data/test/FixedSizeSortedMap.fullCollection.version3.1.obj");
//    }
}

@@ -996,9 +996,9 @@
 : 1.
-6
+7
  $ $
@@ -1016,18 +1016,18 @@
 04/0
-2 23:12:34
+9 09:40:15
  $%0A 
@@ -1493,32 +1493,110 @@
 seName);%0A    %7D%0A%0A
+    //-----------------------------------------------------------------------%0A
     public Map m
@@ -1864,172 +1864,99 @@
 n is
-PutAddSupported() %7B%0A        return false;%0A    %7D%0A%0A    public boolean isRemoveSupported() %7B%0A        return false;%0A    %7D%0A%0A    public String getCompatibilityVersion() %7B
+SubMapViewsSerializable() %7B%0A        // TreeMap sub map views have a bug in deserialization.
 %0A   
@@ -1971,21 +1971,21 @@
 urn 
-%223.1%22
+false
 ;%0A    %7D%0A
     
@@ -1972,36 +1972,32 @@
 rn false;%0A    %7D%0A
-    
 %0A    public Stri
@@ -1996,913 +1996,293 @@
 lic 
-String%5B%5D ignoredTests() %7B%0A        // TreeMap has a bug (it doesn't deserialize SubMaps properly), thus ignore...%0A        return new String %5B%5D %7B%0A            %22TestFixedSizeSortedMap.bulkTestHeadMap.testEmptyMapCompatibility%22,%0A            %22TestFixedSizeSortedMap.bulkTestHeadMap.testFullMapCompatibility%22,%0A            %22TestFixedSizeSortedMap.bulkTestHeadMap.testSerializeDeserializeThenCompare%22,%0A            %22TestFixedSizeSortedMap.bulkTestTailMap.testEmptyMapCompatibility%22,%0A            %22TestFixedSizeSortedMap.bulkTestTailMap.testFullMapCompatibility%22,
+boolean isPutAddSupported() %7B%0A        return false;%0A    %7D%0A%0A    public boolean isRemoveSupported() %7B%0A        return false;
 %0A    
+%7D%0A%0A
     
-    %22TestFixedSizeSortedMap.bulkTestTailMap.testSerializeDeserializeThenCompare%22,%0A            %22TestFixedSizeSortedMap.bulkTestSubMap.testEmptyMapCompatibility%22,%0A            %22TestFixedSizeSortedMap.bulkTestSubMap.testFullMapCompatibility%22,%0A            %22TestFixedSizeSortedMap.bulkTestSubMap.testSerializeDeserializeThenCompare%22,%0A   
+//-----------------------------------------------------------------------%0A    public String getCompatibilityVersion() %7B%0A        return %223.1%22;%0A
     
- %7D;
+%7D
 %0A    
-%7D%0A
 %0A// 

Use support to work around bug in TreeMap sub map deserialization