Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » JRuby Support (strikes back)
JRuby Support (strikes back) [message #31236] Thu, 02 April 2009 23:52 Go to next message
Eclipse UserFriend
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 #31270 is a reply to message #31236] Fri, 03 April 2009 00:07 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
On 2/4/09 16:52, Frédérick Ros wrote:
> Hi Ketan,
> 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 ?

Are you starting off eclipse by calling the launcher main() method and
then waiting on the display to appear ?

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.

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.

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.

[1] -
http://github.com/ketan/swtbot/blob/master/org.eclipse.swtbo t.eclipse.core/src/org/eclipse/swtbot/eclipse/core/UITestApp lication.java

-- Ketan
Re: JRuby Support (strikes back) [message #31302 is a reply to message #31270] Fri, 03 April 2009 00:29 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 #31405 is a reply to message #31357] Fri, 03 April 2009 17:39 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
On 3/4/09 09:30, Frederick Ros wrote:
> 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.

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.

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.

-- Ketan
Re: JRuby Support (strikes back) [message #31428 is a reply to message #31405] Fri, 03 April 2009 19:08 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 #31763 is a reply to message #31728] Thu, 09 April 2009 16:56 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
On 9/4/09 21:58, Frederick Ros wrote:
> 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 .

Exactly! Only that instead of junit, it's cucumber and we could have it
generate nice html reports with some great colored console reporting :)

Expect a blog report shortly ;)

-- Ketan
Re: JRuby Support (strikes back) [message #31870 is a reply to message #31763] Fri, 10 April 2009 04:31 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
Read up more at:

http://ketan.padegaonkar.name/2009/04/10/cucumber-on-jruby-i nside-eclipse.html

and

http://ketan.padegaonkar.name/2009/04/10/run-jruby-from-with in-a-jar-and-package-your-own-gems-along.html

-- Ketan

On 9/4/09 22:26, Ketan Padegaonkar wrote:
> On 9/4/09 21:58, Frederick Ros wrote:
>> 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 .
>
> Exactly! Only that instead of junit, it's cucumber and we could have it
> generate nice html reports with some great colored console reporting :)
>
> Expect a blog report shortly ;)
>
> -- Ketan
>
Re: JRuby Support (strikes back) [message #31903 is a reply to message #31870] Fri, 10 April 2009 08:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: frederick.ros.gmail.com

Ketan Padegaonkar wrote:
> Read up more at:
>
> http://ketan.padegaonkar.name/2009/04/10/cucumber-on-jruby-i nside-eclipse.html
>
>
> and
>
> http://ketan.padegaonkar.name/2009/04/10/run-jruby-from-with in-a-jar-and-package-your-own-gems-along.html
>

As already commented on your blog, Ketan, you're my god !

I'm going to go deeper on this, probably this afternoon.

Thanks again for your invaluable help on this !

Best Regards,
Fred
Re: JRuby Support (strikes back) [message #31938 is a reply to message #31870] Fri, 10 April 2009 15:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: frederick.ros.gmail.com

Ketan Padegaonkar wrote:
> Read up more at:
>
> http://ketan.padegaonkar.name/2009/04/10/cucumber-on-jruby-i nside-eclipse.html
>
>
> and
>
> http://ketan.padegaonkar.name/2009/04/10/run-jruby-from-with in-a-jar-and-package-your-own-gems-along.html
>

And it works great ! I just end-up testing it and it so cool :)

Next week, I'm going to try to polish it a little bit further and to
really use Cucumber with some SWTBot inside :)

Best Regards,
Fred
Re: JRuby Support (strikes back) [message #31971 is a reply to message #31938] Sat, 11 April 2009 00:14 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
On 10/4/09 21:05, Frederick Ros wrote:
> Next week, I'm going to try to polish it a little bit further and to
> really use Cucumber with some SWTBot inside :)

You'll also need to create a fragment to enhance jruby classpath for it
to be able to load up swt and swtbot classes.

Would be great if you could put up some samples on
http://swtbot-examples.googlecode.com.

-- Ketan
Re: JRuby Support (strikes back) [message #32007 is a reply to message #31971] Sat, 11 April 2009 07:59 Go to previous messageGo to next message
Eclipse UserFriend
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
Unable to run Cucumber test in Eclipse [message #546210 is a reply to message #32007] Mon, 12 July 2010 07:54 Go to previous messageGo to next message
ashitha shetty is currently offline ashitha shettyFriend
Messages: 17
Registered: March 2010
Junior Member
Hi,

I followed the procedure mentioned here:
http:// ketan.padegaonkar.name/2009/04/10/cucumber-on-jruby-inside-e clipse.html
http:// ketan.padegaonkar.name/2009/04/10/run-jruby-from-within-a-ja r-and-package-your-own-gems-along.html

and ran into the following error while running the sample cucumber script:

/cucumber.template.rb:2:in `require': no such file to load -- rubygems (LoadError)
from /cucumber.template.rb:2
...internal jruby stack elided...
from Kernel.require(/cucumber.template.rb:2)
from (unknown).(unknown)(:1)


However, running the script from the command prompt works. Have I missed something?

Regards,
Ashitha.

[Updated on: Mon, 12 July 2010 08:00]

Report message to a moderator

Re: JRuby Support (strikes back) [message #546385 is a reply to message #546210] Mon, 12 July 2010 15:24 Go to previous message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
Perhaps the system property "jruby.home" is not set correctly.

I'm curious to know what you're attempting at doing here since I was
working on something similar a couple of months ago
( http://ketan.padegaonkar.name/2010/05/28/an-embedded-interpr eter-for-eclipse.html)

--
Ketan
http://ketan.padegaonkar.name | http://eclipse.org/swtbot

On 7/12/10 12:54 AM, ashitha wrote:
> Hi,
>
> I followed the procedure mentioned here:
> http://ketan.padegaonkar.name/2009/04/10/cucumber-on-jruby-i nside-eclipse.html
> http://ketan.padegaonkar.name/2009/04/10/run-jruby-from-with in-a-jar-and-package-your-own-gems-along.html
>
>
> and ran into the following error while running the sample cucumber script:
>
> /cucumber.template.rb:2:in `require': no such file to load -- rubygems
> (LoadError)
> from /cucumber.template.rb:2
> ...internal jruby stack elided...
> from Kernel.require(/cucumber.template.rb:2)
> from (unknown).(unknown)(:1)
>
> However, running the script from the command prompt works. Have I missed
> something?
>
> Regards,
> Ashitha.
Previous Topic:Running SWTBot from a cronjob
Next Topic:How to insert text into Editor (Table) ?
Goto Forum:
  


Current Time: Thu Apr 18 01:49:11 GMT 2024

Powered by FUDForum. Page generated in 0.03321 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top