List of usage examples for org.springframework.web.servlet.handler SimpleMappingExceptionResolver DEFAULT_EXCEPTION_ATTRIBUTE
String DEFAULT_EXCEPTION_ATTRIBUTE
To view the source code for org.springframework.web.servlet.handler SimpleMappingExceptionResolver DEFAULT_EXCEPTION_ATTRIBUTE.
Click Source Link
From source file:org.terasoluna.gfw.web.exception.SystemExceptionResolverTest.java
@Test public void testDoResolveException_super_return_notnull() throws Exception { // do setup.//www . j a va 2s. c o m ResultMessages resultMessages = ResultMessages.error().add("code001"); BusinessException occurException = new BusinessException(resultMessages); // setup locale. Locale locale = Locale.ITALIAN; mockRequest.addPreferredLocale(locale); // setup FlashMap. FlashMap flashMap = new FlashMap(); mockRequest.setAttribute(DispatcherServlet.OUTPUT_FLASH_MAP_ATTRIBUTE, flashMap); // setup exception resolver. // setup default. testTarget.setDefaultErrorView("defaultErrorView"); testTarget.setDefaultStatusCode(444); // setup exception code resolver. SimpleMappingExceptionCodeResolver exceptionCodeResolver = new SimpleMappingExceptionCodeResolver(); exceptionCodeResolver.setDefaultExceptionCode("defaultExceptionCode"); testTarget.setExceptionCodeResolver(exceptionCodeResolver); // do test. ModelAndView actualModleAndView = testTarget.doResolveException(mockRequest, mockResponse, null, occurException); // do assert. assertThat(mockResponse.getStatus(), is(444)); assertThat((Integer) mockRequest.getAttribute(WebUtils.ERROR_STATUS_CODE_ATTRIBUTE), is(444)); assertSame(occurException, actualModleAndView.getModel().get(SimpleMappingExceptionResolver.DEFAULT_EXCEPTION_ATTRIBUTE)); assertThat(mockRequest.getAttribute("exceptionCode").toString(), is("defaultExceptionCode")); assertThat(mockResponse.getHeader("X-Exception-Code"), is("defaultExceptionCode")); assertSame(resultMessages, flashMap.get(ResultMessages.DEFAULT_MESSAGES_ATTRIBUTE_NAME)); }