KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > primitives > adapters > TestLongCollectionCollection


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.commons.collections.primitives.adapters;
18
19 import java.io.Serializable JavaDoc;
20 import java.util.Collection JavaDoc;
21
22 import junit.framework.Test;
23 import junit.framework.TestSuite;
24
25 import org.apache.commons.collections.AbstractTestObject;
26 import org.apache.commons.collections.primitives.RandomAccessLongList;
27 import org.apache.commons.collections.primitives.ArrayLongList;
28 import org.apache.commons.collections.primitives.LongList;
29
30 /**
31  * @version $Revision: 480451 $ $Date: 2006-11-28 23:45:08 -0800 (Tue, 28 Nov 2006) $
32  * @author Rodney Waldhoff
33  */

34 public class TestLongCollectionCollection extends AbstractTestObject {
35
36     // conventional
37
// ------------------------------------------------------------------------
38

39     public TestLongCollectionCollection(String JavaDoc testName) {
40         super(testName);
41     }
42
43     public static Test suite() {
44         return new TestSuite(TestLongCollectionCollection.class);
45     }
46
47     // collections testing framework
48
// ------------------------------------------------------------------------
49

50     public Object JavaDoc makeObject() {
51         LongList list = new ArrayLongList();
52         for(int i=0;i<10;i++) {
53             list.add(i);
54         }
55         return new LongCollectionCollection(list);
56     }
57
58     public void testSerializeDeserializeThenCompare() {
59         // Collection.equal contract doesn't work that way
60
}
61
62     /** @TODO need to add serialized form to cvs */
63     public void testCanonicalEmptyCollectionExists() {
64         // XXX FIX ME XXX
65
// need to add a serialized form to cvs
66
}
67
68     public void testCanonicalFullCollectionExists() {
69         // XXX FIX ME XXX
70
// need to add a serialized form to cvs
71
}
72     
73     // tests
74
// ------------------------------------------------------------------------
75

76     public void testWrapNull() {
77         assertNull(LongCollectionCollection.wrap(null));
78     }
79     
80     public void testWrapSerializable() {
81         Collection JavaDoc collection = LongCollectionCollection.wrap(new ArrayLongList());
82         assertNotNull(collection);
83         assertTrue(collection instanceof Serializable JavaDoc);
84     }
85     
86     public void testWrapNonSerializable() {
87         Collection JavaDoc collection = LongCollectionCollection.wrap(new RandomAccessLongList() {
88             public long get(int i) { throw new IndexOutOfBoundsException JavaDoc(); }
89             public int size() { return 0; }
90         });
91         assertNotNull(collection);
92         assertTrue(!(collection instanceof Serializable JavaDoc));
93     }
94
95 }
96
Popular Tags