### Question:
MessagesServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { try(ServletOutputStream out = resp.getOutputStream()) { for (String message : messages) out.println(message); } }    }### Answer:
@Test public void whenServletInvoked_responseDisplaysRecentExchanges() throws IOException { IntStream.rangeClosed(1, MAX_EXCHANGES).forEach(this::addTestExchange); servlet.doGet(request, response); assertThat(response.getHtml(), containsString("request 4")); }