01: /*
02: * Copyright 2003-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.events.observable;
17:
18: import java.util.Arrays;
19: import java.util.Collection;
20: import java.util.List;
21:
22: import junit.framework.Test;
23: import junit.framework.TestSuite;
24:
25: import org.apache.commons.collections.ArrayStack;
26: import org.apache.commons.collections.collection.AbstractTestCollection;
27:
28: /**
29: * Extension of {@link TestCollection} for exercising the
30: * {@link ObservableBuffer} implementation.
31: *
32: * @since Commons Events 1.0
33: * @version $Revision: 155443 $ $Date: 2005-02-26 06:19:51 -0700 (Sat, 26 Feb 2005) $
34: *
35: * @author Stephen Colebourne
36: */
37: public class TestObservableBuffer extends AbstractTestCollection
38: implements ObservedTestHelper.ObservedFactory {
39:
40: public TestObservableBuffer(String testName) {
41: super (testName);
42: }
43:
44: public static Test suite() {
45: return new TestSuite(TestObservableBuffer.class);
46: }
47:
48: public static void main(String args[]) {
49: String[] testCaseName = { TestObservableBuffer.class.getName() };
50: junit.textui.TestRunner.main(testCaseName);
51: }
52:
53: //-----------------------------------------------------------------------
54: public Collection makeConfirmedCollection() {
55: return new ArrayStack();
56: }
57:
58: public Collection makeConfirmedFullCollection() {
59: ArrayStack stack = new ArrayStack();
60: stack.addAll(Arrays.asList(getFullElements()));
61: return stack;
62: }
63:
64: public Collection makeCollection() {
65: return ObservableBuffer.decorate(new ArrayStack(),
66: ObservedTestHelper.LISTENER);
67: }
68:
69: public Collection makeFullCollection() {
70: List stack = new ArrayStack();
71: stack.addAll(Arrays.asList(getFullElements()));
72: return ObservableBuffer.decorate(stack,
73: ObservedTestHelper.LISTENER);
74: }
75:
76: //-----------------------------------------------------------------------
77: public void testObservedBuffer() {
78: ObservedTestHelper.bulkTestObservedBuffer(this );
79: }
80:
81: //-----------------------------------------------------------------------
82: public ObservableCollection createObservedCollection() {
83: return ObservableBuffer.decorate(new ArrayStack());
84: }
85:
86: public ObservableCollection createObservedCollection(Object listener) {
87: return ObservableBuffer.decorate(new ArrayStack(), listener);
88: }
89:
90: }
|