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 junit.framework.Test;
19: import junit.framework.TestSuite;
20:
21: import org.apache.commons.collections.Bag;
22: import org.apache.commons.collections.bag.AbstractTestBag;
23: import org.apache.commons.collections.bag.HashBag;
24:
25: /**
26: * Extension of {@link TestBag} for exercising the
27: * {@link ObservableBag} implementation.
28: *
29: * @since Commons Events 1.0
30: * @version $Revision: 155443 $ $Date: 2005-02-26 06:19:51 -0700 (Sat, 26 Feb 2005) $
31: *
32: * @author Stephen Colebourne
33: */
34: public class TestObservableBag extends AbstractTestBag implements
35: ObservedTestHelper.ObservedFactory {
36:
37: public TestObservableBag(String testName) {
38: super (testName);
39: }
40:
41: public static Test suite() {
42: return new TestSuite(TestObservableBag.class);
43: }
44:
45: public static void main(String args[]) {
46: String[] testCaseName = { TestObservableBag.class.getName() };
47: junit.textui.TestRunner.main(testCaseName);
48: }
49:
50: //-----------------------------------------------------------------------
51: public Bag makeBag() {
52: return ObservableBag.decorate(new HashBag(),
53: ObservedTestHelper.LISTENER);
54: }
55:
56: //-----------------------------------------------------------------------
57: public void testObservedSet() {
58: ObservedTestHelper.bulkTestObservedBag(this );
59: }
60:
61: //-----------------------------------------------------------------------
62: public ObservableCollection createObservedCollection() {
63: return ObservableBag.decorate(new HashBag());
64: }
65:
66: public ObservableCollection createObservedCollection(Object listener) {
67: return ObservableBag.decorate(new HashBag(), listener);
68: }
69:
70: }
|