Java

Eclipsetasy! Time to throw away the dope…

… and move to newer dope…

I just realized that I had about 58 eclipse SDKs downloaded on my hard drive and 22 instances of different versions of eclipse. That was a whooping 9GB for the sdk downloads and 6.5GB for the extracted versions. Time to move to newer dope :)

Similar was the case on the cruise based build grid that tested SWTBot from all versions starting from eclipse 3.2 upwards to the latest RC build on all platforms — linux-gtk/linux-gtk-64/win32/macosx-carbon.

Eclipsetasy

Eclipsetasy

Announcing a new release of SWTBot

You can download the latest and greatest from the SWTBot download page.

A listing of some of the new features available:

Bug 263036 – SWTBot finally has an icon that was missing since two years!
Bug 269919 – Added support for toggle buttons
Bug 271246 – Better support for handling editors. This should serve as a good start towards providing support for multipage, forms based editors
Bug 271132 – Using Display#post() to support sending native click events instead of fake events. This is still work in progress and not all widgets support native events yet.
Bug 273624 – Use native keyboard events for typing. SWTBot currently defaults to using AWT robot. SWT’s Dispay#post() is available as well — it is however buggy across platforms and swt versions. Since SWTBot uses native keyboard events, it needs to understand various Keyboard Layouts.
Bug 267189 – Support capturing screenshots of widgets.
Bug 277093 – Support for Link widgets.

There are also a lot of minor bugs that were fixed in this release.

Java and Unicode monday morning blues

Monday morning excitement. JUnit tests that pass in the IDE fail in ant and cruise servers running on all platforms.

java.lang.AssertionError:
Expected: a string containing "... text=Ç..."
     got: "... text=Å..."

My immediate reaction was the encoding used by the JVM. Setting the “file.encoding” system property to UTF-8 did not help. Running the ant based tests in remote debugging mode also confirmed that the two strings were indeed different.

Since the tests used Cobertura for code coverage, the next step was to disable cobertura. Cobertura manipulates the generated byte code to add logging statements for code coverage. Still the same error.

The hidden gem seemed to be the -encoding java compiler flag. Setting it to UTF-8 fixed the problem.

So the next time you have something fail because of an encoding issue, it could just be the compiler encoding and not just the encoding used in the runtime!

Cucumber On JRuby inside Eclipse

Fredrick recently asked on the swtbot newsgroup:

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.

Cucumber is a BDD framework written in (J)ruby. It executes plain text files as functional tests. As a first step, the goal was to be able to print a simple ‘hello world’:

This required being able to bundle jruby with the necessary gems, the jruby jar is already OSGi-fied, so creating a manifest was not required.

First drop in the jruby-complete.jar that we just created inside the target eclipse’s plugins directory.

Then create an eclipse application with the following in it:

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(), config);
        RubyRuntimeAdapter evaler = JavaEmbedUtils.newRuntimeAdapter();
        evaler.eval(runtime, "p 'Hello, Eclipse World'");
        JavaEmbedUtils.terminate(runtime);

        return EXIT_OK;
    }

    public void stop() {
        // do nothing
    }
}
Hello, Eclipse World

Hello, Eclipse World

Now all we needed was to be able to execute the cucumber executable instead of printing hello world :)

Import the cucumber plugin with a sample calculator to execute it:

Cucumber Output

Cucumber Output

Hitler Does Agile — Are You ?

Via this link which David pasted on IRC

Hitler doing agile with very few unit tests + no nightly build = no safetynet.

Unfortunately this is quite representative of how a lot of eclipse projects work (ducks to take cover).

Are you builds running in the same way ? Do you write tests before you write code or test manually ? Do you run all the tests before you check in ? Do you have <a href="any CI server to run your builds on a variety of platforms that you support ? Do your unit tests have enough of code coverage to give you the confidence to refactor ? Is your build reproducible on any machine (in less than 5 manual steps) ?

If you’re answering no to any of the above, then this video is for you:

SWTBot has moved to eclipse.org!

SWTBot has finally moved to eclipse.org.

There is a bit of documentation sitting at the old home that needs to move to eclipse.org. I’m hoping to move this over in the next couple of days.

The sourcecode will also move during the course of the week. I’m busy renaming plugin IDs and packages to use the org.eclipse.swtbot namespace. Meanwhile you can participate on the newsgroups.

Cheers!

SWTBot Proposal at Eclipse.org

SWTBot has been proposed as an eclipse project.

Everyone is invited to comment on and/or join the project. Please send all feedback to the SWTBot newsgroup (web link).

See you all there.

SWTBot 1.2.0 released

For the impatient:
Direct download link: https://sourceforge.net/project/showfiles.php?group_id=188411&package_id=220519&release_id=622752

Update site: http://swtbot.sourceforge.net/latest/update-site/

SWTBot 1.2.0 is the 3rd of the 1.x releases of SWTBot was released last night, and there have already been about 200 downloads by the time of writing this blog post.

SWTBot has always believed in release early release often mantra, and pushes out nightly builds out of CruiseControl. From the download stats I’m looking at, there are more downloads of the nightly build than the ’stable’ available on the sourceforge mirrors.

The highlight of the release is support for view menus and view toolbar.

Thanks to the contributors and adoptors, for patches, criticism, and suggestions for improvement. The release has fixed about 42 issues.

Read more on the detailed release notes and the changelog.

Copying code snippets for your blog

There was a conversation on IRC a while ago about wordpress plugins for syntax-highlighting code snippets. Wouldn’t it be cool if you could copy code from eclipse and paste it into your blog ?

CodeSnippet for Eclipse lets you do just that:

protected void tearDown() throws Exception {
    closeWindow("Create a new account");
    closeWindow("Address Details");
}

Growl notifications from ant

If you use ant to run your builds, and would like to receive growl notifications about execution status, presenting Growl notifications for ant.

All you need to do is execute:

ant -listener com.google.code.ant.growlnotify.GrowlListener

And you’ll need is the growlnotify binary somewhere on your path, this is bundled with the Growl binary dmg.