Bug 538803

Summary: Junit does not work in Eclipse, Junit not found
Product: [Fedora] Fedora Reporter: Tim Peters <mail>
Component: eclipseAssignee: Alexander Kurtakov <akurtako>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 12CC: akurtako, kaj, oliver, overholt, patrick133t
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Fixed In Version: 3.5.1-21.fc12 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-01-04 21:20:21 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On: 548099    
Bug Blocks:    
Description Flags
Patch to org.eclipse.jdt.junit plugin
Patch to org.eclipse.jdt.junit plugin, v2 none

Description Tim Peters 2009-11-19 13:17:30 UTC
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):

How reproducible:
every time

Steps to Reproduce:
1. create a new java project
2. add a junit test case
3. click yes when asked to add junit libraries
Actual results:
no junit jars are added to the classpath

Expected results:
junit works

Additional info:

Comment 1 Patrick Higgins 2009-12-10 01:18:10 UTC
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.

Comment 2 Alexander Kurtakov 2009-12-10 10:35:19 UTC
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[64]/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[64]/eclipse/dropins/jdt.

Comment 3 Patrick Higgins 2009-12-12 02:55:20 UTC
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.

Comment 4 Patrick Higgins 2009-12-12 14:05:59 UTC
Created attachment 377870 [details]
Patch to org.eclipse.jdt.junit plugin

Comment 5 Patrick Higgins 2009-12-12 14:06:47 UTC
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!

Comment 6 Patrick Higgins 2009-12-12 14:37:39 UTC
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

Comment 7 Alexander Kurtakov 2009-12-14 09:24:04 UTC
Thanks for the patch. I'll test it locally and hopefully upstream won't find some problems so we will push a new build.

Comment 8 Alexander Kurtakov 2009-12-17 16:10:38 UTC
Patch applied. Update to follow soon.

Comment 9 Fedora Update System 2009-12-18 10:47:02 UTC
eclipse-3.5.1-21.fc12 has been submitted as an update for Fedora 12.

Comment 10 Fedora Update System 2009-12-22 04:49:25 UTC
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

Comment 11 Fedora Update System 2010-01-04 21:20:16 UTC
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.