JCAPS Unit Testing - Part 3

Now that we can test jcdTargets from a jcdUnitTester, the final step is to use a combination of JUnit and HTTPUnit to execute and verify the tests. Basically we turn jcdUnitTester into a simple RESTful Web Service where we post the tests.

The first set of changes are to jcdUnitTester. My first pass at jcdUnitTester hard coded the test into the JCD. Since we'd like to change the message per test, it'd be better to pass this in as parameter on the HTTP Request. Use the getRequest().getParameterInfo().getWebParameterList() method of JCAPS' HttpServer class to get these values.

Other values we'll need, in addition to the test itself, is the queue/topic name where the test will be placed and the queue/topic where jcdUnitTester will listen for the response. Use the same technique described in the previous post to set the replyTo field in the JMS message.

This should be the minimum set of values we'll want to send to jcdUnitTester. Some other optional things I've found useful are parameters for debug level and any needed topic message selectors.

The final thing to create is the JUnit test themselves. Nothing to fancy here. I've used standard JUnit conventions (like the @Test annotation) to identify my test methods. The test methods use HtppUnit's PostMethodWebRequest (set to jcdUnitTester's URL) and setParameter() to set the request parameters.

Once the response returns, WebResponse's getText() method should hopefully provide the string that matches your expected result. Otherwise, you have a bug...

Comments

Popular posts from this blog

I Believe...

More stuff to get excited about

A few quick notes