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;
11:
12: import junit.framework.TestCase;
13:
14: import org.eclipse.core.databinding.observable.Realm;
15: import org.eclipse.jface.tests.databinding.RealmTester;
16: import org.eclipse.jface.tests.databinding.RealmTester.CurrentRealm;
17:
18: /**
19: * @since 3.2
20: */
21: public class RealmTest extends TestCase {
22: public void testSetDefaultWithRunnable() throws Exception {
23: Realm oldRealm = new CurrentRealm(true);
24: final Realm newRealm = new CurrentRealm(true);
25:
26: RealmTester.setDefault(oldRealm);
27: Realm.runWithDefault(newRealm, new Runnable() {
28: public void run() {
29: assertEquals("new realm should be default", newRealm,
30: Realm.getDefault());
31: }
32: });
33:
34: assertEquals("old realm should have been restored", oldRealm,
35: Realm.getDefault());
36: }
37: }
|