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.ArrayList;
19: import java.util.Arrays;
20: import java.util.List;
21:
22: import junit.framework.Test;
23: import junit.framework.TestSuite;
24:
25: import org.apache.commons.collections.list.AbstractTestList;
26:
27: /**
28: * Extension of {@link TestList} for exercising the
29: * {@link ObservedList} implementation.
30: *
31: * @since Commons Events 1.0
32: * @version $Revision: 155443 $ $Date: 2005-02-26 06:19:51 -0700 (Sat, 26 Feb 2005) $
33: *
34: * @author Stephen Colebourne
35: */
36: public class TestObservableList extends AbstractTestList implements
37: ObservedTestHelper.ObservedFactory {
38:
39: public TestObservableList(String testName) {
40: super (testName);
41: }
42:
43: public static Test suite() {
44: return new TestSuite(TestObservableList.class);
45: }
46:
47: public static void main(String args[]) {
48: String[] testCaseName = { TestObservableList.class.getName() };
49: junit.textui.TestRunner.main(testCaseName);
50: }
51:
52: //-----------------------------------------------------------------------
53: public List makeEmptyList() {
54: return ObservableList.decorate(new ArrayList(),
55: ObservedTestHelper.LISTENER);
56: }
57:
58: public List makeFullList() {
59: List set = new ArrayList();
60: set.addAll(Arrays.asList(getFullElements()));
61: return ObservableList
62: .decorate(set, ObservedTestHelper.LISTENER);
63: }
64:
65: //-----------------------------------------------------------------------
66: public void testObservedList() {
67: ObservedTestHelper.bulkTestObservedList(this );
68: }
69:
70: //-----------------------------------------------------------------------
71: public ObservableCollection createObservedCollection() {
72: return ObservableList.decorate(new ArrayList());
73: }
74:
75: public ObservableCollection createObservedCollection(Object listener) {
76: return ObservableList.decorate(new ArrayList(), listener);
77: }
78:
79: }
|