Jeff Mesnil
Weblog · About

Testing an Eclipse plug-in in isolation

August 30, 2005

All this post just to ask a simple question: how to test an Eclipse plug-in in isolation?

I'm currently writing an Eclipse feature to manage a server through JMX. It is composed of 3 plug-ins:

  • the JMX plug-in is used to create on demand the MBean proxies and handle all the low-level JMX stuff (connections, authentication, etc.)
  • the Core plug-in is my domain model. it provides core objects which, in addition of the management methods of the MBeans, provide navigation methods to easily move between them (the core objects are in a way proxies of the MBean proxies...)
  • the UI plug-in uses the core objects provided by the Core plug-in for display and user interaction.

As an aside, I don't use the MBeans directly as my domain model. To have an object-oriented domain model has two advantages:

  1. the navigation between the objects is simple to use and self-described by the API
  2. I can integrate better with Eclipse since my core objects implements IAdaptable (adapters are implemented in the UI plug-in)

So I'd like to test the Core plug-in in isolation to ensure the consistency of my domain model based on the MBeans. However I don't want to use the "real" MBeans because most of the code I want to test is destructive and will alter the state of the managed objects on the server side making it too much difficult to run tests in isolation.

My first idea was to mock the JMX plug-in so that it returns mocked MBeans that I can use to unit test the Core plugin.

It sounds quite simple but I haven't yet find a way to make it work...

The first dirty hack that I tried was to create a JMX Mock plug-in with the same ID and API than the real JMX plug-in and use that one in the test launch configuration but Eclipse is (understandingly!) not happy about having two plug-ins with the same ID. Anyway, it is ugly because the JMX Mock plug-in wouldn't have any relation with the real JMX plug-in but a copy-paste...

Another dirty solution would be that the JMX plug-in itself could either return the real MBeans or the mocked ones. But is is so ugly and wrong that I really don't want to go that way...

I searched on Google and Eclipse mailing lists about ways to test Eclipse plug-ins in isolation but I didn't found any good advices.

In fact I haven't found information about mocked plug-in (but thousands and thousands of plug-ins generating mocks, sigh...).

All that said, I just have two simple questions:

  • how to test a plug-in in isolation?
  • how to provide a mocked plug-in which is injected in another plugin at runtime?

Disclaimer: I'm relatively new at plug-ins development and I really wonder if I'm not missing something obvious for experienced plug-ins developers...)

Mac OS X on X86: what will it mean for Java?

June 7, 2005

So now that the news is official that Apple will move its laptops to Intel X86 architecture, I'm wondering what it means for Java. I'm neither a hardware guy nor an OS one but if the architecture is based on X86 and the OS on an UNIX kernel, what are the implications for Java? Will it be simpler for Apple to develop their own JVM? Can they leverage Open Source projects (no, I'm not talking about Harmony!)?

My hope is that there will be less lag between Sun JVMs on Wintel and Linux and Apple one. However, since Apple seems committed to support both PowerPC and X86 architectures, will they accept to have two different versions of Java (the X86 one following closely Sun ones and the PowerPC one still lagging a few months behind)? Or will they keep only one version and, unfortunately but realistically, the older one? Java was much heralded by Steve Jobs when Apple released Mac OS X but it has never really become a first-class citizen for application development. Now with the move to Intel and the continuing support for PowerPC, it may renew the interest of developers.

That and the availability of SWT for Cocoa would mean a new age for Java application development on Apple boxes...

Using Java 1.5 on Mac OS X Tiger

May 2, 2005

Since I upgraded to Mac OS X Tiger, I also installed Java 1.5 on my PowerBook.

Apple provides a small application to change the default JVM to 1.5 instead of the standard 1.4.2. However it is only useful for Applets and WebStart applications. To change the default JVM for the CLI and Java applications such as Eclipse, I also had to change a symlink.

$ cd /System/Library/Frameworks/JavaVM.framework/Versions
$ sudo mv Current Current.old
$ sudo ln -s 1.5 Current

Et voila!

$ java -version
java version "1.5.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-56)
Java HotSpot(TM) Client VM (build 1.5.0_02-36, mixed mode, sharing)

Ars Technica review of Mac OS X Tiger

April 29, 2005

A extensive review of Mac OS X Tiger has been published on Ars Technica.

The explanation of how metadata have been implemented and how Spotlight works under the hoods is the best I've seen so far. I'm eager to try Spotlight but after reading that article and figuring out what can be done if users could apply metadata to file, I'm already looking forward to Mac OS X 10.5 (lion?, wolverine?).

Favorite features in Mac OS X Tiger

April 12, 2005

Now that the release date is known (April 29th), and after having browsed the 200+ new features of Tiger, these are the ones I'm looking forward to:

  • Spotlight -- I'm using Quicksilver for some of the Spotlight features but Spotlight integration in Apple applications (especially Mail) seems quite powerful
  • Dashboard -- Widgets are cool (but are they useful?). What is interesting with Dashboard is that it's based on Web standards (HTML, CSS, JavaScript). If it is possible to use an XmlHttpRequest object from Dashboard widgets, there is a lot of potential (a new wave of Web Services straight to my desktop)
  • Preview -- View and create annotations to a PDF document
  • DVD Player -- Bookmark favorite moments of a DVD
  • iChat AV -- Jabber support
  • Mail -- Add photos from Mail directly to iPhoto
  • Mobility -- More battery usage for my PowerBook
  • Access Spotlight from a UNIX command line using mdls or mdfind (will it be more powerful than find/grep/locate combination?)
  • Java 1.5 -- it seems it's not part of Tiger but available as a separate download

There is no killer feature for me (like Expose was for Panther) but a lot of minor enhancements which should improve the great user experience I have on my Mac so far.

Continuations In Ruby

March 24, 2005

updated with a code example

Via Tim Bray, I read an example of Continuations in Ruby.

The example is very impressive but I didn't grok it at first (I'm still not sure to have understood it yet!).

