Description of problem:
I have a Java project. I created a new JUnit test case with the wizard. The wizard detected I don't have JUnit on my classpath and offered to add it. I said yes but it didn't add it to the project's classpath for me.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. create a new java project
2. add a junit test case
3. click yes when asked to add junit libraries
no junit jars are added to the classpath
I see the same problem. This seems similar to Eclipse bug 276111:
However, that was supposed to be fixed in 3.5.1, so it may be a different problem.
The workaround I've been using is to add the junit jar to my project directly, but I don't want to have to share a project file like that with others just to deal with my broken installation.
It's a similar issue but it is caused by our separation of jdt (and junit as a result) and installation in dropins. I'm still not able to find a fix for the problem.
If someone is interesting to debug the problem:
junit bundle is installed in /usr/lib/eclipse/dropins/jdt but there is no p2 data in the dropins folder because it is created in ~/.eclipse/**/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info which makes p2 looking for it in ~/.eclipse while it is actually in /usr/lib/eclipse/dropins/jdt.
I've been debugging this a little and it looks to me like JDT has a P2Utils class that doesn't know to look in dropins for things. It does look in both the config area and install location (if not found in the config area).
For the install location search, it calls:
Ultimately, this leads to a call to:
That call appears to return a BundleInfo of size 149, which is the number of entries in my /usr/lib/eclipse/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info.
From what I've seen, those are the only entries that get searched by JDT for junit. It doesn't have any logic for checking dropins.
Created attachment 377870 [details]
Patch to org.eclipse.jdt.junit plugin
OK, I've created a fix; the patch is attached. I will also create a bug on the Eclipse bug tracker for this.
The problem is that the P2Utils class in the org.eclipse.jdt.junit plugin will only resolve relative URLs in the config area to URLs under the config area. I've patched it so that it will look there first, but will also check the install area if a relative URL is found.
It seems really bizarre to me that such seemingly general lookup code is in the JDT JUnit plugin!
Created attachment 377875 [details]
Patch to org.eclipse.jdt.junit plugin, v2
I updated my patch to remove an erroneous return statement.
The Eclipse bug is https://bugs.eclipse.org/bugs/show_bug.cgi?id=297663
Thanks for the patch. I'll test it locally and hopefully upstream won't find some problems so we will push a new build.
Patch applied. Update to follow soon.
eclipse-3.5.1-21.fc12 has been submitted as an update for Fedora 12.
eclipse-3.5.1-21.fc12 has been pushed to the Fedora 12 testing repository. If problems still persist, please make note of it in this bug report.
If you want to test the update, you can install it with
su -c 'yum --enablerepo=updates-testing update eclipse'. You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F12/FEDORA-2009-13476
eclipse-3.5.1-21.fc12 has been pushed to the Fedora 12 stable repository. If problems still persist, please make note of it in this bug report.