001: /*
002: * Copyright 2004 The Apache Software Foundation
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.apache.commons.collections.buffer;
017:
018: import java.util.Arrays;
019: import java.util.Collection;
020:
021: import junit.framework.Test;
022: import junit.framework.TestSuite;
023:
024: import org.apache.commons.collections.ArrayStack;
025: import org.apache.commons.collections.Buffer;
026: import org.apache.commons.collections.collection.AbstractTestCollection;
027:
028: /**
029: * Extension of {@link AbstractTestCollection} for exercising the
030: * {@link UnmodifiableBuffer} implementation.
031: *
032: * @since Commons Collections 3.1
033: * @version $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
034: *
035: * @author Phil Steitz
036: * @author Stephen Colebourne
037: */
038: public class TestUnmodifiableBuffer extends AbstractTestCollection {
039:
040: public TestUnmodifiableBuffer(String testName) {
041: super (testName);
042: }
043:
044: public static Test suite() {
045: return new TestSuite(TestUnmodifiableBuffer.class);
046: }
047:
048: public static void main(String args[]) {
049: String[] testCaseName = { TestUnmodifiableBuffer.class
050: .getName() };
051: junit.textui.TestRunner.main(testCaseName);
052: }
053:
054: //-----------------------------------------------------------------------
055: public Collection makeCollection() {
056: return UnmodifiableBuffer.decorate(new UnboundedFifoBuffer());
057: }
058:
059: public Collection makeFullCollection() {
060: Buffer buffer = new UnboundedFifoBuffer();
061: buffer.addAll(Arrays.asList(getFullElements()));
062: return UnmodifiableBuffer.decorate(buffer);
063: }
064:
065: public Collection makeConfirmedCollection() {
066: ArrayStack list = new ArrayStack();
067: return list;
068: }
069:
070: public Collection makeConfirmedFullCollection() {
071: ArrayStack list = new ArrayStack();
072: list.addAll(Arrays.asList(getFullElements()));
073: return list;
074: }
075:
076: public boolean isAddSupported() {
077: return false;
078: }
079:
080: public boolean isRemoveSupported() {
081: return false;
082: }
083:
084: public boolean isNullSupported() {
085: return false;
086: }
087:
088: public void testBufferRemove() {
089: resetEmpty();
090: Buffer buffer = (Buffer) collection;
091: try {
092: buffer.remove();
093: fail();
094: } catch (UnsupportedOperationException ex) {
095: }
096: }
097:
098: public String getCompatibilityVersion() {
099: return "3.1";
100: }
101:
102: // public void testCreate() throws Exception {
103: // resetEmpty();
104: // writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/UnmodifiableBuffer.emptyCollection.version3.1.obj");
105: // resetFull();
106: // writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/UnmodifiableBuffer.fullCollection.version3.1.obj");
107: // }
108:
109: }
|