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.ui.tests.harness.util;
11:
12: import junit.framework.Test;
13: import junit.framework.TestCase;
14: import junit.framework.TestResult;
15: import junit.framework.TestSuite;
16:
17: import org.eclipse.core.runtime.IExtensionPoint;
18: import org.eclipse.core.runtime.Platform;
19:
20: /**
21: * Tests to see if we're running with Tweaklets. If so, fail early so we don't
22: * waste an entire morning trying to figure out why all of the part tests are
23: * failing.
24: *
25: * @since 3.4
26: *
27: */
28: public class TweakletCheckTest extends TestCase {
29:
30: /**
31: *
32: */
33: public TweakletCheckTest() {
34: setName("test for tweaklets");
35: }
36:
37: /*
38: * (non-Javadoc)
39: *
40: * @see junit.framework.TestCase#run(junit.framework.TestResult)
41: */
42: public void run(TestResult result) {
43:
44: result.startTest(this );
45: try {
46: IExtensionPoint point = Platform.getExtensionRegistry()
47:
48: .getExtensionPoint("org.eclipse.ui.internalTweaklets");
49: boolean abort = point.getExtensions().length > 0;
50:
51: if (abort) {
52: Error error = new Error(
53: "Tweaklets present in test setup - all test results are now suspect. Please restart the tests with the tweaklet extensions removed.");
54: result.addError(this , error);
55: result.stop();
56: }
57: } finally {
58: result.endTest(this );
59: }
60:
61: }
62:
63: public static Test suite() {
64: TestSuite test = new TestSuite();
65: test.addTest(new TweakletCheckTest());
66: test.addTest(new TweakletCheckTest());
67: // should not run if there are tweaklets present - the first run should
68: // aggressively take down the framework.
69: return test;
70: }
71: }
|