YaK:: WebLog #535 Topic : 2005-12-21 18.58.22 matt : HttpUnit issues with OpenRico [Changes]   [Calendar]   [Search]   [Index]   [PhotoTags]   
  [Back to weblog: pretention]  
[mega_changes]
[photos]

HttpUnit issues with OpenRico

Ran into some issues with HttpUnit and JWebUnit while on a job in Miami last week. Here's how to mostly work around them.


OpenRico (http://www.openrico.org/) is a Java library that allegedly makes Ajax transactions in Java web apps easier. HttpUnit (http://httpunit.sourceforge.net/) (and it's cousin, JWebUnit (http://jwebunit.sourceforge.net/)) allow programmers to write unit test-style tests for their web pages: programmatically loading a page, interacting with controls, and asserting the presence or absence of data in certain fields or table cels. JWebUnit actually uses HttpUnit underneath, along with all of HttpUnit's underlying components.

The team I was working with had tried to do some basic HttpUnit tests, but kept getting odd JavaScript parsing issues that they thought were related to their usage of OpenRico. They hadn't had the time before to really figure out why, so I paired with a developer to look at things. Sure enough, the HttpUnit tests running in JUnit (http://junit.org) gave odd JavaScript parsing exceptions which were causing our tests to fail. The exceptions errors were hard to make sense of because they would say things like "parse error on line 1301", but not mention which file it was.

First, we needed to track down the line of JavaScript causing the problem. We went through all the .js files referenced from the page we were testing, seeing which one had a line 1301 that made sense (wasn't a comment, etc). We found it in the OpenRico generated javascript file. It looked like a pretty basic line of JavaScript, so I thought we should look for a newer version of HttpUnit. Unfortunately, there was no newer version since 2004, and going through the few CVS commit messages since their last release didn't yield any possible fixes if we were to cvs checkout the source and build it ourselves.

Looking through HttpUnit's CVS was when I noticed js.jar -- a binary component. I mentioned this to my partner and we started web searching to find out where it came from. My thinking was that if the js.jar library's interfaces hadn't changed in a newer version, the bug may have been fixed. We found a link to the js.jar page in the JWebUnit pages (http://jwebunit.sourceforge.net/dependencies.html).

js.jar is a component maintained by the Mozilla Foundation called "Rhino", the latest release of which is 1.6R2 which came out in 9/2005. The version HttpUnit was using was 1.5R4.1 which came out in 4/2003. That's over 2 years old! We downloaded 1.6R2 andd dropped it in place and it just worked!

Tests got much farther, but we still had to comment out some odd JavaScript in OpenRico's code in the case of very old web browsers. Once we did that, the tests mostly passed. They needed to be refactored to have fewer assertions per test and we introduced a SetUp, and it turned out great.

I don't usually write about things like this, but I figured that if anyone had the same problem and did a web search that this page might be helpful. HttpUnit seems pretty cool, like NUnitAsp. It just seems like it needs to be more actively maintained by someone, somewhere.

Discussion:

showing all 0 messages    

(No messages)

>
Post a new message:

   

(unless otherwise marked) Copyright 2002-2014 YakPeople. All rights reserved.
(last modified 2005-12-21)       [Login]
(No back references.)