Bug 538803 - Junit does not work in Eclipse, Junit not found
Junit does not work in Eclipse, Junit not found
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: eclipse (Show other bugs)
12
All Linux
low Severity medium
: ---
: ---
Assigned To: Alexander Kurtakov
Fedora Extras Quality Assurance
:
Depends On: 548099
Blocks:
  Show dependency treegraph
 
Reported: 2009-11-19 08:17 EST by Tim Peters
Modified: 2010-01-04 16:20 EST (History)
5 users (show)

See Also:
Fixed In Version: 3.5.1-21.fc12
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-01-04 16:20:21 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch to org.eclipse.jdt.junit plugin (1.37 KB, patch)
2009-12-12 09:05 EST, Patrick Higgins
no flags Details | Diff
Patch to org.eclipse.jdt.junit plugin, v2 (1.37 KB, patch)
2009-12-12 09:37 EST, Patrick Higgins
no flags Details | Diff

  None (edit)
Description Tim Peters 2009-11-19 08:17:30 EST
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-09 20:18:10 EST
I see the same problem. This seems similar to Eclipse bug 276111: 

https://bugs.eclipse.org/bugs/show_bug.cgi?id=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 05:35:19 EST
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-11 21:55:20 EST
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:

P2Utils.getBundlesFromFile(
  file:/usr/lib/eclipse/,
  file:/usr/lib/eclipse/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info);

Ultimately, this leads to a call to:

org.eclipse.equinox.internal.simpleconfigurator.manipulator.SimpleConfiguratorManipulatorImpl.loadConfiguration(
  file:/usr/lib/eclipse/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info,
  /usr/lib/eclipse);

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 09:05:59 EST
Created attachment 377870 [details]
Patch to org.eclipse.jdt.junit plugin
Comment 5 Patrick Higgins 2009-12-12 09:06:47 EST
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 09:37:39 EST
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 04:24:04 EST
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 11:10:38 EST
Patch applied. Update to follow soon.
Comment 9 Fedora Update System 2009-12-18 05:47:02 EST
eclipse-3.5.1-21.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/eclipse-3.5.1-21.fc12
Comment 10 Fedora Update System 2009-12-21 23:49:25 EST
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 16:20:16 EST
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.

Note You need to log in before you can comment on or make changes to this bug.