KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > buffer > TestUnmodifiableBuffer


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

16 package org.apache.commons.collections.buffer;
17
18 import java.util.Arrays JavaDoc;
19 import java.util.Collection JavaDoc;
20
21 import junit.framework.Test;
22 import junit.framework.TestSuite;
23
24 import org.apache.commons.collections.ArrayStack;
25 import org.apache.commons.collections.Buffer;
26 import org.apache.commons.collections.collection.AbstractTestCollection;
27
28 /**
29  * Extension of {@link AbstractTestCollection} for exercising the
30  * {@link UnmodifiableBuffer} implementation.
31  *
32  * @since Commons Collections 3.1
33  * @version $Revision: 1.1 $ $Date: 2004/06/02 22:05:54 $
34  *
35  * @author Phil Steitz
36  * @author Stephen Colebourne
37  */

38 public class TestUnmodifiableBuffer extends AbstractTestCollection {
39     
40     public TestUnmodifiableBuffer(String JavaDoc testName) {
41         super(testName);
42     }
43     
44     public static Test suite() {
45         return new TestSuite(TestUnmodifiableBuffer.class);
46     }
47     
48     public static void main(String JavaDoc args[]) {
49         String JavaDoc[] testCaseName = { TestUnmodifiableBuffer.class.getName()};
50         junit.textui.TestRunner.main(testCaseName);
51     }
52
53     //-----------------------------------------------------------------------
54
public Collection JavaDoc makeCollection() {
55         return UnmodifiableBuffer.decorate(new UnboundedFifoBuffer());
56     }
57     
58     public Collection JavaDoc makeFullCollection() {
59         Buffer buffer = new UnboundedFifoBuffer();
60         buffer.addAll(Arrays.asList(getFullElements()));
61         return UnmodifiableBuffer.decorate(buffer);
62     }
63     
64     public Collection JavaDoc makeConfirmedCollection() {
65         ArrayStack list = new ArrayStack();
66         return list;
67     }
68
69     public Collection JavaDoc makeConfirmedFullCollection() {
70         ArrayStack list = new ArrayStack();
71         list.addAll(Arrays.asList(getFullElements()));
72         return list;
73     }
74
75     public boolean isAddSupported() {
76         return false;
77     }
78     
79     public boolean isRemoveSupported() {
80         return false;
81     }
82     
83     public boolean isNullSupported() {
84         return false;
85     }
86     
87     public void testBufferRemove() {
88         resetEmpty();
89         Buffer buffer = (Buffer) collection;
90         try {
91             buffer.remove();
92             fail();
93         } catch (UnsupportedOperationException JavaDoc ex) {}
94     }
95
96     public String JavaDoc getCompatibilityVersion() {
97         return "3.1";
98     }
99
100 // public void testCreate() throws Exception {
101
// resetEmpty();
102
// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/UnmodifiableBuffer.emptyCollection.version3.1.obj");
103
// resetFull();
104
// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/UnmodifiableBuffer.fullCollection.version3.1.obj");
105
// }
106

107 }
108
Popular Tags