ResponseWriter { public void writeSuccessfulResponse(String content) { writer.println("HTTP/1.0 200 OK"); writer.println("Content-type: application/json"); appendResponseCommon(content); } ResponseWriter(PrintWriter writer); void writeNotFoundResponse(String line); void writeSuccessfulResponse(String content); void writeErrorResponse(Exception e);  }
@Test public void writeSuccessfulResponse() { String content = "test content"; String expectedMessage = "HTTP/1.0 200 OK" + newLine + "Content-type: application/json" + newLine + responseCommon + content + newLine; testSubject.writeSuccessfulResponse(content); String writtenMessage = stringWriter.toString(); Assert.assertEquals(writtenMessage, expectedMessage); }