ResponseWriter { public void writeNotFoundResponse(String line) { final String content = "<b>404</b> This service can't process <i>" + line + "</i>"; writer.println("HTTP/1.0 404 File Not Found"); writer.println("Content-type: text/html; charset=UTF-8"); appendResponseCommon(content); } ResponseWriter(PrintWriter writer); void writeNotFoundResponse(String line); void writeSuccessfulResponse(String content); void writeErrorResponse(Exception e);  }
@Test public void writeNotFoundResponse() { String requestLine = "test request line"; String expectedMessage = "HTTP/1.0 404 File Not Found" + newLine + "Content-type: text/html; charset=UTF-8" + newLine + responseCommon + "<b>404</b> This service can't process <i>" + requestLine + "</i>" + newLine; testSubject.writeNotFoundResponse(requestLine); String writtenMessage = stringWriter.toString(); Assert.assertEquals(writtenMessage, expectedMessage); }