@Test public void testWriteResourceFileWhenFileDoesNotExistShouldWriteErrorResponse() throws IOException { given(fileReader.readFile(FILE_NAME, path)).willReturn(null); given(response.getWriter()).willReturn(writer); underTest.writeResourceFile(response, PATH_INFO, path); verify(response).setContentType(HTML); verify(writer).write(FILE_NOT_FOUND_MSG); verify(writer).flush(); verify(writer).close(); }
public void writeResourceFile(final HttpServletResponse resp, final String path, final Path filePath) throws IOException { String requestedFilename = path.substring(1); InputStream messageFileInputStream = fileReader.readFile(requestedFilename, filePath); if (messageFileExists(messageFileInputStream)) { writeResourceFileInResponse(resp, requestedFilename, messageFileInputStream); } else { writeErrorToResponse(resp); } }
ResourceFileNameHandler { public void writeResourceFile(final HttpServletResponse resp, final String path, final Path filePath) throws IOException { String requestedFilename = path.substring(1); InputStream messageFileInputStream = fileReader.readFile(requestedFilename, filePath); if (messageFileExists(messageFileInputStream)) { writeResourceFileInResponse(resp, requestedFilename, messageFileInputStream); } else { writeErrorToResponse(resp); } } }
ResourceFileNameHandler { public void writeResourceFile(final HttpServletResponse resp, final String path, final Path filePath) throws IOException { String requestedFilename = path.substring(1); InputStream messageFileInputStream = fileReader.readFile(requestedFilename, filePath); if (messageFileExists(messageFileInputStream)) { writeResourceFileInResponse(resp, requestedFilename, messageFileInputStream); } else { writeErrorToResponse(resp); } }  }
ResourceFileNameHandler { public void writeResourceFile(final HttpServletResponse resp, final String path, final Path filePath) throws IOException { String requestedFilename = path.substring(1); InputStream messageFileInputStream = fileReader.readFile(requestedFilename, filePath); if (messageFileExists(messageFileInputStream)) { writeResourceFileInResponse(resp, requestedFilename, messageFileInputStream); } else { writeErrorToResponse(resp); } }  void writeResourceFile(final HttpServletResponse resp, final String path, final Path filePath); }
ResourceFileNameHandler { public void writeResourceFile(final HttpServletResponse resp, final String path, final Path filePath) throws IOException { String requestedFilename = path.substring(1); InputStream messageFileInputStream = fileReader.readFile(requestedFilename, filePath); if (messageFileExists(messageFileInputStream)) { writeResourceFileInResponse(resp, requestedFilename, messageFileInputStream); } else { writeErrorToResponse(resp); } }  void writeResourceFile(final HttpServletResponse resp, final String path, final Path filePath);  }