@Test public final void testWriteFileContentToResponseShouldWriteErrorMessageWhenPathIsAnInvalidFileName() throws IOException { given(messageFileReader.readFile("invalidfilename", path)).willReturn(null); underTest.writeFileContentToResponse(request, response, "invalidfilename", path); verify(response).setContentType("text/html"); verify(printWriter).write("Requested file not found."); verify(printWriter).flush(); verify(printWriter).close(); }
public void writeFileContentToResponse(final HttpServletRequest req, final HttpServletResponse resp, final String pathInfo, final Path path) throws IOException { String requestedFilename = pathInfo.substring(1); InputStream messageFileInputStream = messageFileReader.readFile(requestedFilename, path); if (messageFileExists(messageFileInputStream)) { writeFileToResponse(req, resp, requestedFilename, messageFileInputStream); } else { writeErrorToResponse(resp); } }
LogFileHandler { public void writeFileContentToResponse(final HttpServletRequest req, final HttpServletResponse resp, final String pathInfo, final Path path) throws IOException { String requestedFilename = pathInfo.substring(1); InputStream messageFileInputStream = messageFileReader.readFile(requestedFilename, path); if (messageFileExists(messageFileInputStream)) { writeFileToResponse(req, resp, requestedFilename, messageFileInputStream); } else { writeErrorToResponse(resp); } } }
LogFileHandler { public void writeFileContentToResponse(final HttpServletRequest req, final HttpServletResponse resp, final String pathInfo, final Path path) throws IOException { String requestedFilename = pathInfo.substring(1); InputStream messageFileInputStream = messageFileReader.readFile(requestedFilename, path); if (messageFileExists(messageFileInputStream)) { writeFileToResponse(req, resp, requestedFilename, messageFileInputStream); } else { writeErrorToResponse(resp); } }  }
LogFileHandler { public void writeFileContentToResponse(final HttpServletRequest req, final HttpServletResponse resp, final String pathInfo, final Path path) throws IOException { String requestedFilename = pathInfo.substring(1); InputStream messageFileInputStream = messageFileReader.readFile(requestedFilename, path); if (messageFileExists(messageFileInputStream)) { writeFileToResponse(req, resp, requestedFilename, messageFileInputStream); } else { writeErrorToResponse(resp); } }  void writeFileNamesToResponse(final HttpServletResponse resp, final Path path); void writeFileContentToResponse(final HttpServletRequest req, final HttpServletResponse resp, final String pathInfo, final Path path); }
LogFileHandler { public void writeFileContentToResponse(final HttpServletRequest req, final HttpServletResponse resp, final String pathInfo, final Path path) throws IOException { String requestedFilename = pathInfo.substring(1); InputStream messageFileInputStream = messageFileReader.readFile(requestedFilename, path); if (messageFileExists(messageFileInputStream)) { writeFileToResponse(req, resp, requestedFilename, messageFileInputStream); } else { writeErrorToResponse(resp); } }  void writeFileNamesToResponse(final HttpServletResponse resp, final Path path); void writeFileContentToResponse(final HttpServletRequest req, final HttpServletResponse resp, final String pathInfo, final Path path);  }