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.Collection;
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.RandomAccessByteList;
27 import org.apache.commons.collections.primitives.ArrayByteList;
28 import org.apache.commons.collections.primitives.ByteList;
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 TestByteCollectionCollection extends AbstractTestObject {
35
36 // conventional
37 // ------------------------------------------------------------------------
38
39 public TestByteCollectionCollection(String testName) {
40 super(testName);
41 }
42
43 public static Test suite() {
44 return new TestSuite(TestByteCollectionCollection.class);
45 }
46
47 // collections testing framework
48 // ------------------------------------------------------------------------
49
50 public Object makeObject() {
51 ByteList list = new ArrayByteList();
52 for(int i=0;i<10;i++) {
53 list.add((byte)i);
54 }
55 return new ByteCollectionCollection(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(ByteCollectionCollection.wrap(null));
78 }
79
80 public void testWrapSerializable() {
81 Collection collection = ByteCollectionCollection.wrap(new ArrayByteList());
82 assertNotNull(collection);
83 assertTrue(collection instanceof Serializable);
84 }
85
86 public void testWrapNonSerializable() {
87 Collection collection = ByteCollectionCollection.wrap(new RandomAccessByteList() {
88 public byte get(int i) { throw new IndexOutOfBoundsException(); }
89 public int size() { return 0; }
90 });
91 assertNotNull(collection);
92 assertTrue(!(collection instanceof Serializable));
93 }
94
95 }