@Test public void testEncodeEnd() throws Exception { StringWriter writer = new StringWriter(); ResponseWriter testResponseWriter = new TestResponseWriter(writer); FacesContext facesContext = PowerMock.createPartialMockForAllMethodsExcept(FacesContext.class, "getCurrentInstance"); UIViewRoot viewRoot = PowerMock.createMock(UIViewRoot.class); Application application = PowerMock.createMock(Application.class); BodyRenderer bodyRenderer = new BodyRenderer(); HtmlBody htmlBody = new HtmlBody(); expect(facesContext.getApplication()).andReturn(application).anyTimes(); expect(facesContext.getClientIdsWithMessages()).andReturn(Collections.EMPTY_LIST.iterator()).anyTimes(); expect(facesContext.getResponseWriter()).andReturn(testResponseWriter).anyTimes(); expect(facesContext.getViewRoot()).andReturn(viewRoot).anyTimes(); expect(facesContext.isProjectStage(ProjectStage.Development)).andReturn(false).anyTimes(); expect(viewRoot.getComponentResources(facesContext, "body")).andReturn(Collections.EMPTY_LIST).anyTimes(); PowerMock.replay(facesContext, viewRoot, application); bodyRenderer.encodeEnd(facesContext, htmlBody); PowerMock.verify(facesContext, viewRoot, application); String html = writer.toString(); assertTrue(html.contains("</body>")); }
@Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); UIViewRoot viewRoot = context.getViewRoot(); ListIterator iter = (viewRoot.getComponentResources(context, "body")).listIterator(); while (iter.hasNext()) { UIComponent resource = (UIComponent)iter.next(); resource.encodeAll(context); } RenderKitUtils.renderUnhandledMessages(context); writer.endElement("body"); }
BodyRenderer extends HtmlBasicRenderer { @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); UIViewRoot viewRoot = context.getViewRoot(); ListIterator iter = (viewRoot.getComponentResources(context, "body")).listIterator(); while (iter.hasNext()) { UIComponent resource = (UIComponent)iter.next(); resource.encodeAll(context); } RenderKitUtils.renderUnhandledMessages(context); writer.endElement("body"); } }
BodyRenderer extends HtmlBasicRenderer { @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); UIViewRoot viewRoot = context.getViewRoot(); ListIterator iter = (viewRoot.getComponentResources(context, "body")).listIterator(); while (iter.hasNext()) { UIComponent resource = (UIComponent)iter.next(); resource.encodeAll(context); } RenderKitUtils.renderUnhandledMessages(context); writer.endElement("body"); }  }
BodyRenderer extends HtmlBasicRenderer { @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); UIViewRoot viewRoot = context.getViewRoot(); ListIterator iter = (viewRoot.getComponentResources(context, "body")).listIterator(); while (iter.hasNext()) { UIComponent resource = (UIComponent)iter.next(); resource.encodeAll(context); } RenderKitUtils.renderUnhandledMessages(context); writer.endElement("body"); }  @Override void decode(FacesContext context, UIComponent component); @Override void encodeBegin(FacesContext context, UIComponent component); @Override void encodeChildren(FacesContext context, UIComponent component); @Override void encodeEnd(FacesContext context, UIComponent component); @Override boolean getRendersChildren(); }
BodyRenderer extends HtmlBasicRenderer { @Override public void encodeEnd(FacesContext context, UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); UIViewRoot viewRoot = context.getViewRoot(); ListIterator iter = (viewRoot.getComponentResources(context, "body")).listIterator(); while (iter.hasNext()) { UIComponent resource = (UIComponent)iter.next(); resource.encodeAll(context); } RenderKitUtils.renderUnhandledMessages(context); writer.endElement("body"); }  @Override void decode(FacesContext context, UIComponent component); @Override void encodeBegin(FacesContext context, UIComponent component); @Override void encodeChildren(FacesContext context, UIComponent component); @Override void encodeEnd(FacesContext context, UIComponent component); @Override boolean getRendersChildren();  }