ByteArrayOutputStream ostrWriter = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(ostrWriter);
ServletOutputStreamMock sOstr = new ServletOutputStreamMock(ostr);
NewStreamingMockResponse resp = new NewStreamingMockResponse(response, sOstr, writer);
FacesContext context = new FacesContextImpl(servletContext, request, resp);
ResponseWriter responseWriter = context.getResponseWriter();
if (responseWriter == null) {
try {
responseWriter = new MockResponseWriter(((ServletResponse) context.getExternalContext().getResponse()).getWriter(), null, null);
} catch (IOException ex) {
super.fail(ex.getMessage());
}
context.setResponseWriter(responseWriter);
}
assertTrue("responsewriter not null", responseWriter != null);