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.Collection; 021 022import junit.framework.Test; 023import junit.framework.TestSuite; 024 025import org.apache.commons.collections.AbstractTestObject; 026import org.apache.commons.collections.primitives.RandomAccessDoubleList; 027import org.apache.commons.collections.primitives.ArrayDoubleList; 028import org.apache.commons.collections.primitives.DoubleList; 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 TestDoubleCollectionCollection extends AbstractTestObject { 035 036 // conventional 037 // ------------------------------------------------------------------------ 038 039 public TestDoubleCollectionCollection(String testName) { 040 super(testName); 041 } 042 043 public static Test suite() { 044 return new TestSuite(TestDoubleCollectionCollection.class); 045 } 046 047 // collections testing framework 048 // ------------------------------------------------------------------------ 049 050 public Object makeObject() { 051 DoubleList list = new ArrayDoubleList(); 052 for(int i=0;i<10;i++) { 053 list.add((double)i); 054 } 055 return new DoubleCollectionCollection(list); 056 } 057 058 public void testSerializeDeserializeThenCompare() { 059 // Collection.equal contract doesn't work that way 060 } 061 062 /** @TODO need to add serialized form to cvs */ 063 public void testCanonicalEmptyCollectionExists() { 064 // XXX FIX ME XXX 065 // need to add a serialized form to cvs 066 } 067 068 public void testCanonicalFullCollectionExists() { 069 // XXX FIX ME XXX 070 // need to add a serialized form to cvs 071 } 072 073 // tests 074 // ------------------------------------------------------------------------ 075 076 public void testWrapNull() { 077 assertNull(DoubleCollectionCollection.wrap(null)); 078 } 079 080 public void testWrapSerializable() { 081 Collection collection = DoubleCollectionCollection.wrap(new ArrayDoubleList()); 082 assertNotNull(collection); 083 assertTrue(collection instanceof Serializable); 084 } 085 086 public void testWrapNonSerializable() { 087 Collection collection = DoubleCollectionCollection.wrap(new RandomAccessDoubleList() { 088 public double get(int i) { throw new IndexOutOfBoundsException(); } 089 public int size() { return 0; } 090 }); 091 assertNotNull(collection); 092 assertTrue(!(collection instanceof Serializable)); 093 } 094 095}