View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.view.facelets.pss.acid;
20  
21  import javax.faces.application.StateManager;
22  import javax.faces.component.UICommand;
23  import javax.faces.component.UIComponent;
24  import javax.faces.component.UIInput;
25  import javax.faces.component.UIPanel;
26  import javax.faces.component.html.HtmlDataTable;
27  
28  import junit.framework.Assert;
29  
30  import org.apache.myfaces.mc.test.core.AbstractMyFacesRequestTestCase;
31  import org.apache.myfaces.shared.config.MyfacesConfig;
32  import org.apache.myfaces.view.facelets.pss.acid.managed.ResourceDependencyBean;
33  import org.junit.Test;
34  
35  public class AcidMyFacesRequestTestCase extends AbstractMyFacesRequestTestCase
36  {
37  
38      @Override
39      protected boolean isScanAnnotations()
40      {
41          return true;
42      }
43  
44      @Override
45      protected void setUpWebConfigParams() throws Exception
46      {
47          super.setUpWebConfigParams();
48          servletContext.addInitParameter("org.apache.myfaces.annotation.SCAN_PACKAGES","org.apache.myfaces.view.facelets.pss.acid");
49          servletContext.addInitParameter("javax.faces.FACELETS_LIBRARIES", "/WEB-INF/testcomponent.taglib.xml");
50          servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.STATE_SAVING_METHOD_CLIENT);
51          servletContext.addInitParameter("javax.faces.PARTIAL_STATE_SAVING", "true");
52          servletContext.addInitParameter(MyfacesConfig.INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS, "auto");
53      }
54      
55      @Test
56      public void testIndex() throws Exception
57      {
58          setupRequest("/index.xhtml");
59          processLifecycleExecuteAndRender();
60          
61          UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
62          Assert.assertEquals(1, comp.getChildCount());
63          Assert.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value"));
64          
65          /*
66          MockPrintWriter writer1 = (MockPrintWriter) response.getWriter();
67          Assert.assertTrue(new String(writer1.content()).contains(
68                  "<div style=\"border: 1px solid red; margin: 2px\">" +
69                  "<div style=\"background-color: #ffc0c0; padding: 2px; margin-bottom: 5px; display:block\">" +
70                  "TestComponent::encodeBegin <span style=\"color: #888888\">(1 children)</span>" +
71                  "</div>" +
72                  "Dynamically added child" +
73                  "<div style=\"background-color: #ffc0c0; padding: 2px; margin-top: 5px; display:block\">TestComponent::encodeEnd</div></div>"));
74                  */
75          //System.out.println(writer1.content());
76          UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
77          submit(button);
78          processLifecycleExecuteAndRender();
79          
80          comp = facesContext.getViewRoot().findComponent("mainForm:component");
81          Assert.assertEquals(1, comp.getChildCount());
82          Assert.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value"));
83          /*
84          MockPrintWriter writer2 = (MockPrintWriter) response.getWriter();
85          Assert.assertTrue(new String(writer2.content()).contains(
86                  "<div style=\"border: 1px solid red; margin: 2px\">" +
87                  "<div style=\"background-color: #ffc0c0; padding: 2px; margin-bottom: 5px; display:block\">" +
88                  "TestComponent::encodeBegin <span style=\"color: #888888\">(1 children)</span>" +
89                  "</div>" +
90                  "Dynamically added child" +
91                  "<div style=\"background-color: #ffc0c0; padding: 2px; margin-top: 5px; display:block\">TestComponent::encodeEnd</div></div>"));
92                  */
93          //System.out.println(writer2.content());
94          tearDownRequest();
95      }
96      
97      @Test
98      public void testInput() throws Exception
99      {
100         setupRequest("/input.xhtml");
101         processLifecycleExecuteAndRender();
102         UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
103         
104         Assert.assertEquals(1, comp.getChildCount());
105         Assert.assertEquals(1, comp.getChildren().get(0).getChildCount());
106         Assert.assertEquals("mainForm:input", comp.getChildren().get(0).getChildren().get(0).getClientId(facesContext));
107         /*
108         MockPrintWriter writer1 = (MockPrintWriter) response.getWriter();
109         Assert.assertTrue(new String(writer1.content()).contains(
110                "<div style=\"border: 1px solid red; margin: 2px\">" +
111                "<div style=\"background-color: #ffc0c0; padding: 2px; margin-bottom: 5px; display:block\">" +
112                "TestComponent::encodeBegin <span style=\"color: #888888\">(1 children)</span>" +
113                "</div>" +
114                "<span style=\"border: 1px dashed blue; padding: 5px; margin: 5px\">" +
115                "<input id=\"mainForm:input\" name=\"mainForm:input\" type=\"text\" value=\"Foo\" style=\"background-color: red\" />" +
116                "</span>" +
117                "<div style=\"background-color: #ffc0c0; padding: 2px; margin-top: 5px; display:block\">TestComponent::encodeEnd</div></div>"));
118                */
119         //System.out.println(writer1.content());
120         UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
121         submit(button);
122         processLifecycleExecuteAndRender();
123 
124         comp = facesContext.getViewRoot().findComponent("mainForm:component");
125         Assert.assertEquals(1, comp.getChildCount());
126         Assert.assertEquals(1, comp.getChildren().get(0).getChildCount());
127         Assert.assertEquals("mainForm:input", comp.getChildren().get(0).getChildren().get(0).getClientId(facesContext));
128 
129         /*
130         MockPrintWriter writer2 = (MockPrintWriter) response.getWriter();
131         System.out.println(writer2.content());
132         Assert.assertTrue(new String(writer2.content()).contains(
133                 "<div style=\"border: 1px solid red; margin: 2px\">" +
134                 "<div style=\"background-color: #ffc0c0; padding: 2px; margin-bottom: 5px; display:block\">" +
135                 "TestComponent::encodeBegin <span style=\"color: #888888\">(1 children)</span>" +
136                 "</div>" +
137                 "<span style=\"border: 1px dashed blue; padding: 5px; margin: 5px\">" +
138                 "<input id=\"mainForm:input\" name=\"mainForm:input\" type=\"text\" value=\"Foo\" style=\"background-color: red\" />" +
139                 "</span>" +
140                 "<div style=\"background-color: #ffc0c0; padding: 2px; margin-top: 5px; display:block\">TestComponent::encodeEnd</div></div>"));
141                 */
142     }
143     
144     @Test
145     public void testRecursive() throws Exception
146     {
147         setupRequest("/recursive.xhtml");
148         processLifecycleExecuteAndRender();
149         UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
150         Assert.assertEquals(2, comp.getChildCount());
151         Assert.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value"));
152         Assert.assertEquals(1, comp.getChildren().get(1).getChildCount());
153         Assert.assertEquals("Dynamically added child", comp.getChildren().get(1).getChildren().get(0).getAttributes().get("value"));
154         
155         UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
156         submit(button);
157         processLifecycleExecuteAndRender();
158         
159         comp = facesContext.getViewRoot().findComponent("mainForm:component");
160         Assert.assertEquals(2, comp.getChildCount());
161         Assert.assertEquals("Dynamically added child", comp.getChildren().get(0).getAttributes().get("value"));
162         Assert.assertEquals(1, comp.getChildren().get(1).getChildCount());
163         Assert.assertEquals("Dynamically added child", comp.getChildren().get(1).getChildren().get(0).getAttributes().get("value"));
164         
165         tearDownRequest();
166     }
167     
168     @Test
169     public void testStable() throws Exception
170     {
171         setupRequest("/stable.xhtml");
172         processLifecycleExecuteAndRender();
173         UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
174         Assert.assertEquals(3, comp.getChildCount());
175         Assert.assertEquals("1", comp.getChildren().get(0).getAttributes().get("value"));
176         Assert.assertEquals("2", comp.getChildren().get(1).getAttributes().get("value"));
177         Assert.assertEquals("text3", comp.getChildren().get(2).getId());
178         
179         UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
180         submit(button);
181         processLifecycleExecuteAndRender();
182         
183         comp = facesContext.getViewRoot().findComponent("mainForm:component");
184         Assert.assertEquals(3, comp.getChildCount());
185         Assert.assertEquals("1", comp.getChildren().get(0).getAttributes().get("value"));
186         Assert.assertEquals("2", comp.getChildren().get(1).getAttributes().get("value"));
187         Assert.assertEquals("text3", comp.getChildren().get(2).getId());
188         
189         button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
190         submit(button);
191         processLifecycleExecuteAndRender();
192         
193         comp = facesContext.getViewRoot().findComponent("mainForm:component");
194         Assert.assertEquals(3, comp.getChildCount());
195         Assert.assertEquals("1", comp.getChildren().get(0).getAttributes().get("value"));
196         Assert.assertEquals("2", comp.getChildren().get(1).getAttributes().get("value"));
197         Assert.assertEquals("text3", comp.getChildren().get(2).getId());
198 
199         button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
200         UIInput input = (UIInput) facesContext.getViewRoot().findComponent("mainForm:text3");
201         inputText(input, "3");
202         submit(button);
203         processLifecycleExecuteAndRender();
204         
205         comp = facesContext.getViewRoot().findComponent("mainForm:component");
206         Assert.assertEquals(3, comp.getChildCount());
207         Assert.assertEquals("1", comp.getChildren().get(0).getAttributes().get("value"));
208         Assert.assertEquals("2", comp.getChildren().get(1).getAttributes().get("value"));
209         Assert.assertEquals("text3", comp.getChildren().get(2).getId());
210         
211     }
212     
213     @Test
214     public void testTable() throws Exception
215     {
216         setupRequest("/table.xhtml");
217         processLifecycleExecuteAndRender();
218         
219         UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
220         Assert.assertEquals(1, comp.getChildCount());
221         HtmlDataTable dataTable = (HtmlDataTable) comp.getChildren().get(0);
222         Assert.assertEquals(1, dataTable.getChildCount());
223 
224         UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
225         submit(button);
226         processLifecycleExecuteAndRender();
227 
228         comp = facesContext.getViewRoot().findComponent("mainForm:component");
229         Assert.assertEquals(1, comp.getChildCount());
230         dataTable = (HtmlDataTable) comp.getChildren().get(0);
231         Assert.assertEquals(1, dataTable.getChildCount());
232     }
233     
234     @Test
235     public void testToggle() throws Exception
236     {
237         setupRequest("/toggle.xhtml");
238         processLifecycleExecuteAndRender();
239         
240         UIComponent comp = facesContext.getViewRoot().findComponent("mainForm:component");
241         Assert.assertEquals(2, comp.getChildCount());
242         Assert.assertEquals("Manually added child 2<br/>", comp.getChildren().get(0).getAttributes().get("value"));
243         Assert.assertEquals("Manually added child 1<br/>", comp.getChildren().get(1).getAttributes().get("value"));
244 
245         UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
246         submit(button);
247         processLifecycleExecuteAndRender();
248 
249         comp = facesContext.getViewRoot().findComponent("mainForm:component");
250         Assert.assertEquals(2, comp.getChildCount());
251         Assert.assertEquals("Manually added child 1<br/>", comp.getChildren().get(0).getAttributes().get("value"));
252         Assert.assertEquals("Manually added child 2<br/>", comp.getChildren().get(1).getAttributes().get("value"));
253         
254         button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
255         submit(button);
256         processLifecycleExecuteAndRender();
257         
258         comp = facesContext.getViewRoot().findComponent("mainForm:component");
259         Assert.assertEquals(2, comp.getChildCount());
260         Assert.assertEquals("Manually added child 2<br/>", comp.getChildren().get(0).getAttributes().get("value"));
261         Assert.assertEquals("Manually added child 1<br/>", comp.getChildren().get(1).getAttributes().get("value"));
262         
263         button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
264         submit(button);
265         processLifecycleExecuteAndRender();
266         
267         comp = facesContext.getViewRoot().findComponent("mainForm:component");
268         Assert.assertEquals(2, comp.getChildCount());
269         Assert.assertEquals("Manually added child 1<br/>", comp.getChildren().get(0).getAttributes().get("value"));
270         Assert.assertEquals("Manually added child 2<br/>", comp.getChildren().get(1).getAttributes().get("value"));
271         
272     }
273     
274     @Test
275     public void testInclude() throws Exception
276     {
277         setupRequest("/include.xhtml");
278         processLifecycleExecute();
279         //Build the view
280         facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(
281                 facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot());
282         //Set a token to save on the state as delta
283         UIComponent component = facesContext.getViewRoot().findComponent("mainForm:component1");
284         component.getAttributes().put("test", "test1");
285         processRender();
286         
287         UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page1");
288         submit(button);
289         processLifecycleExecute();
290         //Check it is restored
291         component = facesContext.getViewRoot().findComponent("mainForm:component1");
292         Assert.assertEquals("test1", component.getAttributes().get("test"));
293         processRender();
294         //Check buildView does not destroy the state
295         component = facesContext.getViewRoot().findComponent("mainForm:component1");
296         Assert.assertEquals("test1", component.getAttributes().get("test"));
297         
298         //Go to page2
299         button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2");
300         submit(button);
301         
302         processLifecycleExecute();
303         component = facesContext.getViewRoot().findComponent("mainForm:component1");
304         //Check it is restored
305         Assert.assertEquals("test1", component.getAttributes().get("test"));
306         
307         //Build the view
308         facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(
309                 facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot());
310 
311         //Check the page was changed and the state discarded, because it is a different component.
312         component = facesContext.getViewRoot().findComponent("mainForm:component2");
313         Assert.assertNull(component.getAttributes().get("test"));
314         //Set a token to save on the state as delta
315         component.getAttributes().put("test", "test2");
316         processRender();
317         
318         component = facesContext.getViewRoot().findComponent("mainForm:component2");
319         Assert.assertEquals("test2", component.getAttributes().get("test"));
320 
321         button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2");
322         submit(button);
323         
324         processLifecycleExecute();
325         component = facesContext.getViewRoot().findComponent("mainForm:component2");
326         //Check it is restored
327         Assert.assertNotNull("mainForm:component2 was not restored correctly",component);
328         Assert.assertEquals("test2", component.getAttributes().get("test"));
329         
330         //Build the view
331         facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(
332                 facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot());
333 
334         //Check buildView does not destroy the state
335         component = facesContext.getViewRoot().findComponent("mainForm:component2");
336         Assert.assertEquals("test2", component.getAttributes().get("test"));
337         
338         button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2");
339         submit(button);
340 
341         processLifecycleExecute();
342         component = facesContext.getViewRoot().findComponent("mainForm:component2");
343         //Check it is restored
344         Assert.assertEquals("test2", component.getAttributes().get("test"));
345     }
346 
347     /**
348      * Same as testInclude, but only check the component is restored correctly.
349      * Since there is no delta, no state is saved unless it is necessary.
350      * 
351      * @throws Exception
352      */
353     @Test
354     public void testInclude2() throws Exception
355     {
356         setupRequest("/include.xhtml");
357         processLifecycleExecute();
358         //Build the view
359         facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(
360                 facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot());
361         //Set a token to save on the state as delta
362         UIComponent component = facesContext.getViewRoot().findComponent("mainForm:component1");
363         Assert.assertNotNull(component);
364         processRender();
365         
366         UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page1");
367         submit(button);
368         
369         processLifecycleExecute();
370         //Check it is restored
371         component = facesContext.getViewRoot().findComponent("mainForm:component1");
372         Assert.assertNotNull(component);
373         processRender();
374         //Check buildView does not destroy the state
375         component = facesContext.getViewRoot().findComponent("mainForm:component1");
376         Assert.assertNotNull(component);
377         
378         //Go to page2
379         button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2");
380         submit(button);
381         
382         processLifecycleExecute();
383         component = facesContext.getViewRoot().findComponent("mainForm:component1");
384         //Check it is restored
385         Assert.assertNotNull(component);
386         
387         //Build the view
388         facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(
389                 facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot());
390 
391         //Check the page was changed and the state discarded, because it is a different component.
392         component = facesContext.getViewRoot().findComponent("mainForm:component2");
393         Assert.assertNotNull(component);
394         processRender();
395         
396         component = facesContext.getViewRoot().findComponent("mainForm:component2");
397         Assert.assertNotNull(component);
398 
399         button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2");
400         submit(button);
401         
402         processLifecycleExecute();
403         component = facesContext.getViewRoot().findComponent("mainForm:component2");
404         //Check it is restored
405         Assert.assertNotNull(component);
406         
407         //Build the view
408         facesContext.getApplication().getViewHandler().getViewDeclarationLanguage(
409                 facesContext, facesContext.getViewRoot().getViewId()).buildView(facesContext, facesContext.getViewRoot());
410 
411         //Check buildView does not destroy the state
412         component = facesContext.getViewRoot().findComponent("mainForm:component2");
413         Assert.assertNotNull(component);
414         
415         button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:page2");
416         submit(button);
417 
418         processLifecycleExecute();
419         component = facesContext.getViewRoot().findComponent("mainForm:component2");
420         //Check it is restored
421         Assert.assertNotNull(component);
422     }
423     
424     /**
425      * Check if a dynamic subtree can be created from a binding property, and if it
426      * will be preserved across request. 
427      * 
428      * The idea is just inject a subtree using some code like this:
429      * <code>&lt;h:panelGroup id="panel" binding="#{componentBindingBean.panel}"&gt;</code>
430      * 
431      * The solution is if a binding returns a component that has children or facets
432      * attached, it is not elegible for PSS algorithm because the additional components
433      * are created outside facelets control, and there is no warrant that the same structure
434      * will be generated across requests, violating PSS base principle (it is possible to
435      * restore to the initial state calling vdl.buildView).
436      * 
437      * This test is here because all state saving modes should support this method.
438      * 
439      * @throws Exception 
440      */
441     @Test
442     public void testComponentBinding() throws Exception
443     {
444         setupRequest("/componentBinding1.xhtml");
445         processLifecycleExecuteAndRender();
446         
447         UIComponent comp = facesContext.getViewRoot().findComponent("panel");
448         Assert.assertNotNull(comp);
449         Assert.assertEquals(1, comp.getChildCount());
450         
451         UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
452         submit(button);
453         processLifecycleExecuteAndRender();
454         
455         comp = facesContext.getViewRoot().findComponent("panel");
456         
457         Assert.assertEquals("value1", comp.getAttributes().get("attr1"));
458         Assert.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2"));
459         
460         button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
461         submit(button);
462         processLifecycleExecuteAndRender();
463 
464         comp = facesContext.getViewRoot().findComponent("panel");
465         
466         Assert.assertEquals("value1", comp.getAttributes().get("attr1"));
467         Assert.assertEquals("value2", comp.getChildren().get(0).getAttributes().get("attr2"));
468         
469         tearDownRequest();
470     }
471     
472     @Test
473     public void testResourceDependency() throws Exception
474     {
475         setupRequest("/resourceDependency1.xhtml");
476         processLifecycleExecute();
477 
478         executeBeforeRender(facesContext);
479         executeBuildViewCycle(facesContext);
480 
481         UIPanel headPanel = (UIPanel) facesContext.getViewRoot().getFacet("head");
482         Assert.assertNotNull(headPanel);
483         Assert.assertEquals(1, headPanel.getChildCount());
484         
485         String nextUniqueId = facesContext.getViewRoot().createUniqueId(facesContext, null);
486         
487         executeViewHandlerRender(facesContext);
488         executeAfterRender(facesContext);
489         
490         UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
491         submit(button);
492         
493         processLifecycleExecute();
494         
495         ResourceDependencyBean bean = facesContext.getApplication().evaluateExpressionGet(
496             facesContext, "#{resourceDependencyBean}", ResourceDependencyBean.class);
497         bean.setIncludeContent(true);
498         
499         executeBeforeRender(facesContext);
500         executeBuildViewCycle(facesContext);
501         
502         headPanel = (UIPanel) facesContext.getViewRoot().getFacet("head");
503         Assert.assertNotNull(headPanel);
504         Assert.assertEquals(1, headPanel.getChildCount());
505         Assert.assertNotSame(nextUniqueId, headPanel.getChildren().get(0).getId());
506         
507         executeViewHandlerRender(facesContext);
508         executeAfterRender(facesContext);
509     }
510 
511     @Test
512     public void testResourceDependency2() throws Exception
513     {
514         setupRequest("/resourceDependency2.xhtml");
515         processLifecycleExecute();
516 
517         executeBeforeRender(facesContext);
518         executeBuildViewCycle(facesContext);
519 
520         UIPanel headPanel = (UIPanel) facesContext.getViewRoot().getFacet("head");
521         Assert.assertNull(headPanel);
522         
523         String nextUniqueId = facesContext.getViewRoot().createUniqueId(facesContext, null);
524         
525         executeViewHandlerRender(facesContext);
526         executeAfterRender(facesContext);
527         
528         UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
529         submit(button);
530         
531         processLifecycleExecute();
532         
533         ResourceDependencyBean bean = facesContext.getApplication().evaluateExpressionGet(
534             facesContext, "#{resourceDependencyBean}", ResourceDependencyBean.class);
535         bean.setIncludeContent(true);
536         
537         executeBeforeRender(facesContext);
538         executeBuildViewCycle(facesContext);
539         
540         headPanel = (UIPanel) facesContext.getViewRoot().getFacet("head");
541         Assert.assertNotNull(headPanel);
542         Assert.assertTrue(1 >= headPanel.getChildCount());
543         Assert.assertNotSame(nextUniqueId, headPanel.getChildren().get(0).getId());
544         
545         executeViewHandlerRender(facesContext);
546         executeAfterRender(facesContext);
547         
548         UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
549         submit(button2);
550         
551         processLifecycleExecute();
552         
553         bean = facesContext.getApplication().evaluateExpressionGet(
554             facesContext, "#{resourceDependencyBean}", ResourceDependencyBean.class);
555         bean.setIncludeContent(false);
556         
557         executeBeforeRender(facesContext);
558         executeBuildViewCycle(facesContext);
559         
560         headPanel = (UIPanel) facesContext.getViewRoot().getFacet("head");
561         Assert.assertNotNull(headPanel);
562         Assert.assertTrue(1 >= headPanel.getChildCount());
563         //Assert.assertNotSame(nextUniqueId, headPanel.getChildren().get(0).getId());
564         
565         executeViewHandlerRender(facesContext);
566         executeAfterRender(facesContext);    
567         
568         UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
569         submit(button3);
570         
571         processLifecycleExecute();
572         
573         bean = facesContext.getApplication().evaluateExpressionGet(
574             facesContext, "#{resourceDependencyBean}", ResourceDependencyBean.class);
575         bean.setIncludeContent(true);
576         
577         executeBeforeRender(facesContext);
578         executeBuildViewCycle(facesContext);
579         
580         headPanel = (UIPanel) facesContext.getViewRoot().getFacet("head");
581         Assert.assertNotNull(headPanel);
582         Assert.assertTrue(1 >= headPanel.getChildCount());
583         //Assert.assertNotSame(nextUniqueId, headPanel.getChildren().get(0).getId());
584         
585         executeViewHandlerRender(facesContext);
586         executeAfterRender(facesContext);
587         
588         UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:postback");
589         submit(button4);
590         
591         processLifecycleExecute();
592         
593         bean = facesContext.getApplication().evaluateExpressionGet(
594             facesContext, "#{resourceDependencyBean}", ResourceDependencyBean.class);
595         bean.setIncludeContent(false);
596         
597         executeBeforeRender(facesContext);
598         executeBuildViewCycle(facesContext);
599         
600         headPanel = (UIPanel) facesContext.getViewRoot().getFacet("head");
601         Assert.assertNotNull(headPanel);
602         Assert.assertTrue(1 >= headPanel.getChildCount());
603         //Assert.assertNotSame(nextUniqueId, headPanel.getChildren().get(0).getId());
604         
605         executeViewHandlerRender(facesContext);
606         executeAfterRender(facesContext);
607     }
608 
609 }