01: /*******************************************************************************
02: * Copyright (c) 2006 Brad Reynolds and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Brad Reynolds - initial API and implementation
10: ******************************************************************************/package org.eclipse.core.tests.databinding.observable.map;
11:
12: import java.util.Set;
13:
14: import junit.framework.TestCase;
15:
16: import org.eclipse.core.databinding.observable.map.AbstractObservableMap;
17: import org.eclipse.core.databinding.observable.map.MapDiff;
18: import org.eclipse.jface.tests.databinding.RealmTester;
19: import org.eclipse.jface.tests.databinding.RealmTester.CurrentRealm;
20:
21: /**
22: * @since 3.2
23: */
24: public class AbstractObservableMapTest extends TestCase {
25: private AbstractObservableMapStub map;
26:
27: protected void setUp() throws Exception {
28: RealmTester.setDefault(new CurrentRealm(true));
29: map = new AbstractObservableMapStub();
30: }
31:
32: protected void tearDown() throws Exception {
33: RealmTester.setDefault(null);
34: }
35:
36: public void testIsStaleRealmChecks() throws Exception {
37: RealmTester.exerciseCurrent(new Runnable() {
38: public void run() {
39: map.isStale();
40: }
41: });
42: }
43:
44: public void testSetStaleRealmChecks() throws Exception {
45: RealmTester.exerciseCurrent(new Runnable() {
46: public void run() {
47: map.setStale(true);
48: }
49: });
50: }
51:
52: public void testFireStaleRealmChecks() throws Exception {
53: RealmTester.exerciseCurrent(new Runnable() {
54: public void run() {
55: map.fireStale();
56: }
57: });
58: }
59:
60: public void testFireChangeRealmChecks() throws Exception {
61: RealmTester.exerciseCurrent(new Runnable() {
62: public void run() {
63: map.fireChange();
64: }
65: });
66: }
67:
68: public void testFireMapChangeRealmChecks() throws Exception {
69: RealmTester.exerciseCurrent(new Runnable() {
70: public void run() {
71: map.fireMapChange(null);
72: }
73: });
74: }
75:
76: static class AbstractObservableMapStub extends
77: AbstractObservableMap {
78: public Set entrySet() {
79: return null;
80: }
81:
82: protected void fireChange() {
83: super .fireChange();
84: }
85:
86: protected void fireMapChange(MapDiff diff) {
87: super .fireMapChange(diff);
88: }
89:
90: protected void fireStale() {
91: super.fireStale();
92: }
93: }
94: }
|