Ill try to explain some more.
I need to test a method called
Code:
view.buildDocument(map,null,null);
Where buildDocument takes the ModelAndView map as input.
As everything else is mocked, there is no ServletRequest or anything like it, also no validation has been done.
You would like to test if the view renders BindingErrors correctly. Therefore I would like to create a BindException myself. I think I'm misunderstanding the constructor of BindException.
The code that generates the XML for errors I need to test is:
Code:
List errors = ex.getFieldErrors(name);
for (Iterator it = errors.iterator(); it.hasNext();) {
FieldError error = (FieldError) it.next();
Element errorElement = new Element("error");
//add the error message
Element errorMessage = new Element("errorMessage");
errorMessage.addContent(error.toString());
errorElement.addContent(errorMessage);
.......
So I want to fill the FieldErrors of BindException for testing.