Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 175843 Details for
Bug 311979
Validate/Add Required on junit plug-in launch does not consider both 'application' and 'app to test'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch for pde.junit.runtime
headless-ui-testing.patch (text/plain), 8.93 KB, created by
Gunnar Wagenknecht
on 2010-08-04 11:45:16 EDT
(
hide
)
Description:
Patch for pde.junit.runtime
Filename:
MIME Type:
Creator:
Gunnar Wagenknecht
Created:
2010-08-04 11:45:16 EDT
Size:
8.93 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.junit.runtime >Index: src/org/eclipse/pde/internal/junit/runtime/NonUIThreadTestApplication.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.junit.runtime/src/org/eclipse/pde/internal/junit/runtime/NonUIThreadTestApplication.java,v >retrieving revision 1.1 >diff -u -r1.1 NonUIThreadTestApplication.java >--- src/org/eclipse/pde/internal/junit/runtime/NonUIThreadTestApplication.java 8 Jan 2009 16:49:40 -0000 1.1 >+++ src/org/eclipse/pde/internal/junit/runtime/NonUIThreadTestApplication.java 4 Aug 2010 15:43:15 -0000 >@@ -10,18 +10,97 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.junit.runtime; > >-import org.eclipse.core.runtime.Platform; >+import junit.framework.Assert; >+import org.eclipse.core.runtime.*; >+import org.eclipse.equinox.app.IApplication; >+import org.eclipse.equinox.app.IApplicationContext; > > /** > * A Workbench that runs a test suite specified in the > * command line arguments. > */ >-public class NonUIThreadTestApplication extends UITestApplication { >+public class NonUIThreadTestApplication implements IApplication { > >- public void runTests() { >- fTestableObject.testingStarting(); >- RemotePluginTestRunner.main(Platform.getCommandLineArgs()); >- fTestableObject.testingFinished(); >+ private static final String DEFAULT_HEADLESSAPP = "org.eclipse.pde.junit.runtime.coretestapplication"; //$NON-NLS-1$ >+ >+ protected IApplication fApplication; >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) >+ */ >+ public Object start(IApplicationContext context) throws Exception { >+ String[] args = (String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS); >+ Object app = getApplication(args); >+ >+ Assert.assertNotNull(app); >+ >+ return runApp(app, context, args); >+ } >+ >+ protected Object runApp(Object app, IApplicationContext context, String[] args) throws Exception { >+ if (app instanceof IApplication) { >+ fApplication = (IApplication) app; >+ return fApplication.start(context); >+ } >+ return ((IPlatformRunnable) app).run(args); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.equinox.app.IApplication#stop() >+ */ >+ public void stop() { >+ if (fApplication != null) >+ fApplication.stop(); >+ } >+ >+ /* >+ * return the application to run, or null if not even the default application >+ * is found. >+ */ >+ private Object getApplication(String[] args) throws CoreException { >+ // Find the name of the application as specified by the PDE JUnit launcher. >+ // If no application is specified, the 3.0 default workbench application >+ // is returned. >+ IExtension extension = Platform.getExtensionRegistry().getExtension(Platform.PI_RUNTIME, Platform.PT_APPLICATIONS, getApplicationToRun(args)); >+ >+ Assert.assertNotNull(extension); >+ >+ // If the extension does not have the correct grammar, return null. >+ // Otherwise, return the application object. >+ IConfigurationElement[] elements = extension.getConfigurationElements(); >+ if (elements.length > 0) { >+ IConfigurationElement[] runs = elements[0].getChildren("run"); //$NON-NLS-1$ >+ if (runs.length > 0) { >+ Object runnable = runs[0].createExecutableExtension("class"); //$NON-NLS-1$ >+ if (runnable instanceof IPlatformRunnable || runnable instanceof IApplication) >+ return runnable; >+ } >+ } >+ return null; >+ } >+ >+ /* >+ * The -testApplication argument specifies the application to be run. >+ * If the PDE JUnit launcher did not set this argument, then return >+ * the name of the default application. >+ * In 3.0, the default is the "org.eclipse.ui.ide.worbench" application. >+ * >+ * see bug 228044 >+ * >+ */ >+ private String getApplicationToRun(String[] args) { >+ for (int i = 0; i < args.length; i++) { >+ if (args[i].equals("-testApplication") && i < args.length - 1) //$NON-NLS-1$ >+ return args[i + 1]; >+ } >+ IProduct product = Platform.getProduct(); >+ if (product != null) >+ return product.getApplication(); >+ return getDefaultApplicationId(); >+ } >+ >+ protected String getDefaultApplicationId() { >+ return DEFAULT_HEADLESSAPP; > } > > } >Index: src/org/eclipse/pde/internal/junit/runtime/UITestApplication.java >=================================================================== >RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.junit.runtime/src/org/eclipse/pde/internal/junit/runtime/UITestApplication.java,v >retrieving revision 1.26 >diff -u -r1.26 UITestApplication.java >--- src/org/eclipse/pde/internal/junit/runtime/UITestApplication.java 2 Sep 2009 14:57:48 -0000 1.26 >+++ src/org/eclipse/pde/internal/junit/runtime/UITestApplication.java 4 Aug 2010 15:43:15 -0000 >@@ -11,9 +11,7 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.junit.runtime; > >-import junit.framework.Assert; >-import org.eclipse.core.runtime.*; >-import org.eclipse.equinox.app.IApplication; >+import org.eclipse.core.runtime.Platform; > import org.eclipse.equinox.app.IApplicationContext; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.testing.ITestHarness; >@@ -23,85 +21,27 @@ > * A Workbench that runs a test suite specified in the > * command line arguments. > */ >-public class UITestApplication implements IApplication, ITestHarness { >+public class UITestApplication extends NonUIThreadTestApplication implements ITestHarness { > > private static final String DEFAULT_APP_3_0 = "org.eclipse.ui.ide.workbench"; //$NON-NLS-1$ > > protected TestableObject fTestableObject; >- protected IApplication fApplication; > >- /* >- * (non-Javadoc) >- * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) >- */ >- public Object start(IApplicationContext context) throws Exception { >- String[] args = (String[]) context.getArguments().get(IApplicationContext.APPLICATION_ARGS); >- Object app = getApplication(args); >- >- Assert.assertNotNull(app); >- >- fTestableObject = PlatformUI.getTestableObject(); >- fTestableObject.setTestHarness(this); >- if (app instanceof IApplication) { >- fApplication = (IApplication) app; >- return fApplication.start(context); >- } >- return ((IPlatformRunnable) app).run(args); >- } >- >- /* >- * (non-Javadoc) >- * @see org.eclipse.equinox.app.IApplication#stop() >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication#getDefaultApplicationId() > */ >- public void stop() { >- if (fApplication != null) >- fApplication.stop(); >+ protected String getDefaultApplicationId() { >+ // In 3.0, the default is the "org.eclipse.ui.ide.worbench" application. >+ return DEFAULT_APP_3_0; > } > >- /* >- * return the application to run, or null if not even the default application >- * is found. >+ /* (non-Javadoc) >+ * @see org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication#runApp(java.lang.Object, org.eclipse.equinox.app.IApplicationContext, java.lang.String[]) > */ >- private Object getApplication(String[] args) throws CoreException { >- // Find the name of the application as specified by the PDE JUnit launcher. >- // If no application is specified, the 3.0 default workbench application >- // is returned. >- IExtension extension = Platform.getExtensionRegistry().getExtension(Platform.PI_RUNTIME, Platform.PT_APPLICATIONS, getApplicationToRun(args)); >- >- Assert.assertNotNull(extension); >- >- // If the extension does not have the correct grammar, return null. >- // Otherwise, return the application object. >- IConfigurationElement[] elements = extension.getConfigurationElements(); >- if (elements.length > 0) { >- IConfigurationElement[] runs = elements[0].getChildren("run"); //$NON-NLS-1$ >- if (runs.length > 0) { >- Object runnable = runs[0].createExecutableExtension("class"); //$NON-NLS-1$ >- if (runnable instanceof IPlatformRunnable || runnable instanceof IApplication) >- return runnable; >- } >- } >- return null; >- } >- >- /* >- * The -testApplication argument specifies the application to be run. >- * If the PDE JUnit launcher did not set this argument, then return >- * the name of the default application. >- * In 3.0, the default is the "org.eclipse.ui.ide.worbench" application. >- * >- * see bug 228044 >- * >- */ >- private String getApplicationToRun(String[] args) { >- for (int i = 0; i < args.length; i++) { >- if (args[i].equals("-testApplication") && i < args.length - 1) //$NON-NLS-1$ >- return args[i + 1]; >- } >- IProduct product = Platform.getProduct(); >- if (product != null) >- return product.getApplication(); >- return DEFAULT_APP_3_0; >+ protected Object runApp(Object app, IApplicationContext context, String[] args) throws Exception { >+ fTestableObject = PlatformUI.getTestableObject(); >+ fTestableObject.setTestHarness(this); >+ return super.runApp(app, context, args); > } > > /*
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 311979
:
175843
|
177521
|
188855