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.Set;
20: import java.util.SortedSet;
21: import java.util.TreeSet;
22:
23: import junit.framework.Test;
24:
25: import org.apache.commons.collections.BulkTest;
26: import org.apache.commons.collections.set.AbstractTestSortedSet;
27:
28: /**
29: * Extension of {@link TestSortedSet} for exercising the
30: * {@link ObservedSortedSet} 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 TestObservableSortedSet extends AbstractTestSortedSet
38: implements ObservedTestHelper.ObservedFactory {
39:
40: public TestObservableSortedSet(String testName) {
41: super (testName);
42: }
43:
44: public static Test suite() {
45: return BulkTest.makeSuite(TestObservableSortedSet.class);
46: }
47:
48: public static void main(String args[]) {
49: String[] testCaseName = { TestObservableSortedSet.class
50: .getName() };
51: junit.textui.TestRunner.main(testCaseName);
52: }
53:
54: //-----------------------------------------------------------------------
55: public Set makeEmptySet() {
56: return ObservableSortedSet.decorate(new TreeSet(),
57: ObservedTestHelper.LISTENER);
58: }
59:
60: public Set makeFullSet() {
61: SortedSet set = new TreeSet();
62: set.addAll(Arrays.asList(getFullElements()));
63: return ObservableSortedSet.decorate(set,
64: ObservedTestHelper.LISTENER);
65: }
66:
67: //-----------------------------------------------------------------------
68: public void testObservedSortedSet() {
69: ObservedTestHelper.bulkTestObservedSortedSet(this );
70: }
71:
72: //-----------------------------------------------------------------------
73: public ObservableCollection createObservedCollection() {
74: return ObservableSortedSet.decorate(new TreeSet());
75: }
76:
77: public ObservableCollection createObservedCollection(Object listener) {
78: return ObservableSortedSet.decorate(new TreeSet(), listener);
79: }
80:
81: }
|