Archive for May 2007

Unit Testing SimpleFormController

I could not find this very easily searching Google. At first, I figured you could just set the formSubmission property to true but it is a read-only property. I ended up checking out AppFuse’s source code because I figured the solution would be there. It was a good guess. The trick is to make sure your MockHttpServletRequest is a POST when testing a form submission. Seems kind of obvious now =).



request = new MockMultipartHttpServletRequest();
request.setMethod(WebContentGenerator.METHOD_POST);