Example usage for org.springframework.web.servlet.mvc.support DefaultHandlerExceptionResolver DefaultHandlerExceptionResolver

List of usage examples for org.springframework.web.servlet.mvc.support DefaultHandlerExceptionResolver DefaultHandlerExceptionResolver

Introduction

In this page you can find the example usage for org.springframework.web.servlet.mvc.support DefaultHandlerExceptionResolver DefaultHandlerExceptionResolver.

Prototype

public DefaultHandlerExceptionResolver() 

Source Link

Document

Sets the #setOrder(int) order to #LOWEST_PRECEDENCE .

Usage

From source file:org.terasoluna.gfw.web.exception.HandlerExceptionResolverLoggingInterceptorTest.java

@Test
public void testInvoke_DefaultHandlerExceptionResolver_responseCode_2xx() throws Throwable {

    // do setup for test case.
    NullPointerException occurException = new NullPointerException("null pointer exception.");
    HttpServletResponse mockResponse = mock(HttpServletResponse.class);

    DefaultHandlerExceptionResolver resolver = new DefaultHandlerExceptionResolver();

    when(mockMethodInvocation.proceed()).thenReturn("viewname");
    when(mockMethodInvocation.getThis()).thenReturn(resolver);
    when(mockResponse.getStatus()).thenReturn(200);
    when(mockMethodInvocation.getArguments())
            .thenReturn(new Object[] { null, mockResponse, null, occurException });

    // do test./* www  .  jav  a2  s .  c o  m*/
    testTarget.invoke(mockMethodInvocation);

    // do assert.
    verify(mockExceptionLogger, times(1)).info((Exception) any());

}

From source file:org.terasoluna.gfw.web.exception.HandlerExceptionResolverLoggingInterceptorTest.java

@Test
public void testInvoke_responseCode_299() throws Throwable {

    // do setup for test case.
    NullPointerException occurException = new NullPointerException("null pointer exception.");
    HttpServletResponse mockResponse = mock(HttpServletResponse.class);

    DefaultHandlerExceptionResolver resolver = new DefaultHandlerExceptionResolver();

    when(mockMethodInvocation.proceed()).thenReturn("viewname");
    when(mockMethodInvocation.getThis()).thenReturn(resolver);
    when(mockResponse.getStatus()).thenReturn(299);
    when(mockMethodInvocation.getArguments())
            .thenReturn(new Object[] { null, mockResponse, null, occurException });

    // do test.//from  w  ww .  j a v a2s.  c  o  m
    testTarget.invoke(mockMethodInvocation);

    // do assert.
    verify(mockExceptionLogger, times(1)).info((Exception) any());

}