@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); }
@Override public void handleRequest(GenericContainerRequest request, GenericContainerResponse response) throws IOException { final ApplicationContext context = ApplicationContext.getCurrent(); try { for (RequestFilter filter : providers.getRequestFilters(context.getPath())) { filter.doFilter(request); } dispatcher.dispatch(request, response); setupInternalResponseHeaders(response.getStatus(), response.getHttpHeaders()); for (ResponseFilter filter : providers.getResponseFilters(context.getPath())) { filter.doFilter(response); } } catch (Exception e) { if (e instanceof WebApplicationException) { handleWebApplicationException((WebApplicationException)e, response); } else if (e instanceof InternalException) { handleInternalException((InternalException)e, response); } else { throw new UnhandledException(e); } } response.writeResponse(); }
RequestHandlerImpl implements RequestHandler { @Override public void handleRequest(GenericContainerRequest request, GenericContainerResponse response) throws IOException { final ApplicationContext context = ApplicationContext.getCurrent(); try { for (RequestFilter filter : providers.getRequestFilters(context.getPath())) { filter.doFilter(request); } dispatcher.dispatch(request, response); setupInternalResponseHeaders(response.getStatus(), response.getHttpHeaders()); for (ResponseFilter filter : providers.getResponseFilters(context.getPath())) { filter.doFilter(response); } } catch (Exception e) { if (e instanceof WebApplicationException) { handleWebApplicationException((WebApplicationException)e, response); } else if (e instanceof InternalException) { handleInternalException((InternalException)e, response); } else { throw new UnhandledException(e); } } response.writeResponse(); } }
RequestHandlerImpl implements RequestHandler { @Override public void handleRequest(GenericContainerRequest request, GenericContainerResponse response) throws IOException { final ApplicationContext context = ApplicationContext.getCurrent(); try { for (RequestFilter filter : providers.getRequestFilters(context.getPath())) { filter.doFilter(request); } dispatcher.dispatch(request, response); setupInternalResponseHeaders(response.getStatus(), response.getHttpHeaders()); for (ResponseFilter filter : providers.getResponseFilters(context.getPath())) { filter.doFilter(response); } } catch (Exception e) { if (e instanceof WebApplicationException) { handleWebApplicationException((WebApplicationException)e, response); } else if (e instanceof InternalException) { handleInternalException((InternalException)e, response); } else { throw new UnhandledException(e); } } response.writeResponse(); } RequestHandlerImpl(RequestDispatcher dispatcher, ProviderBinder providers); }
RequestHandlerImpl implements RequestHandler { @Override public void handleRequest(GenericContainerRequest request, GenericContainerResponse response) throws IOException { final ApplicationContext context = ApplicationContext.getCurrent(); try { for (RequestFilter filter : providers.getRequestFilters(context.getPath())) { filter.doFilter(request); } dispatcher.dispatch(request, response); setupInternalResponseHeaders(response.getStatus(), response.getHttpHeaders()); for (ResponseFilter filter : providers.getResponseFilters(context.getPath())) { filter.doFilter(response); } } catch (Exception e) { if (e instanceof WebApplicationException) { handleWebApplicationException((WebApplicationException)e, response); } else if (e instanceof InternalException) { handleInternalException((InternalException)e, response); } else { throw new UnhandledException(e); } } response.writeResponse(); } RequestHandlerImpl(RequestDispatcher dispatcher, ProviderBinder providers); @Override void handleRequest(GenericContainerRequest request, GenericContainerResponse response); @Override ProviderBinder getProviders(); @Override ResourceBinder getResources(); }
RequestHandlerImpl implements RequestHandler { @Override public void handleRequest(GenericContainerRequest request, GenericContainerResponse response) throws IOException { final ApplicationContext context = ApplicationContext.getCurrent(); try { for (RequestFilter filter : providers.getRequestFilters(context.getPath())) { filter.doFilter(request); } dispatcher.dispatch(request, response); setupInternalResponseHeaders(response.getStatus(), response.getHttpHeaders()); for (ResponseFilter filter : providers.getResponseFilters(context.getPath())) { filter.doFilter(response); } } catch (Exception e) { if (e instanceof WebApplicationException) { handleWebApplicationException((WebApplicationException)e, response); } else if (e instanceof InternalException) { handleInternalException((InternalException)e, response); } else { throw new UnhandledException(e); } } response.writeResponse(); } RequestHandlerImpl(RequestDispatcher dispatcher, ProviderBinder providers); @Override void handleRequest(GenericContainerRequest request, GenericContainerResponse response); @Override ProviderBinder getProviders(); @Override ResourceBinder getResources();  }