JRuby Support (strikes back) [message #31236] |
Thu, 02 April 2009 23:52 |
Eclipse User |
|
|
|
Originally posted by: frederick.ros.gmail.com
Hi Ketan,
Following experiments made by Andy Maleh, I'm currently trying to play
with SWTBot within JRuby.
My goal is to be able to write some user acceptance tests (using
Cucumber) to be able to tests some of my Eclipse plug-ins.
Currently I'm able to create a small SWT application and to start an
SWTBot to click some of its buttons. So far, so good.
Now regarding Eclipse: I'm able to start an Eclipse instance in a
dedicated thread. However, if I try to get the 'Eclipse Display' using
the method you described (i.e. for each of the VM thread look if an SWT
Display is available). I'm thus unable to start an SWTBot or
SWTEclipseBot in the main thread to exercise my Eclipse instance.
Am I doing something wrong ? Is it technically possible, or is this
'lack' of Display due to the way Eclipse internally work ?
Thanks in advance and Best Regards,
Fred
|
|
|
|
Re: JRuby Support (strikes back) [message #31302 is a reply to message #31270] |
Fri, 03 April 2009 00:29 |
Eclipse User |
|
|
|
Originally posted by: frederick.ros.gmail.com
Ketan Padegaonkar wrote:
> Are you starting off eclipse by calling the launcher main() method and
> then waiting on the display to appear ?
Hi Ketan,
Thanks for your quick answer.
Yep actually that's exactly what I'm doing: Eclipse is launched using
something like:
org.eclipse.equinox.launcher.Main.main("")
in a dedicated thread.
> I'd recommend instead starting cucumber inside jruby inside an
> application. You may need to hack up something like the swtbot launch
> application[1] to launch your stuff.
OK, I'll try this.
> I'm not fully aware of the mechanics of having the display running on a
> non-main thread. You may also try running your tests on the non-main
> thread.
Yes, I'm going to test this first as this is quicker to validate the
stuff ...
> The platform.rcp newsgroup may be a good place to ask with this
> particular issue, as my understanding of the launching mechanism is not
> all that great.
Thanks a lot for your help.
Regards,
Fred
|
|
|
Re: JRuby Support (strikes back) [message #31357 is a reply to message #31270] |
Fri, 03 April 2009 16:30 |
Eclipse User |
|
|
|
Originally posted by: frederick.ros.gmail.com
Ketan Padegaonkar wrote:
> Are you starting off eclipse by calling the launcher main() method and
> then waiting on the display to appear ?
>
Hi Ketan,
I tried to understand what is the real problem here...
What I can see is that the Display class manages an array of Display
objects: each time a Display object is created it is added to this array.
The findDisplay(thread) method just loop around this array looking if
one of its items is associated to the furnished thread.
So far so good ...
If I understand well, having a thread updating the Display static array
and another reading it should not be a problem (provided that the block
updating the array is synchronized, which is the case).
Now playing with debugging, it looks like both threads were working in
different memory areas: the Display array is updated by the Eclipse when
starting, but the Display array the other thread looks at stays empty ...
I'll now have to understand what makes this (i.e. Eclipse in a thread,
SWTBot in another) different from an example with my own private SWT
application runing in a thread and SWTBot in another one.
Best Regards,
Fred
|
|
|
|
Re: JRuby Support (strikes back) [message #31428 is a reply to message #31405] |
Fri, 03 April 2009 19:08 |
Eclipse User |
|
|
|
Originally posted by: frederick.ros.gmail.com
Ketan Padegaonkar wrote:
> I *think* this is because the classloaders used to load the two Display
> classes are different!
>
> Plugins inside eclipse use a classloader that is different from the one
> you use to run your tests, which is why you have two different memory
> areas.
>
> An identity '==' check on the display classes should prove this. My
> guess is that even an equality check 'equals()' would fail.
>
After reading an article on the web, I came to the same conclusion.
Classloaders ... ;)
> This is an interesting problem that I'd definitely like to take a look
> at, I'd be traveling for some part of the next week, so expect some
> delays in responses from me.
I'm going to try to have a look at this too :)
Best Regards,
Fred
|
|
|
Re: JRuby Support (strikes back) [message #31661 is a reply to message #31405] |
Thu, 09 April 2009 12:54 |
Eclipse User |
|
|
|
Originally posted by: frederick.ros.gmail.com
Ketan Padegaonkar wrote:
> This is an interesting problem that I'd definitely like to take a look
> at, I'd be traveling for some part of the next week, so expect some
> delays in responses from me.
Hi Ketan,
I advanced a little bit on this one (not so much time these days).
What I'm trying to do is to start an Eclipse instance using the
org.eclipse.core.runtime.adaptor.EclipseStarter class.
If I succeeds in this, it means that I'll be able to get access to OSGI
services, and will be (potentially) able to get the classloader used for
the org.eclipse.swt plugin.
Then I could use this classloader to load SWTBot ...
Do you think this is doable ?
Best Regards,
Fred
|
|
|
Re: JRuby Support (strikes back) [message #31694 is a reply to message #31661] |
Thu, 09 April 2009 15:42 |
Ketan Padegaonkar Messages: 873 Registered: July 2009 |
Senior Member |
|
|
Hi Fredrick:
What I'm trying out is something like the snippet below. The jruby
bundle is the jruby-complete jar packaged with cucumber. This one is
able to successfully print 'hello world'.
What I need to do next is be able to invoke cucumber :) I think that
should be fairly simple!
public class CucumberRunner implements IApplication {
public Object start(IApplicationContext context) throws Exception {
Bundle bundle = Platform.getBundle("org.jruby.jruby");
URL jrubyHome =
FileLocator.toFileURL(bundle.getEntry("/META-INF/jruby.home "));
RubyInstanceConfig config = new RubyInstanceConfig();
config.setJRubyHome(jrubyHome.toString());
Ruby runtime = JavaEmbedUtils.initialize(new
ArrayList<String>(), config);
RubyRuntimeAdapter evaler = JavaEmbedUtils.newRuntimeAdapter();
evaler.eval(runtime, "p 'hello world'");
JavaEmbedUtils.terminate(runtime);
return EXIT_OK;
}
}
-- Ketan
On 9/4/09 18:24, Frederick Ros wrote:
> Ketan Padegaonkar wrote:
>> This is an interesting problem that I'd definitely like to take a look
>> at, I'd be traveling for some part of the next week, so expect some
>> delays in responses from me.
>
> Hi Ketan,
>
> I advanced a little bit on this one (not so much time these days).
>
> What I'm trying to do is to start an Eclipse instance using the
> org.eclipse.core.runtime.adaptor.EclipseStarter class.
>
> If I succeeds in this, it means that I'll be able to get access to OSGI
> services, and will be (potentially) able to get the classloader used for
> the org.eclipse.swt plugin.
>
> Then I could use this classloader to load SWTBot ...
>
> Do you think this is doable ?
>
> Best Regards,
> Fred
>
|
|
|
Re: JRuby Support (strikes back) [message #31728 is a reply to message #31694] |
Thu, 09 April 2009 16:28 |
Eclipse User |
|
|
|
Originally posted by: frederick.ros.gmail.com
Ketan Padegaonkar wrote:
> Hi Fredrick:
>
> What I'm trying out is something like the snippet below. The jruby
> bundle is the jruby-complete jar packaged with cucumber. This one is
> able to successfully print 'hello world'.
>
> What I need to do next is be able to invoke cucumber :) I think that
> should be fairly simple!
>
> public class CucumberRunner implements IApplication {
>
> public Object start(IApplicationContext context) throws Exception {
> Bundle bundle = Platform.getBundle("org.jruby.jruby");
>
> URL jrubyHome =
> FileLocator.toFileURL(bundle.getEntry("/META-INF/jruby.home "));
>
> RubyInstanceConfig config = new RubyInstanceConfig();
> config.setJRubyHome(jrubyHome.toString());
> Ruby runtime = JavaEmbedUtils.initialize(new
> ArrayList<String>(), config);
> RubyRuntimeAdapter evaler = JavaEmbedUtils.newRuntimeAdapter();
> evaler.eval(runtime, "p 'hello world'");
> JavaEmbedUtils.terminate(runtime);
>
> return EXIT_OK;
> }
> }
Wow, that's great !!!
Regarding calling Cucumber, I would say the simplest (at least to test
it works) would probably be mimicking the cucumber binary:
Cucumber::Cli::Main.execute("my","list","of","options ");
If I understand correctly the path you're taking we will then be able to
use Cucumber in the same way we're doing headless test .
Best Regards,
Fred
|
|
|
|
|
|
|
|
Re: JRuby Support (strikes back) [message #32007 is a reply to message #31971] |
Sat, 11 April 2009 07:59 |
Eclipse User |
|
|
|
Originally posted by: frederick.ros.gmail.com
Ketan Padegaonkar wrote:
> You'll also need to create a fragment to enhance jruby classpath for it
> to be able to load up swt and swtbot classes.
>
Yep, I'll have a look at this next week, to see how I could package all
of this properly.
> Would be great if you could put up some samples on
> http://swtbot-examples.googlecode.com.
Sure, I think I'll also put all related material on github.
Best regards,
Fred
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05116 seconds