Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 360217 - Issue with KeyboardLayout classloading
Summary: Issue with KeyboardLayout classloading
Status: RESOLVED FIXED
Alias: None
Product: SWTBot
Classification: Technology
Component: Build (show other bugs)
Version: 2.1.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 2.1.0   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 359024
  Show dependency tree
 
Reported: 2011-10-07 07:21 EDT by Mickael Istria CLA
Modified: 2013-05-30 04:05 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mickael Istria CLA 2011-10-07 07:21:01 EDT
Detected while working on Tycho build, which is more compliant and rigorous with OSGi that the PDE-based build.

The org.eclipse.swtbot.swt.finder.test contains some keyboard layouts. The KeyboardLayout class will try to read them using its own classloader, which is not aware of the .test plugin. So, conforming to OSGi, the test fails because it cannot load keyboards.
The right way to contribute a keyboard in the OSGi way is to put the keyboard file in a fragment hosted by the bundle containing the KeyboardLayout class.
Comment 1 Mickael Istria CLA 2011-10-07 07:36:31 EDT
I'm working on it. You can see progress here: https://github.com/mickaelistria/swtbot/tree/360217
Comment 2 Mariot Chauvin CLA 2011-10-07 08:07:12 EDT
(In reply to comment #1)
> I'm working on it. You can see progress here:
> https://github.com/mickaelistria/swtbot/tree/360217

It seems to me that org.eclipse.swtbot.swt.finder use the eclipse buddy policy extension, see "Eclipse-BuddyPolicy: registered" in https://github.com/mickaelistria/swtbot/blob/360217/org.eclipse.swtbot.swt.finder/META-INF/MANIFEST.MF.

So if you simpy declare "Eclipse-RegisterBuddy:org.eclipse.swtbot.swt.finder" in MANIFEST.MF of the test bundle it should works.

See http://cyrillakech.blogspot.com/2007/12/eclipse-buddypolicy-registered-et.html
Comment 3 Mickael Istria CLA 2011-10-07 08:40:21 EDT
That's right.
However, I don't like a lot buddyPolicies, it is not always easy to understand and the specific use-case of SWTBot keyboard is quite easy to fix with a fragment.
I'll go for a fragment solution.
Moreover, I just tried this, and it works well. So...
Comment 4 Ketan Padegaonkar CLA 2011-10-07 09:38:50 EDT
Why do these unit tests need OSGi to run. They are swt based tests, and I'd like to run them using plain JUnit because that's how users of that jar use it for the most part.

Can't they run as plain old junit tests as they do right now?
Comment 5 Mickael Istria CLA 2011-10-07 09:57:57 EDT
I've been using the Tycho surefire-plugin to test this plugin in a Tycho build, and run the test in an Eclipse.
I'll try to have those test running in a simple "surefire-plugin" so that their execution gets independant of OSGi. However, I am not sure how much people use the jar directly...
Comment 6 Mickael Istria CLA 2011-10-10 05:41:26 EDT
I succeeded to get test running (except keyboard layout issues on french keyboard) on both maven-surefire (non-OSGi) and (ycho-surefire (OSGi).

This is available on my "master" branch with the following commit: https://github.com/mickaelistria/swtbot/commit/e138b644c19a22a52be8e03523121a665ecd04c8

Ketan, do you think we should:
* Keep only OSGi tests ?
* Keep only non-OSGi tests, and then remove the fragment I created for OSGi ?
* Keep both, Run both ? Tests will get twice longer to execute.
Comment 7 Mickael Istria CLA 2013-05-30 04:05:17 EDT
Build is working great and the problem was fixed (I don't remember how).