@Test public void testErrorPageNotFound() throws Exception { CougarErrorHandler err = new CougarErrorHandler(); final HttpServletRequest request = mock(HttpServletRequest.class); Writer writer = new StringWriter(); err.writeErrorPage(request, writer, 1, null, false); assertEquals("", writer.toString()); }
@Override protected void writeErrorPage(HttpServletRequest request, Writer writer, int code, String message, boolean showStacks) throws IOException { LOGGER.debug("Finding error page for code %d", code); InputStream is = getClass().getResourceAsStream("/errorpages/"+code+".html"); if (is != null) { InputStreamReader reader = new InputStreamReader(is); try { int len; char[] buff = new char[BUFFSIZE]; while ((len = reader.read(buff, 0, BUFFSIZE)) != -1) { writer.write(buff, 0, len); } writer.flush(); } finally { reader.close(); } } }
CougarErrorHandler extends ErrorHandler { @Override protected void writeErrorPage(HttpServletRequest request, Writer writer, int code, String message, boolean showStacks) throws IOException { LOGGER.debug("Finding error page for code %d", code); InputStream is = getClass().getResourceAsStream("/errorpages/"+code+".html"); if (is != null) { InputStreamReader reader = new InputStreamReader(is); try { int len; char[] buff = new char[BUFFSIZE]; while ((len = reader.read(buff, 0, BUFFSIZE)) != -1) { writer.write(buff, 0, len); } writer.flush(); } finally { reader.close(); } } } }
CougarErrorHandler extends ErrorHandler { @Override protected void writeErrorPage(HttpServletRequest request, Writer writer, int code, String message, boolean showStacks) throws IOException { LOGGER.debug("Finding error page for code %d", code); InputStream is = getClass().getResourceAsStream("/errorpages/"+code+".html"); if (is != null) { InputStreamReader reader = new InputStreamReader(is); try { int len; char[] buff = new char[BUFFSIZE]; while ((len = reader.read(buff, 0, BUFFSIZE)) != -1) { writer.write(buff, 0, len); } writer.flush(); } finally { reader.close(); } } }  }
CougarErrorHandler extends ErrorHandler { @Override protected void writeErrorPage(HttpServletRequest request, Writer writer, int code, String message, boolean showStacks) throws IOException { LOGGER.debug("Finding error page for code %d", code); InputStream is = getClass().getResourceAsStream("/errorpages/"+code+".html"); if (is != null) { InputStreamReader reader = new InputStreamReader(is); try { int len; char[] buff = new char[BUFFSIZE]; while ((len = reader.read(buff, 0, BUFFSIZE)) != -1) { writer.write(buff, 0, len); } writer.flush(); } finally { reader.close(); } } }   }
CougarErrorHandler extends ErrorHandler { @Override protected void writeErrorPage(HttpServletRequest request, Writer writer, int code, String message, boolean showStacks) throws IOException { LOGGER.debug("Finding error page for code %d", code); InputStream is = getClass().getResourceAsStream("/errorpages/"+code+".html"); if (is != null) { InputStreamReader reader = new InputStreamReader(is); try { int len; char[] buff = new char[BUFFSIZE]; while ((len = reader.read(buff, 0, BUFFSIZE)) != -1) { writer.write(buff, 0, len); } writer.flush(); } finally { reader.close(); } } }   static final int BUFFSIZE; }