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