Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 312798 - ClassCastException when running ds.tests project's launch configuration
Summary: ClassCastException when running ds.tests project's launch configuration
Status: CLOSED DUPLICATE of bug 296104
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: PDE-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-13 10:40 EDT by Stoyan Boshev CLA
Modified: 2010-05-14 04:52 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stoyan Boshev CLA 2010-05-13 10:40:02 EDT
Using Eclipse3.6M7

If I try to run the launch configuration "All DS Tests" provided by the project org.eclipse.equinox.ds.tests it fails to run because of a ClassCastException (see below). This happens if I run with JDK1.5+. If I run it with JDK1.4.2 the configuration is successfully run.

java.lang.ClassCastException: junit.framework.TestSuite cannot be cast to junit.framework.Test
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.getTest(JUnit3TestLoader.java:108)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestLoader.loadTests(JUnit3TestLoader.java:59)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
	at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1383)



Steps to reproduce:
- import the project org.eclipse.equinox.ds.tests from the rt repository (it is located here: org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.ds.tests) 
- run the junit launch configuration "All DS Tests" with JDK1.5 or higher


I have debugged the problem and it seems that it is caused because there are two "org.junit" bundles with different versions in the target platform. When running the configuration, PDE selects the bundle with higher version and this causes the problem. 
It is strange that this problem does not happen when running the launch configuration of project osgi.tests. It seems identical as the one of ds.tests.
Comment 1 Darin Wright CLA 2010-05-13 10:47:11 EDT
Markus, is this a JUnit 3 vs. 4 issue?
Comment 2 Markus Keller CLA 2010-05-13 12:35:32 EDT
Yes, see bug 296104. I always said the org.junit plug-ins should be singletons, so that such problems can at least be detected by OSGi, but I've been overruled.
Comment 3 Darin Wright CLA 2010-05-13 13:11:00 EDT

*** This bug has been marked as a duplicate of bug 296104 ***
Comment 4 Thomas Watson CLA 2010-05-13 14:22:39 EDT
Stoyan, I figured out why ds.tests is failing to work but osgi.tests is working.  Your test bundle puts a limit on the import-package range.  If you remove the Import-Package for junit and instead use Require-Bundle on junit with no range then it seems to work.
Comment 5 Stoyan Boshev CLA 2010-05-14 04:52:50 EDT
(In reply to comment #4)
> Stoyan, I figured out why ds.tests is failing to work but osgi.tests is
> working.  Your test bundle puts a limit on the import-package range.  If you
> remove the Import-Package for junit and instead use Require-Bundle on junit
> with no range then it seems to work.

Thanks Thomas! It works this way