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;
20 import java.util.AbstractList;
21 import java.util.ArrayList;
22 import java.util.List;
23
24 import junit.framework.Test;
25 import junit.framework.TestSuite;
26
27 import org.apache.commons.collections.AbstractTestObject;
28 import org.apache.commons.collections.primitives.IntCollection;
29
30 /**
31 * @version $Revision: 480451 $ $Date: 2006-11-29 02:45:08 -0500 (Wed, 29 Nov 2006) $
32 * @author Rodney Waldhoff
33 */
34 public class TestCollectionIntCollection extends AbstractTestObject {
35
36 // conventional
37 // ------------------------------------------------------------------------
38
39 public TestCollectionIntCollection(String testName) {
40 super(testName);
41 }
42
43 public static Test suite() {
44 return new TestSuite(TestCollectionIntCollection.class);
45 }
46
47 // collections testing framework
48 // ------------------------------------------------------------------------
49
50 public Object makeObject() {
51 List list = new ArrayList();
52 for(int i=0;i<10;i++) {
53 list.add(new Integer(i));
54 }
55 return new CollectionIntCollection(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(CollectionIntCollection.wrap(null));
78 }
79
80 public void testWrapSerializable() {
81 IntCollection collection = CollectionIntCollection.wrap(new ArrayList());
82 assertNotNull(collection);
83 assertTrue(collection instanceof Serializable);
84 }
85
86 public void testWrapNonSerializable() {
87 IntCollection collection = CollectionIntCollection.wrap(new AbstractList() {
88 public Object get(int i) { throw new IndexOutOfBoundsException(); }
89 public int size() { return 0; }
90 });
91 assertNotNull(collection);
92 assertTrue(!(collection instanceof Serializable));
93 }
94
95 }