Maven, Java and RSpec

18 September 2008

java junit maven rspec testing

Since I've been back on the job, writing Java code lately, that means I've been testing Java code lately.

After living in the land of Ruby with RSpec, thinking about JUnit did not excite me. Thankfully I found the rspec-maven-plugin, which integrates straight into the maven test process.

I like rspec because it removes a whole lot of the cruft involved in writing tests. When I return to the specs weeks later, I can still read the intent. So often, with JUnit tests named with cryptic method names, it's difficult to ascertain exactly what's intended to be tested.

The beta-4 plugin on the repository is based on jruby-1.1.2, but in SVN I've updated it to support 1.1.4. I think there's still some more improvements to be made, such as respecting maven.test.skip and getting rid of the need for JRUBY_HOME pointing to a full installation. (Note: I did not write this plugin, I've just started contributing to it).

After a little configuration of the plugin in your pom.xml...

    <!-- jrubyHome points to the JRuby installation you wish to use (usually ${env.JRUBY_HOME}) -->
    <!-- sourceDirectory references where your RSpec tests reside -->
    <!-- outputDirectory specifies where the RSpec report should be placed -->

Now, just start flinging out specs in ./src/test/specs/.

This is a portion of a test against a JBoss-VFS VirtualFileHandler implementation, written in Java in

describe WarRootHandler do

  before(:each) do
    @context = RailsAppContextFactory.getInstance.createRoot( "ballast", File.dirname( __FILE__ ) + '/../ballast' )
    @root = @context.get_war_root_handler

  it "should have a rails:// URL" do
    @root.to_uri.to_string.should eql( "rails://ballast/" )

  it "should be resolvable through java URL handlers" do
    url = "rails://ballast/" )
    url.to_s.should_not be_nil

  it "should delegate for WEB-INF requests" do
    web_inf = @root.get_child( 'WEB-INF' )
    web_inf.should_not be_nil
    jboss_rails_yml = web_inf.get_child( 'jboss-rails.yml' )
    jboss_rails_yml.should_not be_nil

Well, which is it?

14 January 2008

java jira maven usability

I've been working on compiling JIRA plugins lately, with maven-2.

And I see this go scrolling by:

[WARNING] *** CHECKSUM FAILED - Error retrieving checksum file for webwork/jars/webwork-30Apr07-jiratld.jar - IGNORING

In that single line, I get confused, as there are 4 hot words right there.

  1. WARNING: Hey, something bad happened, but it's not super bad.
  2. FAILED: Well, crap, it just plain did not work.
  3. ERROR: Yep, it still didn't work, and that's a bad bad thing.
  4. IGNORING: But apparently I shouldn't care too much, because maven surely isn't giving it much thought anymore.

Should I take corrective action? Is there anything I can do? I got all hyped up about being warned of the error of failing, only to be told it's no big deal.

Of course, I had to babysit the first build like a crack-baby delivered in the 2nd trimester. Maven attempts to download the world from Atlassian's repository which likes to take a nap after downloading a dozen .pom files. I'd have to go Control-C all over it, and start over, to get a running start at the next dozen .poms. Fun!

A More Pronouncable Maven Corp

19 April 2007

business java maven opensource

Today, my Canadian friend Jason van Zyl announced his new company based around all things maven.

Jason, as you may know, is the founder of both Maven and the first maven-centric company, Mergere. For some history, Mergere was a child of Simula Labs. Simula started life as a VC-ish incubator, but now seems to be some sort of opensource delivery plumbing, particularly after selling LogicBlaze off to IONA last week.

After his stint in LA, Jason returned to his Canadian motherland and enjoyed a brief respite before launching Sonatype today.


He says he's happy to have Sonatype be classified as a training company, but ultimately he's building out a vast partners network to help make maven pervasive. While they are working on projects with some top-shelf clients, they generally prefer to find partners to provide professional services.

I think this open attitude and approach towards other commercial interests within the maven project ecosystem is absolutely correct. Jason is ultimately the outbreak monkey for maven, and how he deals with his community will make or break any commercial effort. As the entire market for maven-related stuff grows, it will require many players to thrive, not just a single dominant controlling organization. I think Sonatype is heading down the right path by becoming a natural commercial nexus instead of attempting to become a 10,000 lbs gorilla.

Disclosure: Jason's a good friend and co-founder of the Codehaus, so I'm not unbiased.