HomeHome
MarathonMarathon
MarathoniteMarathonite
CompanyCompany
ContactContact
WeblogWeblog
 

All things Marathon, Marathonite, Java and GUI Test automation, scripting and whatever is useful for test automation projects.

CATEGORIES

BOOKMARKS

Working on assert_content implementation for JRuby. And straight-away headed into a road block. The call to assert_content looks like this:

assert_content('component', [['R1C1', 'R1C2', 'R1C3'], ['R2C1', 'R2C2', 'R2C3']])

This function from ruby should call a java function:

assertContent(String componentName, String[][] content);

Now it is easy enough in JRuby to convert an array of strings to java array of strings:

['hello'].to_java :String #=> String[]

But converting a array of array of strings is not that straight forward. After a bit of hacking, I found this way.

[['r1c1', 'r1c2'], ['r2c1', 'r2c2']].to_java([].to_java(:String).class) #=> String[][]

Is there any better way of doing this?

Posted by KD Posted in JRuby, Marathon

4 comments so far

  1. Dany

    A posting to jruby-users suggested pre 1.1.3
    [['r1c1', 'r1c2'], ['r2c1', 'r2c2']].map {|ary| ary.to_java(:String)

    with 1.1.4+, the suggestion was
    [['r1c1', 'r1c2'], ['r2c1', 'r2c2']].to_java java.lang.String[]

    Which brings me to my question… Do you plan to update jruby version with the next 2.0 release?

  2. KD

    2.0b4 will ship with JRuby 1.1.5. Jython I am still keeping at 2.2.1 and removing separate model for 2.5 versions.

    You can use earlier/later versions by setting the Home in project settings.

    – KD

  3. Danielle

    Great ideas, is there a place to elaborate on this all?

  4. Random T.

    This is quite a up-to-date info. I’ll share it on Twitter.

Leave a Reply