@Test public void shouldReturnStatus500WithViewResolutionExceptionCauseMessage() throws IOException { Exception cause = new Exception("cause"); Throwable viewResult = new ViewResolutionException(cause, "ViewResolutionMessage"); resolver.resolve(req, resp, viewResult); verify(resp).sendError(Mockito.eq(500), Mockito.startsWith("ViewResolutionMessage\ncause")); }
@Test public void shouldReturnStatus500() throws IOException { Exception cause = new Exception("cause"); Throwable viewResult = new Exception("message", cause); resolver.resolve(req, resp, viewResult); verify(resp) .sendError( Mockito.eq(500), Mockito.startsWith("message\ncause\njava.lang.Exception: message")); }
@Test public void shouldReturnStatus500WithViewResolutionExceptionBecauseNoCauseIsProvided() throws IOException { Throwable viewResult = new ViewResolutionException("message"); resolver.resolve(req, resp, viewResult); verify(resp) .sendError( Mockito.eq(500), Mockito.startsWith( "message\ncom.threewks.thundr.view.ViewResolutionException: message")); }
@Test public void shouldSwallowAnyIOExceptionsDuringViewResolution() throws IOException { ViewResolutionException viewResult = mock(ViewResolutionException.class); doThrow(new IOException("intentional")).when(resp).sendError(anyInt(), anyString()); resolver.resolve(req, resp, viewResult); }