FastWriter fw = new FastWriter();
ResponseWriter rw = facesContext.getResponseWriter();
rw = rw.cloneWithWriter(fw);
facesContext.setResponseWriter(rw);
root.encodeAll(facesContext);
rw.flush();
String result = fw.toString();
Assert.assertTrue("Output should contain 'rightValue'", result.contains("rightValue"));
Assert.assertFalse("Output should not contain 'doNotPrintValue'", result.contains("doNotPrintValue"));