### Question:
RedirectedStreamServletResponseWrapper extends HttpServletResponseWrapper { @Override public void sendRedirect(final String location) throws IOException { try { LOG.debug("redirecting to: {}", location); final InputStream is = externalResourceLocator.locate(location); IOUtils.copy(is, servletOutputStream); is.close(); servletOutputStream.close(); } catch (final IOException e) { LOG.warn("{}: Invalid response for location: {}", e.getClass().getName(), location); throw e; } } RedirectedStreamServletResponseWrapper(final OutputStream outputStream, final HttpServletResponse response); @Override void sendError(final int sc); @Override void sendError(final int sc, final String msg); @Override void sendRedirect(final String location); @Override ServletOutputStream getOutputStream(); @Override void setStatus(final int sc); @Override PrintWriter getWriter();  }### Answer:
@Test public void shouldRedirectStreamWhenSendRedirectIsInvoked() throws Exception { final String message = "Hello world!"; victim = new RedirectedStreamServletResponseWrapper(redirectedStream, mockResponse) { @Override protected UriLocator newExternalResourceLocator() { return new ClasspathUriLocator() { @Override public InputStream locate(final String uri) throws IOException { return new ByteArrayInputStream(message.getBytes()); } }; } }; victim.sendRedirect("/does/not/matter"); assertEquals(message, new String(redirectedStream.toByteArray())); }