001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.collections.primitives.adapters;
018
019import java.io.Serializable;
020import java.util.AbstractList;
021import java.util.ArrayList;
022
023import junit.framework.Test;
024import junit.framework.TestSuite;
025
026import org.apache.commons.collections.BulkTest;
027import org.apache.commons.collections.primitives.IntList;
028import org.apache.commons.collections.primitives.TestIntList;
029
030/**
031 * @version $Revision: 480451 $ $Date: 2006-11-29 02:45:08 -0500 (Wed, 29 Nov 2006) $
032 * @author Rodney Waldhoff
033 */
034public class TestListIntList extends TestIntList {
035
036    // conventional
037    // ------------------------------------------------------------------------
038
039    public TestListIntList(String testName) {
040        super(testName);
041    }
042
043    public static Test suite() {
044        TestSuite suite = BulkTest.makeSuite(TestListIntList.class);
045        return suite;
046    }
047
048    // collections testing framework
049    // ------------------------------------------------------------------------
050
051    /**
052     * @see org.apache.commons.collections.primitives.TestIntList#makeEmptyIntList()
053     */
054    protected IntList makeEmptyIntList() {
055        return new ListIntList(new ArrayList());
056    }
057    
058    public String[] ignoredTests() {
059        // sublists are not serializable
060        return new String[] { 
061            "TestListIntList.bulkTestSubList.testFullListSerialization",
062            "TestListIntList.bulkTestSubList.testEmptyListSerialization",
063            "TestListIntList.bulkTestSubList.testCanonicalEmptyCollectionExists",
064            "TestListIntList.bulkTestSubList.testCanonicalFullCollectionExists",
065            "TestListIntList.bulkTestSubList.testEmptyListCompatibility",
066            "TestListIntList.bulkTestSubList.testFullListCompatibility",
067            "TestListIntList.bulkTestSubList.testSerializeDeserializeThenCompare",
068            "TestListIntList.bulkTestSubList.testSimpleSerialization"
069        };
070    }
071
072    // tests
073    // ------------------------------------------------------------------------
074
075    /** @TODO need to add serialized form to cvs */
076    public void testCanonicalEmptyCollectionExists() {
077        // XXX FIX ME XXX
078        // need to add a serialized form to cvs
079    }
080
081    public void testCanonicalFullCollectionExists() {
082        // XXX FIX ME XXX
083        // need to add a serialized form to cvs
084    }
085
086    public void testEmptyListCompatibility() {
087        // XXX FIX ME XXX
088        // need to add a serialized form to cvs
089    }
090
091    public void testFullListCompatibility() {
092        // XXX FIX ME XXX
093        // need to add a serialized form to cvs
094    }
095    public void testWrapNull() {
096        assertNull(ListIntList.wrap(null));
097    }
098    
099    public void testWrapSerializable() {
100        IntList list = ListIntList.wrap(new ArrayList());
101        assertNotNull(list);
102        assertTrue(list instanceof Serializable);
103    }
104    
105    public void testWrapNonSerializable() {
106        IntList list = ListIntList.wrap(new AbstractList() { 
107            public Object get(int i) { throw new IndexOutOfBoundsException(); } 
108            public int size() { return 0; } 
109        });
110        assertNotNull(list);
111        assertTrue(!(list instanceof Serializable));
112    }
113
114}