01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation 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: * IBM Corporation - initial API and implementation
10: ******************************************************************************/package org.eclipse.jface.tests.databinding;
11:
12: import java.util.Locale;
13:
14: import org.eclipse.core.databinding.util.ILogger;
15: import org.eclipse.core.databinding.util.Policy;
16: import org.eclipse.core.runtime.IStatus;
17:
18: import junit.extensions.TestSetup;
19: import junit.framework.Test;
20:
21: /**
22: * @since 3.2
23: *
24: */
25: public class BindingTestSetup extends TestSetup {
26:
27: private Locale oldLocale;
28: private ILogger oldLogger;
29: private org.eclipse.jface.util.ILogger oldJFaceLogger;
30:
31: public BindingTestSetup(Test test) {
32: super (test);
33: }
34:
35: protected void setUp() throws Exception {
36: super .setUp();
37: oldLocale = Locale.getDefault();
38: Locale.setDefault(Locale.US);
39: oldLogger = Policy.getLog();
40: Policy.setLog(new ILogger() {
41: public void log(IStatus status) {
42: // we are not expecting anything in the log while we test.
43: if (status.getException() != null) {
44: throw new RuntimeException(status.getException());
45: }
46: fail();
47: }
48: });
49: oldJFaceLogger = org.eclipse.jface.util.Policy.getLog();
50: org.eclipse.jface.util.Policy
51: .setLog(new org.eclipse.jface.util.ILogger() {
52: public void log(IStatus status) {
53: // we are not expecting anything in the log while we test.
54: if (status.getException() != null) {
55: throw new RuntimeException(status
56: .getException());
57: }
58: fail();
59: }
60: });
61: }
62:
63: protected void tearDown() throws Exception {
64: Locale.setDefault(oldLocale);
65: Policy.setLog(oldLogger);
66: org.eclipse.jface.util.Policy.setLog(oldJFaceLogger);
67: super.tearDown();
68: }
69: }
|