ServletUtil { public static IOException wrapServletException(ServletException ex, String message) { IOException retValue; Throwable rootCause = ex.getRootCause(); if (rootCause != null) { retValue = new IOException(message, rootCause); } else { retValue = new IOException(message, ex); } return retValue; } private  ServletUtil(); static IOException wrapServletException(ServletException ex,
            String message); static ApplicationContext getApplicationContext(ServletContext servletContext); static ServletRequest getServletRequest(Request request); static ServletContext getServletContext(ApplicationContext applicationContext);  }
@Test public void testWrapServletException() { ServletException servletException = new ServletException(); IOException exception = ServletUtil.wrapServletException(servletException, "my message"); assertEquals(servletException, exception.getCause()); assertEquals("my message", exception.getMessage()); }
@Test public void testWrapServletExceptionWithCause() { Throwable cause = createMock(Throwable.class); replay(cause); ServletException servletException = new ServletException(cause); IOException exception = ServletUtil.wrapServletException(servletException, "my message"); assertEquals(cause, exception.getCause()); assertEquals("my message", exception.getMessage()); verify(cause); }