Home > Development > Why testing early pays off

Why testing early pays off

Part of what we’re doing at my current client is writing an HTTP interface to allow read only access to a Tangosol cache. For the first month or so we’ve been using Jetty (6.0.2) for testing and development, because it’s free and easy. Everything has been going well, and we finally got the official ruling that our webapp will run in production under JBoss (4.0.3SP1). We did expect this, as current webapps they have in production run under JBoss, but we were not sure of which version we were going to end up on so we stuck with Jetty. We’ve been very carefull to keep our app as vanilla as possible, but when we deploy our happy app under JBoss, we start getting showered with NullPointerExceptions like these:

at org.apache.xalan.transformer.SerializerSwitcher.switchSerializerIfHTML(SerializerSwitcher.java:153)
at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:991)

After a bit of poking around I found that the only nulls that existed in that area of our code was when we were calling startElement() and endElement() with nulls. A quick look at the JavaDocs for these methods says that you should pass “the empty string” if there is no Namespace URI or Namespace. Simply replacing calls like:

transformerHandler.startElement(null, null, ERROR_TAG_NAME, errorAttributes)


transformerHandler.startElement(“”, “”, ERROR_TAG_NAME, errorAttributes)

sorted out the problem!

We’re only due to go live with this app in July, but one of the patterns that has saved me many times is to test early and often. The trick is not to limit your testing, but push it as far as you can go. In this case, testing in a production like environment 5 months before we’re due to go live has meant we only needed to change a few lines of code in two classes. Imagine how much more we would have to change in 5 months time…

Categories: Development
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: