经过一段时间的研究和尝试不同的事情后,我仍然无法在我的 jUnit 集成测试中调用我的 @ExceptionHandler。请帮我理解为什么?
@RequestMapping(value = "/someURL", method = RequestMethod.POST)
public ModelAndView batchUpload(@RequestBody final String xml, @RequestParam boolean replaceAll)
throws IOException, URISyntaxException, SAXException, ParserConfigurationException, InvocationTargetException, IllegalAccessException, UnmarshallingFailureException
{
StreamSource source = new StreamSource(new StringReader(xml));
DomainClass xmlDomainClass;
try
{
xmlDomainClass = (DomainClass) castorMarshaller.unmarshal(source);
}
catch (UnmarshallingFailureException me)
{
// some logging. this gets executed
throw me;
}
.
@ExceptionHandler(Throwable.class)
public ModelAndView handleUnmarshallingExceptions(Throwable th)
{
// never executes anything in here
return new ModelAndView( /*some parameters */ );
}