KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > testing > TestableObject


1 /*******************************************************************************
2  * Copyright (c) 2003, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.testing;
13
14 import org.eclipse.core.runtime.Assert;
15
16 /**
17  * A testable object.
18  * Allows a test harness to register itself with a testable object.
19  * The test harness is notified of test-related lifecycle events,
20  * such as when is an appropriate time to run tests on the object.
21  * This also provides API for running tests as a runnable, and for signaling
22  * when the tests are starting and when they are finished.
23  * <p>
24  * The workbench provides an implementation of this facade, available
25  * via <code>PlatformUI.getTestableObject()</code>.
26  * </p>
27  *
28  * @since 3.0
29  */

30 public class TestableObject {
31
32     private ITestHarness testHarness;
33
34     /**
35      * Returns the test harness, or <code>null</code> if it has not yet been set.
36      *
37      * @return the test harness or <code>null</code>
38      */

39     public ITestHarness getTestHarness() {
40         return testHarness;
41     }
42
43     /**
44      * Sets the test harness.
45      *
46      * @param testHarness the test harness
47      */

48     public void setTestHarness(ITestHarness testHarness) {
49         Assert.isNotNull(testHarness);
50         this.testHarness = testHarness;
51     }
52
53     /**
54      * Runs the given test runnable.
55      * The default implementation simply invokes <code>run</code> on the
56      * given test runnable. Subclasses may extend.
57      *
58      * @param testRunnable the test runnable to run
59      */

60     public void runTest(Runnable JavaDoc testRunnable) {
61         testRunnable.run();
62     }
63
64     /**
65      * Notification from the test harness that it is starting to run
66      * the tests.
67      * The default implementation does nothing.
68      * Subclasses may override.
69      */

70     public void testingStarting() {
71         // do nothing
72
}
73
74     /**
75      * Notification from the test harness that it has finished running the
76      * tests.
77      * The default implementation does nothing.
78      * Subclasses may override.
79      */

80     public void testingFinished() {
81         // do nothing
82
}
83 }
84
Popular Tags