KickJava   Java API By Example, From Geeks To Geeks.

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


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.AbstractList JavaDoc;
21 import java.util.ArrayList JavaDoc;
22 import java.util.List JavaDoc;
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.ByteCollection;
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 TestCollectionByteCollection extends AbstractTestObject {
35
36     // conventional
37
// ------------------------------------------------------------------------
38

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

50     public Object JavaDoc makeObject() {
51         List JavaDoc list = new ArrayList JavaDoc();
52         for(int i=0;i<10;i++) {
53             list.add(new Byte JavaDoc((byte)i));
54         }
55         return new CollectionByteCollection(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(CollectionByteCollection.wrap(null));
78     }
79     
80     public void testWrapSerializable() {
81         ByteCollection collection = CollectionByteCollection.wrap(new ArrayList JavaDoc());
82         assertNotNull(collection);
83         assertTrue(collection instanceof Serializable JavaDoc);
84     }
85     
86     public void testWrapNonSerializable() {
87         ByteCollection collection = CollectionByteCollection.wrap(new AbstractList JavaDoc() {
88             public Object JavaDoc 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