@Test
public void testSetExceptionInfo() {

    // do setup.
    FlashMap flashMap = new FlashMap();
    mockRequest.setAttribute(DispatcherServlet.OUTPUT_FLASH_MAP_ATTRIBUTE,
            flashMap);
    SimpleMappingExceptionCodeResolver exceptionCodeResolver = new SimpleMappingExceptionCodeResolver();
    exceptionCodeResolver.setDefaultExceptionCode("defaultCode");
    testTarget.setExceptionCodeResolver(exceptionCodeResolver);
    ResultMessages resultMessages = ResultMessages.error().add("code001");
    BusinessException occurException = new BusinessException(resultMessages);
    // do test.
    testTarget.setExceptionInfo(occurException, mockRequest, mockResponse);
    // do assert.
    assertThat(mockRequest.getAttribute("exceptionCode").toString(), is(
            "defaultCode"));
    assertThat(mockResponse.getHeader("X-Exception-Code"), is(
            "defaultCode"));
    assertThat(resultMessages, is(flashMap.get(
            ResultMessages.DEFAULT_MESSAGES_ATTRIBUTE_NAME)));
}