UIComponent ccinnerpanel = facesContext.getViewRoot().findComponent("mainForm:ccpanel:component");
Assert.assertNotNull(ccinnerpanel);
UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:ccpanel:component:increment");
Assert.assertNotNull(button);
CheckActionEventBean checkBean = facesContext.getApplication().evaluateExpressionGet(facesContext,
"#{checkActionEventBean}", CheckActionEventBean.class);
int oldcount1 = checkBean.getActionListenerCount();
submit(button);
processLifecycleExecute();
Assert.assertEquals("event not called", oldcount1+1, checkBean.getActionListenerCount());
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 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);
button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:ccpanel:component:increment");
Assert.assertNotNull(button);
int oldcount2 = checkBean.getActionListenerCount();
submit(button);
processLifecycleExecute();
Assert.assertEquals("event not called", oldcount2+1, checkBean.getActionListenerCount());
processRender();
Assert.assertNotNull(comp);
Assert.assertEquals(2, comp.getChildCount());