@Test
public void throwsUnhandledExceptionWithWebApplicationExceptionWhenJspErrorPageForWebApplicationExceptionIsAvailable() throws Exception {

    ErrorPages errorPages = mock(ErrorPages.class);
    WebApplicationException webApplicationException = new WebApplicationException();
    when(errorPages.hasErrorPage(webApplicationException)).thenReturn(true);
    when(environmentContext.get(ErrorPages.class)).thenReturn(errorPages);
    doThrow(webApplicationException).when(requestDispatcher).dispatch(request, response);
    thrown.expect(UnhandledException.class);
    thrown.expectCause(exceptionSameInstanceMatcher(webApplicationException));
    requestHandler.handleRequest(request, response);
}