HtmlUnit

Inspired through the news about the new HtmlUnit version (TheServerSide-News) I decided to give it a try to test some JSF application. One of the first things were some error-messages about redirection, as described in this HtmlUnit-FAQ-entry. Well I could not accept that… and some intense minutes of digging into some sourcecode… here is a possibility to turn off those error-messages:

In the setUp()-method, or under Junit 4 the setUpBeforeClass()-method, I added these two lines:

System.getProperties().put(
   "org.apache.commons.logging.Log",
   "org.apache.commons.logging.impl.SimpleLog");
System.getProperties().put(
   "org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient.HttpMethodDirector",
   "fatal");

And the error-messages are gone. The same things could be done in a config-file, but dealing here with unit-testing I prefer to do it directly in Java. The most difficult thing was determining the name of the second property.

more to follow…

Advertisements


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 )

Google+ photo

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

Connecting to %s