Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCurtis Windatt2013-04-22 20:46:44 +0000
committerCurtis Windatt2013-04-22 20:46:44 +0000
commit73450d3d6e3c9093d2f6d9d64f972a967fef6a3e (patch)
tree9edcd1979ee790557592acfe389cb0beae8b8aa1
parentbc6ecd8814725cb315d8a4e9a21589fbb94d3194 (diff)
downloadeclipse.pde.ui-73450d3d6e3c9093d2f6d9d64f972a967fef6a3e.tar.gz
eclipse.pde.ui-73450d3d6e3c9093d2f6d9d64f972a967fef6a3e.tar.xz
eclipse.pde.ui-73450d3d6e3c9093d2f6d9d64f972a967fef6a3e.zip
Bug 406244 - org.eclipse.pde.junit.runtime has a required dependency onI20130423-0800
org.eclipse.ui now Change-Id: I169a68737ee91cad71bc5806e7e0cf7aeff005d2
-rw-r--r--ui/org.eclipse.pde.junit.runtime/META-INF/MANIFEST.MF1
-rw-r--r--ui/org.eclipse.pde.junit.runtime/src/org/eclipse/pde/internal/junit/runtime/PDEJUnitRuntimePlugin.java47
-rw-r--r--ui/org.eclipse.pde.junit.runtime/src/org/eclipse/pde/internal/junit/runtime/UITestApplication.java3
3 files changed, 39 insertions, 12 deletions
diff --git a/ui/org.eclipse.pde.junit.runtime/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.junit.runtime/META-INF/MANIFEST.MF
index de16a38047..fb1c87751f 100644
--- a/ui/org.eclipse.pde.junit.runtime/META-INF/MANIFEST.MF
+++ b/ui/org.eclipse.pde.junit.runtime/META-INF/MANIFEST.MF
@@ -13,3 +13,4 @@ Export-Package: org.eclipse.pde.internal.junit.runtime;x-internal:=true
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Bundle-Activator: org.eclipse.pde.internal.junit.runtime.PDEJUnitRuntimePlugin
Bundle-ActivationPolicy: lazy
+Import-Package: org.eclipse.ui.testing;resolution:=optional
diff --git a/ui/org.eclipse.pde.junit.runtime/src/org/eclipse/pde/internal/junit/runtime/PDEJUnitRuntimePlugin.java b/ui/org.eclipse.pde.junit.runtime/src/org/eclipse/pde/internal/junit/runtime/PDEJUnitRuntimePlugin.java
index e9967214d0..42795e26f3 100644
--- a/ui/org.eclipse.pde.junit.runtime/src/org/eclipse/pde/internal/junit/runtime/PDEJUnitRuntimePlugin.java
+++ b/ui/org.eclipse.pde.junit.runtime/src/org/eclipse/pde/internal/junit/runtime/PDEJUnitRuntimePlugin.java
@@ -10,18 +10,45 @@
*******************************************************************************/
package org.eclipse.pde.internal.junit.runtime;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.Workbench;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.testing.TestableObject;
+import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;
/**
- * The plug-in activator for the PDE JUnit Runtime plug-in
+ * The plug-in activator for the PDE JUnit Runtime plug-in.
+ * <p>
+ * The PDE JUnit runtime allows JUnit tests to be run with an OSGi runtime.
+ * It supports the following use cases:
+ * <pre>
+ * 1) Headless tests (no UI, no workbench)
+ * Runs NonUIThreadTestApplication with no testable object
+ *
+ * 2) e4 UI tests (e4 UI, no workbench)
+ * Runs NonUIThreadTestApplication with a testable object from e4 service
+ *
+ * 3) UI tests run in the non UI thread (UI, workbench)
+ * Runs NonUIThreadTestApplication with a testable object from e4 service or PlatformUI
+ *
+ * 4) UI tests run in the UI thread (UI, workbench)
+ * Runs UITestApplication with a testable object from e4 service or PlatformUI
+ *
+ * 5) Headless tests with no application (no UI, no workbench, no application)
+ * Runs directly with no application
+ *
+ * 6) Legacy UI test application (deprecated)
+ * Runs LegacyUITestApplication with an IPlatformRunnable
+ * </pre>
* @since 4.3
*/
-public class PDEJUnitRuntimePlugin extends AbstractUIPlugin {
+public class PDEJUnitRuntimePlugin implements BundleActivator {
+
+ /**
+ * The testable object is accessed via service and a string name to avoid depending on UI code. The
+ */
+ private static final String TESTABLE_OBJECT_SERVICE_NAME = "org.eclipse.ui.testing.TestableObject"; //$NON-NLS-1$
/**
* Default instance of the receiver
@@ -50,19 +77,20 @@ public class PDEJUnitRuntimePlugin extends AbstractUIPlugin {
}
/* (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
- super.start(context);
bundleContext = context;
}
+ /* (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
public void stop(BundleContext context) throws Exception {
if (testableTracker != null) {
testableTracker.close();
testableTracker = null;
}
- super.stop(context);
}
/**
@@ -75,17 +103,16 @@ public class PDEJUnitRuntimePlugin extends AbstractUIPlugin {
* over {@link Workbench#getWorkbenchTestable()} to avoid the
* tests having a dependency on the Workbench.
* </p>
- * @see PlatformUI#getTestableObject()
* @return TestableObject provided via service or <code>null</code>
*/
- public TestableObject getTestableObject() {
+ public Object getTestableObject() {
if (bundleContext == null)
return null;
if (testableTracker == null) {
- testableTracker = new ServiceTracker(bundleContext, TestableObject.class.getName(), null);
+ testableTracker = new ServiceTracker(bundleContext, TESTABLE_OBJECT_SERVICE_NAME, null);
testableTracker.open();
}
- return (TestableObject) testableTracker.getService();
+ return testableTracker.getService();
}
}
diff --git a/ui/org.eclipse.pde.junit.runtime/src/org/eclipse/pde/internal/junit/runtime/UITestApplication.java b/ui/org.eclipse.pde.junit.runtime/src/org/eclipse/pde/internal/junit/runtime/UITestApplication.java
index e20464ff92..8928d0dbbc 100644
--- a/ui/org.eclipse.pde.junit.runtime/src/org/eclipse/pde/internal/junit/runtime/UITestApplication.java
+++ b/ui/org.eclipse.pde.junit.runtime/src/org/eclipse/pde/internal/junit/runtime/UITestApplication.java
@@ -13,7 +13,6 @@ package org.eclipse.pde.internal.junit.runtime;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.testing.TestableObject;
/**
* A Workbench that runs a test suite specified in the
@@ -36,7 +35,7 @@ public class UITestApplication extends NonUIThreadTestApplication {
*/
protected Object runApp(Object app, IApplicationContext context, String[] args) throws Exception {
// Get the testable object from the service
- TestableObject testableObject = PDEJUnitRuntimePlugin.getDefault().getTestableObject();
+ Object testableObject = PDEJUnitRuntimePlugin.getDefault().getTestableObject();
// If the service doesn't return a testable object ask PlatformUI directly
// Unlike in NonUIThreadTestApplication if the platform dependency is not available we will fail here
if (testableObject == null) {

Back to the top