Assert.assertTrue(UIComponent.isCompositeComponent(wrapper));
UIComponent 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 writer1 = (MockPrintWriter) response.getWriter();
String content1 = new String(writer1.content());
Assert.assertTrue(content1.contains("Dynamically added markup"));
int indexDynHeader1_1 = content1.indexOf("Start Dynamic Header");
int indexDynHeader1_2 = content1.indexOf("Dynamically added header", indexDynHeader1_1);
int indexDynHeader1_3 = content1.indexOf("End Dynamic Header", indexDynHeader1_2);
Assert.assertNotSame(-1, indexDynHeader1_1);
Assert.assertNotSame(-1, indexDynHeader1_2);
Assert.assertNotSame(-1, indexDynHeader1_3);
UIComponent ccpanel = facesContext.getViewRoot().findComponent("mainForm:ccpanel");
Assert.assertNotNull(ccpanel);
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();
client.submit(button);
processLifecycleExecute();
Assert.assertEquals("event not called", oldcount1+1, checkBean.getActionListenerCount());
renderResponse();
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();
client.submit(button);
processLifecycleExecute();
Assert.assertEquals("event not called", oldcount2+1, checkBean.getActionListenerCount());
renderResponse();
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 writer3 = (MockPrintWriter) response.getWriter();
String content3 = new String(writer3.content());
Assert.assertTrue(content3.contains("Dynamically added markup"));
int indexDynHeader3_1 = content3.indexOf("Start Dynamic Header");
int indexDynHeader3_2 = content3.indexOf("Dynamically added header", indexDynHeader3_1);
int indexDynHeader3_3 = content3.indexOf("End Dynamic Header", indexDynHeader3_2);
Assert.assertNotSame(-1, indexDynHeader3_1);