UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
submit(button);
processLifecycleExecute();
CustomSessionBean sessionBean = facesContext.getApplication().evaluateExpressionGet(
facesContext, "#{customSessionBean}", CustomSessionBean.class);
// Here we change the value to show the section 1 part. If the refresh algorithm works,
// this part should be rendered
sessionBean.setShowSection1(true);
processRender();
Assert.assertNotNull(comp);
Assert.assertEquals(2, comp.getChildCount());
comp = facesContext.getViewRoot().findComponent("mainForm:panel");
Assert.assertEquals("value1", comp.getAttributes().get("attr1"));
Assert.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2"));
wrapper = comp.getChildren().get(1);
Assert.assertNotNull(wrapper);
Assert.assertTrue(UIComponent.isCompositeComponent(wrapper));
ccContent = wrapper.getFacet(UIComponent.COMPOSITE_FACET_NAME);
Assert.assertNotNull(ccContent);
Assert.assertEquals(3, ccContent.getChildCount());
//Assert.assertEquals("Dynamically added header",
// ccContent.getChildren().get(0).getFacet("header").getAttributes().get("value"));
Assert.assertEquals("Dynamically added child", ccContent.getChildren().get(2).getAttributes().get("value"));
MockPrintWriter writer2 = (MockPrintWriter) response.getWriter();
String content2 = new String(writer2.content());
Assert.assertTrue(content2.contains("Dynamically added markup"));
int indexDynHeader2_1 = content2.indexOf("Start Dynamic Header");
int indexDynHeader2_2 = content2.indexOf("Dynamically added header", indexDynHeader2_1);
int indexDynHeader2_3 = content2.indexOf("End Dynamic Header", indexDynHeader2_2);
Assert.assertNotSame(-1, indexDynHeader2_1);
Assert.assertNotSame(-1, indexDynHeader2_2);
Assert.assertNotSame(-1, indexDynHeader2_3);
Assert.assertTrue(content2.contains("This is section 1"));
button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
submit(button);
processLifecycleExecute();
sessionBean.setShowSection1(false);
processRender();
Assert.assertNotNull(comp);
Assert.assertEquals(2, comp.getChildCount());