After some searches on continuations, I found this funny analogy on the RubyGarden Wiki which helped me to understand better what continuations are.

I don't see yet where and when I would use them but it's a new way for me to think about the execution of the code that I'm not accustomed to. Very interesting stuff!

Here is the Ruby code corresponding to the analogy:

puts "Walking..."
turn_left = callcc do | turn_left |
    turn_left
end
if turn_left
  puts "Turning left..."
  puts "Bitten by a dog!"
  bitten = callcc do | bitten |
      bitten
  end
  turn_left.call false if turn_left
  puts "I prefer to bleed!"
else
  puts "Turning right..."
  puts "Hit by a train!"
  bitten.call
  puts "DEAD!!"
end

which outputs

Walking...
Turning left...
Bitten by a dog
Turning right...
Hit by a train!
I prefer to bleed!

The simple example is no better than using goto statements but the example in Continuations on the Web shows that continuations can become more powerful than that when they keep state.

Comments on "Data on the Outside Versus Data on the Inside"

March 9, 2005

Fantastic paper from Pat Helland : Data on the Outside Versus Data on the Inside. In this paper, Pat gives a high-level overview of what SOA really means and all its implications.

His conclusions are not really groundbreaking:

  • use version dependent identifier
  • use XML for outside data
  • use SQL for inside data
  • use Objects for business logic

But what is great is the way he comes to that conclusion.

My favorite part is the introduction of a temporal notion in SOA. I never realized before that using SOA has implications both on space and time. And the analogy between Newton and Einstein laws and RPC/2PC and SOA is simply brillant.

This paper is a must for anyone interested in SOA without the hype surrounding the acronym (and not cluttered by a list of hundreds of WS-blablah).

I had the great pleasure to meet Pat Helland at HPTS'03 and I learned a lot by listening to him (and his songs!). He has the most amazing quality to make complex things simple to understand (is there any better description for 2PC protocol than calling it the "unavailibility protocol"?)

Ruby as Java pseudo code

March 8, 2005

I laughed out loud when I saw that Brian uses Ruby syntax as Java pseudo-code to describe a Web framework. It might be caused by too much exposure to Ruby On Rails!

Brian is right: his Ruby pseudo code is clearer than equivalent Java code. It is a testimony of Ruby expressiveness and, sadly, of the lack of it in Java.

As an aside, very interesting stuff Brian!

Rails is slow, J2EE is Fast - Haven't I already heard this?

February 28, 2005

On Dion's blog, someone commented that Rails is 8x slower than J2EE (don't get me started on such benchmark figures...).

It reminded me of the old "Java is slow, C is fast" argument that I heard some years ago (I still hear it but mostly from Slashdot crowd these days). Then people realized that C and Java have their respective strength and weakness and are best used in some areas than others.

So maybe, we will realize that the same thing apply here and that Java/J2EE and Ruby/Rails serve different purposes and are better suited for different kind of web applications. Maybe, just maybe, one size does not fit all...

I'm not sure I'll build the next Google or Amazon on Rails. But there is also a range of web sites for which Rails is the way to go. Besides, it has a great quality long forgotten in the Java world: that simple things should be simple and complex things should be possible.

I developped in Java for a living and enjoy it most of the time (a little less since I was introduced to Ruby by the way) but sometimes the complexity of Java/J2EE saddens me and I'm not talking about EJB only.

I understand that there are some kind of applications which require this complexity and I contributed to it (on a J2EE server, a JMS one and a distributed transaction manager).

But there is way much more applications which don't need it and would benefit from some simplicity.

From that point of view, developping on Ruby and Rails is an eye-opener. I saw that it makes simple things simple. Now I need more time and experience with it to see if it is possible to do the complex stuff. So far, I've got a good feeling about it.

I plan to talk a little more about my (good) experience with Rails and Ruby. And the best resource from a Java perspective is Brian McCallister's Waste Of Time.

As an aside, maybe Rails is 8x slower than J2EE but it is also 10x more productive so that compensates it... What a bunch of meaningless figures!