do not expose IOException

This commit is contained in:
Sebastian Sdorra
2018-08-30 11:03:15 +02:00
parent 5a22255a2b
commit f8df92ef7a
2 changed files with 18 additions and 1 deletions

View File

@@ -105,6 +105,14 @@ public class WebResourceServletTest {
verify(response).setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
@Test
public void testDoGetWithDispatcherException() throws IOException {
when(request.getRequestURI()).thenReturn("/scm/awesome.jpg");
doThrow(IOException.class).when(pushStateDispatcher).dispatch(request, response, "/awesome.jpg");
servlet.doGet(request, response);
verify(response).setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
private static class TestingOutputServletOutputStream extends ServletOutputStream {
private ByteArrayOutputStream buffer = new ByteArrayOutputStream();