@Test
public void throwsUnhandledExceptionWithCauseOfInternalExceptionWhenJspErrorPageForCauseIsAvailable() throws Exception {

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