01: /*
02: * Copyright 2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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;
19: import java.util.Collection;
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 SynchronizedBuffer} implementation.
31: *
32: * @since Commons Collections 3.1
33: * @version $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
34: *
35: * @author Phil Steitz
36: * @author Stephen Colebourne
37: */
38: public class TestSynchronizedBuffer extends AbstractTestCollection {
39:
40: public TestSynchronizedBuffer(String testName) {
41: super (testName);
42: }
43:
44: public static Test suite() {
45: return new TestSuite(TestSynchronizedBuffer.class);
46: }
47:
48: public static void main(String args[]) {
49: String[] testCaseName = { TestSynchronizedBuffer.class
50: .getName() };
51: junit.textui.TestRunner.main(testCaseName);
52: }
53:
54: //-----------------------------------------------------------------------
55: public Collection makeCollection() {
56: return SynchronizedBuffer.decorate(new UnboundedFifoBuffer());
57: }
58:
59: public Collection makeFullCollection() {
60: Buffer buffer = new UnboundedFifoBuffer();
61: buffer.addAll(Arrays.asList(getFullElements()));
62: return SynchronizedBuffer.decorate(buffer);
63: }
64:
65: public Collection makeConfirmedCollection() {
66: ArrayStack list = new ArrayStack();
67: return list;
68: }
69:
70: public Collection makeConfirmedFullCollection() {
71: ArrayStack list = new ArrayStack();
72: list.addAll(Arrays.asList(getFullElements()));
73: return list;
74: }
75:
76: public boolean isNullSupported() {
77: return false;
78: }
79:
80: public String getCompatibilityVersion() {
81: return "3.1";
82: }
83:
84: // public void testCreate() throws Exception {
85: // resetEmpty();
86: // writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/SynchronizedBuffer.emptyCollection.version3.1.obj");
87: // resetFull();
88: // writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/SynchronizedBuffer.fullCollection.version3.1.obj");
89: // }
90:
91: }
|