1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.view.facelets.pool;
20
21 import java.util.ArrayList;
22 import java.util.List;
23 import java.util.Locale;
24 import javax.el.ExpressionFactory;
25 import javax.faces.application.ProjectStage;
26 import javax.faces.application.StateManager;
27 import javax.faces.component.UICommand;
28 import javax.faces.component.UIComponent;
29 import javax.faces.component.UIForm;
30 import javax.faces.component.UIOutput;
31 import javax.faces.component.UIPanel;
32 import javax.faces.component.UIViewParameter;
33 import javax.faces.component.UIViewRoot;
34 import javax.faces.view.ViewMetadata;
35
36 import org.apache.myfaces.mc.test.core.AbstractMyFacesRequestTestCase;
37 import org.apache.myfaces.shared.config.MyfacesConfig;
38 import org.apache.myfaces.view.facelets.ViewPoolProcessor;
39 import org.apache.myfaces.view.facelets.pool.impl.ViewPoolImpl;
40 import org.apache.myfaces.view.facelets.tag.jsf.ComponentSupport;
41 import org.apache.myfaces.view.facelets.tag.jsf.FaceletState;
42 import org.junit.Assert;
43 import org.junit.Test;
44
45 public class ViewPoolMyFacesRequestTestCase extends AbstractMyFacesRequestTestCase
46 {
47
48 @Override
49 protected boolean isScanAnnotations()
50 {
51 return true;
52 }
53
54 protected ExpressionFactory createExpressionFactory()
55 {
56 return new org.apache.el.ExpressionFactoryImpl();
57 }
58
59 @Override
60 protected void setUpWebConfigParams() throws Exception
61 {
62 super.setUpWebConfigParams();
63 servletContext.addInitParameter("org.apache.myfaces.annotation.SCAN_PACKAGES","org.apache.myfaces.view.facelets.pool");
64 servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.STATE_SAVING_METHOD_CLIENT);
65 servletContext.addInitParameter(StateManager.PARTIAL_STATE_SAVING_PARAM_NAME, "true");
66 servletContext.addInitParameter(MyfacesConfig.INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS, "auto");
67
68
69 servletContext.addInitParameter(ViewPoolImpl.INIT_PARAM_VIEW_POOL_ENTRY_MODE, "soft");
70 servletContext.addInitParameter(ViewPoolImpl.INIT_PARAM_VIEW_POOL_MAX_POOL_SIZE, "20");
71 servletContext.addInitParameter("org.apache.myfaces.CACHE_EL_EXPRESSIONS", "alwaysRecompile");
72 servletContext.addInitParameter("javax.faces.CONFIG_FILES", "/view-pool-faces-config.xml");
73 servletContext.addInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME, "Production");
74 }
75
76
77
78
79
80
81
82 @Test
83 public void testStaticPageNoForm1() throws Exception
84 {
85 Locale locale = null;
86 startViewRequest("/staticPageNoForm.xhtml");
87 processLifecycleExecute();
88 locale = facesContext.getViewRoot().getLocale();
89 renderResponse();
90
91 UIViewRoot root = new UIViewRoot();
92 root.setLocale(locale);
93 root.setRenderKitId("HTML_BASIC");
94 root.setViewId("/staticPageNoForm.xhtml");
95
96 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
97 ViewPool viewPool = processor.getViewPool(facesContext, root);
98 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
99 Assert.assertNotNull(entry);
100 Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
101 endRequest();
102 }
103
104
105
106
107
108
109
110 @Test
111 public void testStaticPageNoForm1_1() throws Exception
112 {
113 Locale locale = null;
114 startViewRequest("/staticPageNoForm.xhtml");
115 processLifecycleExecute();
116 locale = facesContext.getViewRoot().getLocale();
117
118 executeBeforeRender(facesContext);
119 executeBuildViewCycle(facesContext);
120 executeViewHandlerRender(facesContext);
121 executeAfterRender(facesContext);
122
123 endRequest();
124
125 startViewRequest("/staticPageNoForm.xhtml");
126 processLifecycleExecute();
127
128 executeBeforeRender(facesContext);
129 executeBuildViewCycle(facesContext);
130
131 Assert.assertTrue(facesContext.getViewRoot().getChildCount() > 0);
132
133 UIViewRoot root = new UIViewRoot();
134 root.setLocale(locale);
135 root.setRenderKitId("HTML_BASIC");
136 root.setViewId("/staticPageNoForm.xhtml");
137
138 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
139 ViewPool viewPool = processor.getViewPool(facesContext, root);
140 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
141
142 Assert.assertNull(entry);
143 }
144
145 @Test
146 public void testStaticPageNoForm2() throws Exception
147 {
148 Locale locale = null;
149 startViewRequest("/staticPageNoForm2.xhtml");
150 processLifecycleExecute();
151 locale = facesContext.getViewRoot().getLocale();
152
153 executeBeforeRender(facesContext);
154 executeBuildViewCycle(facesContext);
155
156 UIOutput testjs1_1 = (UIOutput) facesContext.getViewRoot().findComponent("testjs");
157 Assert.assertNotNull(testjs1_1);
158 testjs1_1.getAttributes().put("param1", "value1");
159
160 List<UIComponent> crlist = facesContext.getViewRoot().getComponentResources(facesContext, "head");
161 Assert.assertEquals(2, crlist.size());
162 for(UIComponent comp : crlist)
163 {
164 comp.getAttributes().put("param2", "value2");
165 }
166
167 executeViewHandlerRender(facesContext);
168 executeAfterRender(facesContext);
169
170 endRequest();
171
172 startViewRequest("/staticPageNoForm2.xhtml");
173 processLifecycleExecute();
174
175 executeBeforeRender(facesContext);
176 executeBuildViewCycle(facesContext);
177
178 Assert.assertTrue(facesContext.getViewRoot().getChildCount() > 0);
179
180 UIOutput testjs2_1 = (UIOutput) facesContext.getViewRoot().findComponent("testjs");
181 Assert.assertNotNull(testjs2_1);
182
183 Assert.assertNull(testjs2_1.getAttributes().get("param1"));
184
185 List<UIComponent> crlist2 = facesContext.getViewRoot().getComponentResources(facesContext, "head");
186 Assert.assertEquals(2, crlist2.size());
187 for(UIComponent comp : crlist)
188 {
189 Assert.assertNull(comp.getAttributes().get("param2"));
190 }
191
192 UIViewRoot root = new UIViewRoot();
193 root.setLocale(locale);
194 root.setRenderKitId("HTML_BASIC");
195 root.setViewId("/staticPageNoForm2.xhtml");
196
197 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
198 ViewPool viewPool = processor.getViewPool(facesContext, root);
199 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
200
201 Assert.assertNull(entry);
202 }
203
204 @Test
205 public void testStaticPage1() throws Exception
206 {
207 Locale locale = null;
208 startViewRequest("/staticPage.xhtml");
209 processLifecycleExecute();
210 locale = facesContext.getViewRoot().getLocale();
211 renderResponse();
212
213 UIViewRoot root = new UIViewRoot();
214 root.setLocale(locale);
215 root.setRenderKitId("HTML_BASIC");
216 root.setViewId("/staticPage.xhtml");
217
218 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
219 ViewPool viewPool = processor.getViewPool(facesContext, root);
220 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
221 Assert.assertNotNull(entry);
222 Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
223 endRequest();
224 }
225
226 @Test
227 public void testStaticPage1_1() throws Exception
228 {
229 Locale locale = null;
230 startViewRequest("/staticPage.xhtml");
231 processLifecycleExecute();
232 locale = facesContext.getViewRoot().getLocale();
233 executeBeforeRender(facesContext);
234 executeBuildViewCycle(facesContext);
235
236
237 UIOutput testComponent = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE);
238 testComponent.setId("testId");
239 testComponent.setValue("Some Text");
240 UIForm form = (UIForm) facesContext.getViewRoot().findComponent("mainForm");
241 form.getChildren().add(testComponent);
242
243 executeViewHandlerRender(facesContext);
244 executeAfterRender(facesContext);
245
246 UIViewRoot root = new UIViewRoot();
247 root.setLocale(locale);
248 root.setRenderKitId("HTML_BASIC");
249 root.setViewId("/staticPage.xhtml");
250
251 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
252 ViewPool viewPool = processor.getViewPool(facesContext, root);
253 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
254 Assert.assertNotNull(entry);
255 Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
256
257
258 UIForm form2 = (UIForm) entry.getViewRoot().findComponent("mainForm");
259 Assert.assertNotNull(form2);
260 UIOutput testComponent2 = (UIOutput) form2.findComponent("testId");
261 Assert.assertNull(testComponent2);
262
263 endRequest();
264 }
265
266 @Test
267 public void testStaticPage1_2() throws Exception
268 {
269 Locale locale = null;
270 startViewRequest("/staticPage.xhtml");
271 processLifecycleExecute();
272 locale = facesContext.getViewRoot().getLocale();
273 executeBeforeRender(facesContext);
274 executeBuildViewCycle(facesContext);
275
276
277 UIOutput testComponent = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE);
278 testComponent.setId("testId");
279 testComponent.setValue("Some Text");
280 UIForm form = (UIForm) facesContext.getViewRoot().findComponent("mainForm");
281 form.getChildren().add(testComponent);
282
283 executeViewHandlerRender(facesContext);
284 executeAfterRender(facesContext);
285
286 UIViewRoot root = new UIViewRoot();
287 root.setLocale(locale);
288 root.setRenderKitId("HTML_BASIC");
289 root.setViewId("/staticPage.xhtml");
290
291 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
292 ViewPool viewPool = processor.getViewPool(facesContext, root);
293 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
294 Assert.assertNotNull(entry);
295 Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
296
297
298 UIForm form2 = (UIForm) entry.getViewRoot().findComponent("mainForm");
299 Assert.assertNotNull(form2);
300 UIOutput testComponent2 = (UIOutput) form2.findComponent("testId");
301 Assert.assertNull(testComponent2);
302
303 endRequest();
304 }
305
306 @Test
307 public void testStaticPage1_3() throws Exception
308 {
309 Locale locale = null;
310 startViewRequest("/staticPage.xhtml");
311 processLifecycleExecute();
312 locale = facesContext.getViewRoot().getLocale();
313
314 executeBeforeRender(facesContext);
315 executeBuildViewCycle(facesContext);
316
317
318
319
320 UIForm form = (UIForm) facesContext.getViewRoot().findComponent("mainForm");
321 form.getChildren().remove(0);
322
323 executeViewHandlerRender(facesContext);
324 executeAfterRender(facesContext);
325
326 UIViewRoot root = new UIViewRoot();
327 root.setLocale(locale);
328 root.setRenderKitId("HTML_BASIC");
329 root.setViewId("/staticPage.xhtml");
330
331 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
332 ViewPool viewPool = processor.getViewPool(facesContext, root);
333 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
334 Assert.assertNotNull(entry);
335 Assert.assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult());
336 endRequest();
337 }
338
339 @Test
340 public void testStaticPage1_4() throws Exception
341 {
342 Locale locale = null;
343 startViewRequest("/staticPage.xhtml");
344 processLifecycleExecute();
345 locale = facesContext.getViewRoot().getLocale();
346
347 executeBeforeRender(facesContext);
348 executeBuildViewCycle(facesContext);
349
350
351
352
353 UIForm form = (UIForm) facesContext.getViewRoot().findComponent("mainForm");
354 UIComponent panel = form.getChildren().remove(0);
355
356 form.getChildren().add(panel);
357
358 executeViewHandlerRender(facesContext);
359 executeAfterRender(facesContext);
360
361 UIViewRoot root = new UIViewRoot();
362 root.setLocale(locale);
363 root.setRenderKitId("HTML_BASIC");
364 root.setViewId("/staticPage.xhtml");
365
366 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
367 ViewPool viewPool = processor.getViewPool(facesContext, root);
368 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
369 Assert.assertNotNull(entry);
370 Assert.assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult());
371 endRequest();
372 }
373
374 @Test
375 public void testStaticPage1_5() throws Exception
376 {
377 Locale locale = null;
378 startViewRequest("/staticPage.xhtml");
379 processLifecycleExecute();
380 locale = facesContext.getViewRoot().getLocale();
381 executeBeforeRender(facesContext);
382 executeBuildViewCycle(facesContext);
383
384
385 facesContext.getViewRoot().getViewMap().put("someKey", "someValue");
386
387 UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
388
389 executeViewHandlerRender(facesContext);
390 executeAfterRender(facesContext);
391
392 client.submit(submitButton);
393
394 processLifecycleExecute();
395
396 executeBeforeRender(facesContext);
397 executeBuildViewCycle(facesContext);
398
399
400 Assert.assertEquals("someValue", facesContext.getViewRoot().getViewMap().get("someKey"));
401
402 facesContext.getViewRoot().getViewMap().put("someKey", "someValue2");
403
404 submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
405
406 executeViewHandlerRender(facesContext);
407 executeAfterRender(facesContext);
408
409 client.submit(submitButton);
410
411 processLifecycleExecute();
412
413 executeBeforeRender(facesContext);
414 executeBuildViewCycle(facesContext);
415
416
417 Assert.assertEquals("someValue2", facesContext.getViewRoot().getViewMap().get("someKey"));
418
419 Assert.assertTrue(facesContext.getViewRoot().getChildCount() > 0);
420
421 executeViewHandlerRender(facesContext);
422 executeAfterRender(facesContext);
423
424 UIViewRoot root = new UIViewRoot();
425 root.setLocale(locale);
426 root.setRenderKitId("HTML_BASIC");
427 root.setViewId("/staticPage.xhtml");
428
429 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
430 ViewPool viewPool = processor.getViewPool(facesContext, root);
431 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
432 Assert.assertNotNull(entry);
433 Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
434
435 endRequest();
436 }
437
438 @Test
439 public void testStaticPage1_6() throws Exception
440 {
441 Locale locale = null;
442 startViewRequest("/staticPage3.xhtml");
443 processLifecycleExecute();
444 locale = facesContext.getViewRoot().getLocale();
445 facesContext.getViewRoot().getViewMap().put("keyBeforeView", "someBeforeValue");
446
447 executeBeforeRender(facesContext);
448 executeBuildViewCycle(facesContext);
449
450
451 Assert.assertEquals("someBeforeValue", facesContext.getViewRoot().getViewMap().get("keyBeforeView"));
452 facesContext.getViewRoot().getViewMap().put("someKey", "someValue");
453
454 UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
455
456 executeViewHandlerRender(facesContext);
457 executeAfterRender(facesContext);
458
459 client.submit(submitButton);
460
461 processLifecycleExecute();
462
463 executeBeforeRender(facesContext);
464 executeBuildViewCycle(facesContext);
465
466
467 Assert.assertEquals("someValue", facesContext.getViewRoot().getViewMap().get("someKey"));
468
469 facesContext.getViewRoot().getViewMap().put("someKey", "someValue2");
470
471 submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
472
473 executeViewHandlerRender(facesContext);
474 executeAfterRender(facesContext);
475
476 client.submit(submitButton);
477
478 processLifecycleExecute();
479
480 executeBeforeRender(facesContext);
481 executeBuildViewCycle(facesContext);
482
483
484 Assert.assertEquals("someValue2", facesContext.getViewRoot().getViewMap().get("someKey"));
485
486 Assert.assertTrue(facesContext.getViewRoot().getChildCount() > 0);
487
488 executeViewHandlerRender(facesContext);
489 executeAfterRender(facesContext);
490
491 UIViewRoot root = new UIViewRoot();
492 root.setLocale(locale);
493 root.setRenderKitId("HTML_BASIC");
494 root.setViewId("/staticPage3.xhtml");
495
496 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
497 ViewPool viewPool = processor.getViewPool(facesContext, root);
498 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
499 Assert.assertNotNull(entry);
500 Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
501
502 endRequest();
503 }
504
505 @Test
506 public void testStaticPage1_7() throws Exception
507 {
508 Locale locale = null;
509 startViewRequest("/staticPage3.xhtml");
510 processLifecycleExecute();
511 locale = facesContext.getViewRoot().getLocale();
512
513 executeBeforeRender(facesContext);
514 executeBuildViewCycle(facesContext);
515
516
517 facesContext.getViewRoot().getViewMap().put("someKey", "someValue");
518
519
520 executeViewHandlerRender(facesContext);
521 executeAfterRender(facesContext);
522
523 startViewRequest("/staticPage3.xhtml");
524 request.addParameter("id", "someId");
525 processLifecycleExecute();
526 locale = facesContext.getViewRoot().getLocale();
527 facesContext.getViewRoot().getViewMap().put("keyBeforeView", "someBeforeValue");
528
529 UIViewParameter paramComponent = ViewMetadata.getViewParameters(facesContext.getViewRoot()).iterator().next();
530 Assert.assertNotNull(paramComponent);
531 Assert.assertEquals("someId", paramComponent.getValue());
532
533 executeBeforeRender(facesContext);
534 executeBuildViewCycle(facesContext);
535
536 paramComponent = ViewMetadata.getViewParameters(facesContext.getViewRoot()).iterator().next();
537 Assert.assertNotNull(paramComponent);
538 Assert.assertEquals("someId", paramComponent.getValue());
539
540
541 Assert.assertEquals("someBeforeValue", facesContext.getViewRoot().getViewMap().get("keyBeforeView"));
542 facesContext.getViewRoot().getViewMap().put("someKey", "someValue");
543
544
545 UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
546
547 executeViewHandlerRender(facesContext);
548 executeAfterRender(facesContext);
549
550 endRequest();
551 }
552
553 @Test
554 public void testStaticPage2() throws Exception
555 {
556 Locale locale = null;
557 startViewRequest("/staticPage2.xhtml");
558 processLifecycleExecute();
559 locale = facesContext.getViewRoot().getLocale();
560
561 executeBeforeRender(facesContext);
562 executeBuildViewCycle(facesContext);
563
564 UIOutput testjs1_1 = (UIOutput) facesContext.getViewRoot().findComponent("testjs");
565 Assert.assertNotNull(testjs1_1);
566 testjs1_1.getAttributes().put("param1", "value1");
567
568 List<UIComponent> crlist = facesContext.getViewRoot().getComponentResources(facesContext, "head");
569 Assert.assertEquals(2, crlist.size());
570 for(UIComponent comp : crlist)
571 {
572 comp.getAttributes().put("param2", "value2");
573 }
574
575 UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
576
577 executeViewHandlerRender(facesContext);
578 executeAfterRender(facesContext);
579
580 client.submit(submitButton);
581
582 processLifecycleExecute();
583
584 executeBeforeRender(facesContext);
585 executeBuildViewCycle(facesContext);
586
587 Assert.assertTrue(facesContext.getViewRoot().getChildCount() > 0);
588
589 UIOutput testjs2_1 = (UIOutput) facesContext.getViewRoot().findComponent("testjs");
590 Assert.assertNotNull(testjs2_1);
591
592 Assert.assertEquals("value1",testjs2_1.getAttributes().get("param1"));
593
594 List<UIComponent> crlist2 = facesContext.getViewRoot().getComponentResources(facesContext, "head");
595 Assert.assertEquals(2, crlist2.size());
596 for(UIComponent comp : crlist)
597 {
598 Assert.assertEquals("value2", comp.getAttributes().get("param2"));
599 }
600
601 UIViewRoot root = new UIViewRoot();
602 root.setLocale(locale);
603 root.setRenderKitId("HTML_BASIC");
604 root.setViewId("/staticPage2.xhtml");
605
606 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
607 ViewPool viewPool = processor.getViewPool(facesContext, root);
608 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
609
610 Assert.assertNull(entry);
611 }
612
613 @Test
614 public void testStaticPageWithViewScope1() throws Exception
615 {
616 Locale locale = null;
617 startViewRequest("/staticPage.xhtml");
618 processLifecycleExecute();
619 locale = facesContext.getViewRoot().getLocale();
620
621 executeBuildViewCycle(facesContext);
622 facesContext.getViewRoot().getViewMap(true).put("viewItem", "someValue");
623 executeViewHandlerRender(facesContext);
624 executeAfterRender(facesContext);
625
626 endRequest();
627
628 startViewRequest("/staticPage.xhtml");
629 processLifecycleExecute();
630
631 executeBuildViewCycle(facesContext);
632
633
634 Assert.assertNull(facesContext.getViewRoot().getViewMap(false));
635
636
637 UIViewRoot root = new UIViewRoot();
638 root.setLocale(locale);
639 root.setRenderKitId("HTML_BASIC");
640 root.setViewId("/staticPage.xhtml");
641 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
642 ViewPool viewPool = processor.getViewPool(facesContext, root);
643 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
644 Assert.assertNull(entry2);
645 }
646
647 @Test
648 public void testStaticPageWithViewScope1_1() throws Exception
649 {
650 Locale locale = null;
651 startViewRequest("/staticPage.xhtml");
652 processLifecycleExecute();
653 locale = facesContext.getViewRoot().getLocale();
654
655 executeBuildViewCycle(facesContext);
656 facesContext.getViewRoot().getViewMap(true).put("viewItem", "someValue");
657 executeViewHandlerRender(facesContext);
658 executeAfterRender(facesContext);
659
660 UIViewRoot root = new UIViewRoot();
661 root.setLocale(locale);
662 root.setRenderKitId("HTML_BASIC");
663 root.setViewId("/staticPage.xhtml");
664
665 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
666 ViewPool viewPool = processor.getViewPool(facesContext, root);
667 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
668 Assert.assertNotNull(entry);
669 Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
670 endRequest();
671 }
672
673 @Test
674 public void testStaticPageWithViewScope2() throws Exception
675 {
676 Locale locale = null;
677 startViewRequest("/staticPage.xhtml");
678 processLifecycleExecute();
679 locale = facesContext.getViewRoot().getLocale();
680 facesContext.getViewRoot().getViewMap(true).put("viewItem", "someValue");
681
682 executeBuildViewCycle(facesContext);
683 UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
684
685 executeViewHandlerRender(facesContext);
686 executeAfterRender(facesContext);
687
688 UIViewRoot root = new UIViewRoot();
689 root.setLocale(locale);
690 root.setRenderKitId("HTML_BASIC");
691 root.setViewId("/staticPage.xhtml");
692
693 client.submit(submitButton);
694
695 processLifecycleExecute();
696
697
698 Assert.assertNotNull(facesContext.getViewRoot().getViewMap(false));
699 Assert.assertEquals("someValue", facesContext.getViewRoot().getViewMap(false).get("viewItem"));
700
701 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
702 ViewPool viewPool = processor.getViewPool(facesContext, root);
703
704 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
705 Assert.assertNull(entry2);
706 }
707
708 @Test
709 public void testStaticUIParamPage1() throws Exception
710 {
711 Locale locale = null;
712 startViewRequest("/staticUIParamPage1.xhtml");
713 processLifecycleExecute();
714 locale = facesContext.getViewRoot().getLocale();
715 renderResponse();
716
717 UIViewRoot root = new UIViewRoot();
718 root.setLocale(locale);
719 root.setRenderKitId("HTML_BASIC");
720 root.setViewId("/staticUIParamPage1.xhtml");
721
722 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
723 ViewPool viewPool = processor.getViewPool(facesContext, root);
724 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
725 Assert.assertNotNull(entry);
726 Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
727 endRequest();
728 }
729
730 @Test
731 public void testStaticUIParamPage1_1() throws Exception
732 {
733 Locale locale = null;
734 startViewRequest("/staticUIParamPage1.xhtml");
735 processLifecycleExecute();
736 locale = facesContext.getViewRoot().getLocale();
737
738 executeBuildViewCycle(facesContext);
739
740 UIOutput outParam1_1 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:paramOut_1");
741 Assert.assertNotNull(outParam1_1);
742 Assert.assertEquals("hello_1", outParam1_1.getValue());
743
744 UIOutput outParam1_2 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:paramOut_2");
745 Assert.assertNotNull(outParam1_2);
746 Assert.assertEquals("hello_2", outParam1_2.getValue());
747
748 executeViewHandlerRender(facesContext);
749
750
751
752
753 executeAfterRender(facesContext);
754
755 endRequest();
756
757 startViewRequest("/staticUIParamPage1.xhtml");
758 processLifecycleExecute();
759
760 executeBuildViewCycle(facesContext);
761
762 UIOutput outParam2_1 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:paramOut_1");
763 Assert.assertNotNull(outParam2_1);
764 Assert.assertEquals("hello_1", outParam2_1.getValue());
765
766 UIOutput outParam2_2 = (UIOutput) facesContext.getViewRoot().findComponent("mainForm:paramOut_2");
767 Assert.assertNotNull(outParam2_2);
768 Assert.assertEquals("hello_2", outParam2_2.getValue());
769
770
771 UIViewRoot root = new UIViewRoot();
772 root.setLocale(locale);
773 root.setRenderKitId("HTML_BASIC");
774 root.setViewId("/staticPage.xhtml");
775 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
776 ViewPool viewPool = processor.getViewPool(facesContext, root);
777 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
778 Assert.assertNull(entry2);
779
780 executeViewHandlerRender(facesContext);
781
782
783
784
785 executeAfterRender(facesContext);
786 }
787
788 @Test
789 public void testStaticViewParamPage1() throws Exception
790 {
791 Locale locale = null;
792 startViewRequest("/staticViewParamPage1.xhtml");
793 processLifecycleExecute();
794 locale = facesContext.getViewRoot().getLocale();
795 renderResponse();
796
797 UIViewRoot root = new UIViewRoot();
798 root.setLocale(locale);
799 root.setRenderKitId("HTML_BASIC");
800 root.setViewId("/staticViewParamPage1.xhtml");
801
802 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
803 ViewPool viewPool = processor.getViewPool(facesContext, root);
804 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
805 Assert.assertNotNull(entry);
806 Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
807 endRequest();
808 }
809
810 @Test
811 public void testStaticViewParamPage1_1() throws Exception
812 {
813 Locale locale = null;
814 startViewRequest("/staticViewParamPage1.xhtml");
815 processLifecycleExecute();
816 locale = facesContext.getViewRoot().getLocale();
817
818 executeBuildViewCycle(facesContext);
819
820 UIOutput testId1_1 = (UIOutput) facesContext.getViewRoot().findComponent("testId");
821 Assert.assertNotNull(testId1_1);
822 testId1_1.getAttributes().put("param1", "value1");
823
824 executeViewHandlerRender(facesContext);
825
826 executeAfterRender(facesContext);
827
828 endRequest();
829
830 startViewRequest("/staticViewParamPage1.xhtml");
831 processLifecycleExecute();
832
833 executeBuildViewCycle(facesContext);
834
835 UIOutput testId2_1 = (UIOutput) facesContext.getViewRoot().findComponent("testId");
836 Assert.assertNotNull(testId2_1);
837 Assert.assertNull(testId2_1.getAttributes().get("param1"));
838
839
840 UIViewRoot root = new UIViewRoot();
841 root.setLocale(locale);
842 root.setRenderKitId("HTML_BASIC");
843 root.setViewId("/staticViewParamPage1.xhtml");
844 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
845 ViewPool viewPool = processor.getViewPool(facesContext, root);
846 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
847 Assert.assertNull(entry2);
848
849 executeViewHandlerRender(facesContext);
850
851 executeAfterRender(facesContext);
852 }
853
854 @Test
855 public void testStaticViewParamPage1_2() throws Exception
856 {
857 Locale locale = null;
858 startViewRequest("/staticViewParamPage1.xhtml");
859 processLifecycleExecute();
860 locale = facesContext.getViewRoot().getLocale();
861
862 executeBuildViewCycle(facesContext);
863
864 UIOutput testId1_1 = (UIOutput) facesContext.getViewRoot().findComponent("testId");
865 Assert.assertNotNull(testId1_1);
866
867
868 testId1_1.getAttributes().put("param1", "value1");
869
870 UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
871
872 executeViewHandlerRender(facesContext);
873
874 executeAfterRender(facesContext);
875
876 client.submit(submitButton);
877
878 processLifecycleExecute();
879
880 UIOutput testId2_1 = (UIOutput) facesContext.getViewRoot().findComponent("testId");
881 Assert.assertNotNull(testId2_1);
882
883 Assert.assertEquals("value1", testId2_1.getAttributes().get("param1"));
884
885 executeBuildViewCycle(facesContext);
886
887 UIOutput testId3_1 = (UIOutput) facesContext.getViewRoot().findComponent("testId");
888 Assert.assertNotNull(testId3_1);
889
890 Assert.assertEquals("value1", testId3_1.getAttributes().get("param1"));
891
892
893 UIViewRoot root = new UIViewRoot();
894 root.setLocale(locale);
895 root.setRenderKitId("HTML_BASIC");
896 root.setViewId("/staticViewParamPage1.xhtml");
897 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
898 ViewPool viewPool = processor.getViewPool(facesContext, root);
899 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
900 Assert.assertNull(entry2);
901
902 executeViewHandlerRender(facesContext);
903
904 executeAfterRender(facesContext);
905 }
906
907 @Test
908 public void testDynamicPage1() throws Exception
909 {
910 Locale locale = null;
911 startViewRequest("/dynPage1.xhtml");
912 processLifecycleExecute();
913 locale = facesContext.getViewRoot().getLocale();
914
915 executeBeforeRender(facesContext);
916 executeBuildViewCycle(facesContext);
917
918 FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get(
919 ComponentSupport.FACELET_STATE_INSTANCE);
920
921 executeViewHandlerRender(facesContext);
922 executeAfterRender(facesContext);
923
924 UIViewRoot root = new UIViewRoot();
925 root.setLocale(locale);
926 root.setRenderKitId("HTML_BASIC");
927 root.setViewId("/dynPage1.xhtml");
928
929 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
930 ViewPool viewPool = processor.getViewPool(facesContext, root);
931 ViewEntry entry = viewPool.popDynamicStructureView(facesContext, root, faceletState);
932 Assert.assertNotNull(entry);
933 Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
934 endRequest();
935 }
936
937 @Test
938 public void testDynamicPage1_1() throws Exception
939 {
940 Locale locale = null;
941 startViewRequest("/dynPage1.xhtml");
942 processLifecycleExecute();
943 locale = facesContext.getViewRoot().getLocale();
944 executeBeforeRender(facesContext);
945 executeBuildViewCycle(facesContext);
946
947
948 UIOutput testComponent = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE);
949 testComponent.setId("testId");
950 testComponent.setValue("Some Text");
951 UIForm form = (UIForm) facesContext.getViewRoot().findComponent("mainForm");
952 form.getChildren().add(testComponent);
953
954 FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get(
955 ComponentSupport.FACELET_STATE_INSTANCE);
956
957 executeViewHandlerRender(facesContext);
958 executeAfterRender(facesContext);
959
960 UIViewRoot root = new UIViewRoot();
961 root.setLocale(locale);
962 root.setRenderKitId("HTML_BASIC");
963 root.setViewId("/dynPage1.xhtml");
964
965 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
966 ViewPool viewPool = processor.getViewPool(facesContext, root);
967 ViewEntry entry = viewPool.popDynamicStructureView(facesContext, root, faceletState);
968 Assert.assertNotNull(entry);
969 Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
970
971
972 UIForm form2 = (UIForm) entry.getViewRoot().findComponent("mainForm");
973 Assert.assertNotNull(form2);
974 UIOutput testComponent2 = (UIOutput) form2.findComponent("testId");
975 Assert.assertNull(testComponent2);
976
977 endRequest();
978 }
979
980 @Test
981 public void testDynamicPage1_2() throws Exception
982 {
983 Locale locale = null;
984 startViewRequest("/dynPage1.xhtml");
985 processLifecycleExecute();
986 locale = facesContext.getViewRoot().getLocale();
987 facesContext.getViewRoot().getViewMap(true).put("viewItem", "someValue");
988
989 executeBuildViewCycle(facesContext);
990 UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
991
992 executeViewHandlerRender(facesContext);
993 executeAfterRender(facesContext);
994
995 client.submit(submitButton);
996
997 processLifecycleExecute();
998
999
1000 Assert.assertNotNull(facesContext.getViewRoot().getViewMap(false));
1001 Assert.assertEquals("someValue", facesContext.getViewRoot().getViewMap(false).get("viewItem"));
1002
1003 FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get(
1004 ComponentSupport.FACELET_STATE_INSTANCE);
1005
1006 UIViewRoot root = new UIViewRoot();
1007 root.setLocale(locale);
1008 root.setRenderKitId("HTML_BASIC");
1009 root.setViewId("/dynPage1.xhtml");
1010
1011 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1012 ViewPool viewPool = processor.getViewPool(facesContext, root);
1013
1014 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
1015 Assert.assertNull(entry2);
1016 ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState);
1017 Assert.assertNull(entry3);
1018 }
1019
1020 @Test
1021 public void testStaticPageLocale1() throws Exception
1022 {
1023 Locale locale = null;
1024 startViewRequest("/staticPageLocale1.xhtml");
1025 processLifecycleExecute();
1026 executeBeforeRender(facesContext);
1027 executeBuildViewCycle(facesContext);
1028 locale = facesContext.getViewRoot().getLocale();
1029 Assert.assertEquals(Locale.US, locale);
1030
1031
1032 executeViewHandlerRender(facesContext);
1033 executeAfterRender(facesContext);
1034
1035 UIViewRoot root = new UIViewRoot();
1036 root.setLocale(locale);
1037 root.setRenderKitId("HTML_BASIC");
1038 root.setViewId("/staticPageLocale1.xhtml");
1039
1040 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1041 ViewPool viewPool = processor.getViewPool(facesContext, root);
1042 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
1043 Assert.assertNotNull(entry);
1044 Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
1045 endRequest();
1046 }
1047
1048 @Test
1049 public void testStaticPageLocale1_1() throws Exception
1050 {
1051 Locale locale = null;
1052 startViewRequest("/staticPageLocale1.xhtml");
1053 processLifecycleExecute();
1054 locale = facesContext.getViewRoot().getLocale();
1055 Assert.assertEquals(Locale.US, locale);
1056
1057 executeBuildViewCycle(facesContext);
1058 executeViewHandlerRender(facesContext);
1059 executeAfterRender(facesContext);
1060
1061 endRequest();
1062
1063 startViewRequest("/staticPageLocale1.xhtml");
1064 processLifecycleExecute();
1065
1066 executeBuildViewCycle(facesContext);
1067
1068
1069 UIViewRoot root = new UIViewRoot();
1070 root.setLocale(locale);
1071 root.setRenderKitId("HTML_BASIC");
1072 root.setViewId("/staticPageLocale1.xhtml");
1073 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1074 ViewPool viewPool = processor.getViewPool(facesContext, root);
1075 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
1076 Assert.assertNull(entry2);
1077 }
1078
1079
1080
1081
1082
1083
1084 @Test
1085 public void testStaticPageLocale1_2() throws Exception
1086 {
1087 Locale locale = null;
1088 startViewRequest("/staticPageLocale1.xhtml");
1089 processLifecycleExecute();
1090 locale = facesContext.getViewRoot().getLocale();
1091 Assert.assertEquals(Locale.US, locale);
1092
1093 executeBuildViewCycle(facesContext);
1094 executeViewHandlerRender(facesContext);
1095 executeAfterRender(facesContext);
1096
1097 DynamicBean bean = facesContext.getApplication().evaluateExpressionGet(
1098 facesContext, "#{dynamicBean}", DynamicBean.class);
1099 bean.setLocale(Locale.UK);
1100
1101 endRequest();
1102
1103 startViewRequest("/staticPageLocale1.xhtml");
1104 processLifecycleExecute();
1105 locale = facesContext.getViewRoot().getLocale();
1106 Assert.assertEquals(Locale.UK, locale);
1107 executeBuildViewCycle(facesContext);
1108
1109
1110 UIViewRoot root = new UIViewRoot();
1111 root.setLocale(Locale.US);
1112 root.setRenderKitId("HTML_BASIC");
1113 root.setViewId("/staticPageLocale1.xhtml");
1114 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1115 ViewPool viewPool = processor.getViewPool(facesContext, root);
1116 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
1117 Assert.assertNotNull(entry2);
1118 }
1119
1120 @Test
1121 public void testStaticPageContract1() throws Exception
1122 {
1123 Locale locale = null;
1124 startViewRequest("/staticPageContract1.xhtml");
1125 processLifecycleExecute();
1126 executeBeforeRender(facesContext);
1127 executeBuildViewCycle(facesContext);
1128 locale = facesContext.getViewRoot().getLocale();
1129
1130 executeViewHandlerRender(facesContext);
1131 executeAfterRender(facesContext);
1132
1133 UIViewRoot root = new UIViewRoot();
1134 root.setLocale(locale);
1135 root.setRenderKitId("HTML_BASIC");
1136 root.setViewId("/staticPageContract1.xhtml");
1137
1138 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1139 ViewPool viewPool = processor.getViewPool(facesContext, root);
1140 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
1141 Assert.assertNotNull(entry);
1142 Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
1143 endRequest();
1144 }
1145
1146 @Test
1147 public void testStaticPageContract1_1() throws Exception
1148 {
1149 Locale locale = null;
1150 startViewRequest("/staticPageContract1.xhtml");
1151 processLifecycleExecute();
1152 locale = facesContext.getViewRoot().getLocale();
1153
1154 executeBuildViewCycle(facesContext);
1155 executeViewHandlerRender(facesContext);
1156 executeAfterRender(facesContext);
1157
1158 endRequest();
1159
1160 startViewRequest("/staticPageContract1.xhtml");
1161 processLifecycleExecute();
1162
1163 executeBuildViewCycle(facesContext);
1164
1165
1166 UIViewRoot root = new UIViewRoot();
1167 root.setLocale(locale);
1168 root.setRenderKitId("HTML_BASIC");
1169 root.setViewId("/staticPageContract1.xhtml");
1170 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1171 ViewPool viewPool = processor.getViewPool(facesContext, root);
1172 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
1173 Assert.assertNull(entry2);
1174 }
1175
1176
1177
1178
1179
1180
1181 @Test
1182 public void testStaticPageContract1_2() throws Exception
1183 {
1184 Locale locale = null;
1185 startViewRequest("/staticPageContract1.xhtml");
1186 processLifecycleExecute();
1187 locale = facesContext.getViewRoot().getLocale();
1188
1189 executeBuildViewCycle(facesContext);
1190 executeViewHandlerRender(facesContext);
1191 executeAfterRender(facesContext);
1192
1193 DynamicBean bean = facesContext.getApplication().evaluateExpressionGet(
1194 facesContext, "#{dynamicBean}", DynamicBean.class);
1195 bean.setContract("yellow");
1196
1197 endRequest();
1198
1199 startViewRequest("/staticPageContract1.xhtml");
1200 processLifecycleExecute();
1201 locale = facesContext.getViewRoot().getLocale();
1202 executeBuildViewCycle(facesContext);
1203
1204
1205 List<String> contracts = new ArrayList<String>();
1206 contracts.add("blue");
1207 facesContext.setResourceLibraryContracts(contracts);
1208 UIViewRoot root = new UIViewRoot();
1209 root.setLocale(locale);
1210 root.setRenderKitId("HTML_BASIC");
1211 root.setViewId("/staticPageContract1.xhtml");
1212 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1213 ViewPool viewPool = processor.getViewPool(facesContext, root);
1214 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
1215 Assert.assertNotNull(entry2);
1216 }
1217
1218 @Test
1219 public void testDynPageResource1() throws Exception
1220 {
1221 Locale locale = null;
1222 startViewRequest("/dynPageResource.xhtml");
1223 processLifecycleExecute();
1224 locale = facesContext.getViewRoot().getLocale();
1225
1226 executeBeforeRender(facesContext);
1227 executeBuildViewCycle(facesContext);
1228
1229 FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get(
1230 ComponentSupport.FACELET_STATE_INSTANCE);
1231
1232 executeViewHandlerRender(facesContext);
1233 executeAfterRender(facesContext);
1234
1235 UIViewRoot root = new UIViewRoot();
1236 root.setLocale(locale);
1237 root.setRenderKitId("HTML_BASIC");
1238 root.setViewId("/dynPageResource.xhtml");
1239 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1240 ViewPool viewPool = processor.getViewPool(facesContext, root);
1241 ViewEntry entry1 = viewPool.popDynamicStructureView(facesContext, root, faceletState);
1242 Assert.assertNotNull(entry1);
1243 }
1244
1245 @Test
1246 public void testDynPageResource1_1() throws Exception
1247 {
1248 Locale locale = null;
1249 startViewRequest("/dynPageResource.xhtml");
1250 processLifecycleExecute();
1251 locale = facesContext.getViewRoot().getLocale();
1252
1253 executeBeforeRender(facesContext);
1254 executeBuildViewCycle(facesContext);
1255
1256 UIOutput testjs1_1 = (UIOutput) facesContext.getViewRoot().findComponent("testjs");
1257 Assert.assertNotNull(testjs1_1);
1258 testjs1_1.getAttributes().put("param1", "value1");
1259
1260 List<UIComponent> crlist = facesContext.getViewRoot().getComponentResources(facesContext, "head");
1261 Assert.assertEquals(2, crlist.size());
1262 for(UIComponent comp : crlist)
1263 {
1264 comp.getAttributes().put("param2", "value2");
1265 }
1266
1267 UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
1268
1269 executeViewHandlerRender(facesContext);
1270 executeAfterRender(facesContext);
1271
1272 client.submit(submitButton);
1273
1274 processLifecycleExecute();
1275
1276 executeBeforeRender(facesContext);
1277 executeBuildViewCycle(facesContext);
1278
1279 Assert.assertTrue(facesContext.getViewRoot().getChildCount() > 0);
1280
1281 UIOutput testjs2_1 = (UIOutput) facesContext.getViewRoot().findComponent("testjs");
1282 Assert.assertNotNull(testjs2_1);
1283
1284 Assert.assertEquals("value1",testjs2_1.getAttributes().get("param1"));
1285
1286 List<UIComponent> crlist2 = facesContext.getViewRoot().getComponentResources(facesContext, "head");
1287 Assert.assertEquals(2, crlist2.size());
1288 for(UIComponent comp : crlist)
1289 {
1290 Assert.assertEquals("value2", comp.getAttributes().get("param2"));
1291 }
1292
1293 UIViewRoot root = new UIViewRoot();
1294 root.setLocale(locale);
1295 root.setRenderKitId("HTML_BASIC");
1296 root.setViewId("/dynPageResource.xhtml");
1297
1298 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1299 ViewPool viewPool = processor.getViewPool(facesContext, root);
1300 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
1301
1302 Assert.assertNull(entry);
1303 }
1304
1305 @Test
1306 public void testDynPageResource2() throws Exception
1307 {
1308 Locale locale = null;
1309
1310 startViewRequest("/dynPageResource.xhtml");
1311 processLifecycleExecute();
1312 locale = facesContext.getViewRoot().getLocale();
1313
1314 executeBeforeRender(facesContext);
1315 executeBuildViewCycle(facesContext);
1316
1317 executeViewHandlerRender(facesContext);
1318 executeAfterRender(facesContext);
1319
1320 DynamicBean bean = facesContext.getApplication().evaluateExpressionGet(
1321 facesContext, "#{dynamicBean}", DynamicBean.class);
1322 bean.setResource1(true);
1323
1324 endRequest();
1325
1326 startViewRequest("/dynPageResource.xhtml");
1327 processLifecycleExecute();
1328 locale = facesContext.getViewRoot().getLocale();
1329
1330 executeBeforeRender(facesContext);
1331 executeBuildViewCycle(facesContext);
1332
1333 UIOutput testjs1_1 = (UIOutput) facesContext.getViewRoot().findComponent("testjs");
1334 Assert.assertNotNull(testjs1_1);
1335 testjs1_1.getAttributes().put("param1", "value1");
1336
1337 List<UIComponent> crlist = facesContext.getViewRoot().getComponentResources(facesContext, "head");
1338 Assert.assertEquals(2, crlist.size());
1339 for(UIComponent comp : crlist)
1340 {
1341 comp.getAttributes().put("param2", "value2");
1342 }
1343
1344 UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
1345
1346 bean.setResource1(false);
1347
1348 executeViewHandlerRender(facesContext);
1349 executeAfterRender(facesContext);
1350
1351 client.submit(submitButton);
1352
1353 processLifecycleExecute();
1354
1355 UIOutput testjs2_1 = (UIOutput) facesContext.getViewRoot().findComponent("testjs");
1356 Assert.assertNotNull(testjs2_1);
1357
1358 Assert.assertEquals("value1",testjs2_1.getAttributes().get("param1"));
1359
1360 List<UIComponent> crlist2 = facesContext.getViewRoot().getComponentResources(facesContext, "head");
1361 Assert.assertEquals(2, crlist2.size());
1362
1363
1364
1365
1366
1367
1368
1369 executeBeforeRender(facesContext);
1370 executeBuildViewCycle(facesContext);
1371
1372 UIViewRoot root = new UIViewRoot();
1373 root.setLocale(locale);
1374 root.setRenderKitId("HTML_BASIC");
1375 root.setViewId("/dynPageResource.xhtml");
1376
1377 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1378 ViewPool viewPool = processor.getViewPool(facesContext, root);
1379 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
1380
1381 Assert.assertNull(entry);
1382 }
1383
1384 @Test
1385 public void testStaticPageBinding1() throws Exception
1386 {
1387 Locale locale = null;
1388 startViewRequest("/staticPageBinding1.xhtml");
1389 processLifecycleExecute();
1390 locale = facesContext.getViewRoot().getLocale();
1391 executeBeforeRender(facesContext);
1392 executeBuildViewCycle(facesContext);
1393
1394 UIPanel panel1 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel1");
1395 Assert.assertNotNull(panel1);
1396
1397 executeViewHandlerRender(facesContext);
1398 executeAfterRender(facesContext);
1399
1400 UIViewRoot root = new UIViewRoot();
1401 root.setLocale(locale);
1402 root.setRenderKitId("HTML_BASIC");
1403 root.setViewId("/staticPageBinding1.xhtml");
1404
1405 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1406 ViewPool viewPool = processor.getViewPool(facesContext, root);
1407 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
1408 Assert.assertNotNull(entry);
1409 Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
1410 endRequest();
1411 }
1412
1413 @Test
1414 public void testStaticPageBinding1_1() throws Exception
1415 {
1416 Locale locale = null;
1417 startViewRequest("/staticPageBinding1.xhtml");
1418 processLifecycleExecute();
1419 locale = facesContext.getViewRoot().getLocale();
1420
1421 executeBuildViewCycle(facesContext);
1422 UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
1423
1424 UIPanel panel1 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel1");
1425 Assert.assertNotNull(panel1);
1426
1427 executeViewHandlerRender(facesContext);
1428 executeAfterRender(facesContext);
1429
1430 client.submit(submitButton);
1431
1432 processLifecycleExecute();
1433
1434 UIPanel panel2_1 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel1");
1435 Assert.assertNotNull(panel2_1);
1436
1437 FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get(
1438 ComponentSupport.FACELET_STATE_INSTANCE);
1439
1440 UIViewRoot root = new UIViewRoot();
1441 root.setLocale(locale);
1442 root.setRenderKitId("HTML_BASIC");
1443 root.setViewId("/staticPageBinding1.xhtml");
1444
1445 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1446 ViewPool viewPool = processor.getViewPool(facesContext, root);
1447
1448 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
1449 Assert.assertNull(entry2);
1450 ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState);
1451 Assert.assertNull(entry3);
1452
1453 }
1454
1455 @Test
1456 public void testStaticPageBinding2() throws Exception
1457 {
1458 Locale locale = null;
1459 startViewRequest("/staticPageBinding2.xhtml");
1460 processLifecycleExecute();
1461 locale = facesContext.getViewRoot().getLocale();
1462
1463 executeBeforeRender(facesContext);
1464 executeBuildViewCycle(facesContext);
1465
1466 UIPanel panel1_2 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel2");
1467 Assert.assertNotNull(panel1_2);
1468 Assert.assertEquals(1, panel1_2.getChildCount());
1469 Assert.assertEquals("added component through binding",
1470 panel1_2.getChildren().get(0).getAttributes().get("value"));
1471
1472 executeViewHandlerRender(facesContext);
1473 executeAfterRender(facesContext);
1474
1475 UIViewRoot root = new UIViewRoot();
1476 root.setLocale(locale);
1477 root.setRenderKitId("HTML_BASIC");
1478 root.setViewId("/staticPageBinding2.xhtml");
1479
1480 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1481 ViewPool viewPool = processor.getViewPool(facesContext, root);
1482 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
1483 Assert.assertNotNull(entry);
1484 Assert.assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult());
1485 endRequest();
1486 }
1487
1488 @Test
1489 public void testStaticPageBinding2_1() throws Exception
1490 {
1491 Locale locale = null;
1492 startViewRequest("/staticPageBinding2.xhtml");
1493 processLifecycleExecute();
1494 locale = facesContext.getViewRoot().getLocale();
1495
1496 executeBuildViewCycle(facesContext);
1497
1498 UIPanel panel1_2 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel2");
1499 Assert.assertNotNull(panel1_2);
1500 Assert.assertEquals(1, panel1_2.getChildCount());
1501 Assert.assertEquals("added component through binding",
1502 panel1_2.getChildren().get(0).getAttributes().get("value"));
1503
1504 UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
1505
1506 executeViewHandlerRender(facesContext);
1507 executeAfterRender(facesContext);
1508
1509 client.submit(submitButton);
1510
1511 processLifecycleExecute();
1512
1513 UIPanel panel2_2 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel2");
1514 Assert.assertNotNull(panel2_2);
1515 Assert.assertEquals(1, panel2_2.getChildCount());
1516 Assert.assertEquals("added component through binding",
1517 panel2_2.getChildren().get(0).getAttributes().get("value"));
1518
1519 FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get(
1520 ComponentSupport.FACELET_STATE_INSTANCE);
1521
1522 UIViewRoot root = new UIViewRoot();
1523 root.setLocale(locale);
1524 root.setRenderKitId("HTML_BASIC");
1525 root.setViewId("/staticPageBinding2.xhtml");
1526
1527 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1528 ViewPool viewPool = processor.getViewPool(facesContext, root);
1529
1530 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
1531 Assert.assertNull(entry2);
1532 ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState);
1533 Assert.assertNull(entry3);
1534 }
1535
1536 @Test
1537 public void testStaticPageBinding3() throws Exception
1538 {
1539 Locale locale = null;
1540 startViewRequest("/staticPageBinding3.xhtml");
1541 processLifecycleExecute();
1542 locale = facesContext.getViewRoot().getLocale();
1543
1544 executeBeforeRender(facesContext);
1545 executeBuildViewCycle(facesContext);
1546
1547 UIPanel panel1_3 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel3");
1548 Assert.assertNotNull(panel1_3);
1549 Assert.assertEquals(1, panel1_3.getChildCount());
1550 Assert.assertEquals("added component through binding",
1551 panel1_3.getChildren().get(0).getAttributes().get("value"));
1552
1553 executeViewHandlerRender(facesContext);
1554 executeAfterRender(facesContext);
1555
1556 UIViewRoot root = new UIViewRoot();
1557 root.setLocale(locale);
1558 root.setRenderKitId("HTML_BASIC");
1559 root.setViewId("/staticPageBinding3.xhtml");
1560
1561 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1562 ViewPool viewPool = processor.getViewPool(facesContext, root);
1563 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
1564 Assert.assertNotNull(entry);
1565 Assert.assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult());
1566 endRequest();
1567 }
1568
1569 @Test
1570 public void testStaticPageBinding3_1() throws Exception
1571 {
1572 Locale locale = null;
1573 startViewRequest("/staticPageBinding3.xhtml");
1574 processLifecycleExecute();
1575 locale = facesContext.getViewRoot().getLocale();
1576
1577 executeBuildViewCycle(facesContext);
1578
1579 UIPanel panel1_3 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel3");
1580 Assert.assertNotNull(panel1_3);
1581 Assert.assertEquals(1, panel1_3.getChildCount());
1582 Assert.assertEquals("added component through binding",
1583 panel1_3.getChildren().get(0).getAttributes().get("value"));
1584
1585 UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
1586
1587 executeViewHandlerRender(facesContext);
1588 executeAfterRender(facesContext);
1589
1590 client.submit(submitButton);
1591
1592 processLifecycleExecute();
1593
1594 UIPanel panel2_3 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel3");
1595 Assert.assertNotNull(panel2_3);
1596 Assert.assertEquals(1, panel2_3.getChildCount());
1597 Assert.assertEquals("added component through binding",
1598 panel2_3.getChildren().get(0).getAttributes().get("value"));
1599
1600 FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get(
1601 ComponentSupport.FACELET_STATE_INSTANCE);
1602
1603 UIViewRoot root = new UIViewRoot();
1604 root.setLocale(locale);
1605 root.setRenderKitId("HTML_BASIC");
1606 root.setViewId("/staticPageBinding3.xhtml");
1607
1608 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1609 ViewPool viewPool = processor.getViewPool(facesContext, root);
1610
1611 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
1612 Assert.assertNull(entry2);
1613 ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState);
1614 Assert.assertNull(entry3);
1615 }
1616
1617 @Test
1618 public void testStaticPageBinding4() throws Exception
1619 {
1620 Locale locale = null;
1621 startViewRequest("/staticPageBinding4.xhtml");
1622 processLifecycleExecute();
1623 locale = facesContext.getViewRoot().getLocale();
1624
1625 executeBeforeRender(facesContext);
1626 executeBuildViewCycle(facesContext);
1627
1628 UIPanel panel1_4 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel4");
1629 Assert.assertNotNull(panel1_4);
1630 Assert.assertEquals(1, panel1_4.getChildCount());
1631
1632 executeViewHandlerRender(facesContext);
1633 executeAfterRender(facesContext);
1634
1635 UIViewRoot root = new UIViewRoot();
1636 root.setLocale(locale);
1637 root.setRenderKitId("HTML_BASIC");
1638 root.setViewId("/staticPageBinding4.xhtml");
1639
1640 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1641 ViewPool viewPool = processor.getViewPool(facesContext, root);
1642 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
1643 Assert.assertNotNull(entry);
1644 Assert.assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult());
1645 endRequest();
1646 }
1647
1648 @Test
1649 public void testStaticPageBinding4_1() throws Exception
1650 {
1651 Locale locale = null;
1652 startViewRequest("/staticPageBinding4.xhtml");
1653 processLifecycleExecute();
1654 locale = facesContext.getViewRoot().getLocale();
1655
1656 executeBuildViewCycle(facesContext);
1657
1658 UIPanel panel1_4 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel4");
1659 Assert.assertNotNull(panel1_4);
1660 Assert.assertEquals(1, panel1_4.getChildCount());
1661
1662 UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
1663
1664 executeViewHandlerRender(facesContext);
1665 executeAfterRender(facesContext);
1666
1667 client.submit(submitButton);
1668
1669 processLifecycleExecute();
1670
1671 UIPanel panel2_4 = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel4");
1672 Assert.assertNotNull(panel2_4);
1673 Assert.assertEquals(1, panel2_4.getChildCount());
1674
1675 FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get(
1676 ComponentSupport.FACELET_STATE_INSTANCE);
1677
1678 UIViewRoot root = new UIViewRoot();
1679 root.setLocale(locale);
1680 root.setRenderKitId("HTML_BASIC");
1681 root.setViewId("/staticPageBinding4.xhtml");
1682
1683 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1684 ViewPool viewPool = processor.getViewPool(facesContext, root);
1685
1686 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
1687 Assert.assertNull(entry2);
1688 ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState);
1689 Assert.assertNull(entry3);
1690 }
1691
1692 @Test
1693 public void testStaticPageBindingValidator1() throws Exception
1694 {
1695 Locale locale = null;
1696 startViewRequest("/staticPageBindingValidator1.xhtml");
1697 processLifecycleExecute();
1698 locale = facesContext.getViewRoot().getLocale();
1699 executeBeforeRender(facesContext);
1700 executeBuildViewCycle(facesContext);
1701
1702 executeViewHandlerRender(facesContext);
1703 executeAfterRender(facesContext);
1704
1705 UIViewRoot root = new UIViewRoot();
1706 root.setLocale(locale);
1707 root.setRenderKitId("HTML_BASIC");
1708 root.setViewId("/staticPageBindingValidator1.xhtml");
1709
1710 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1711 ViewPool viewPool = processor.getViewPool(facesContext, root);
1712 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
1713 Assert.assertNotNull(entry);
1714 Assert.assertEquals(RestoreViewFromPoolResult.COMPLETE, entry.getResult());
1715 endRequest();
1716 }
1717
1718 @Test
1719 public void testStaticPageBindingValidator1_1() throws Exception
1720 {
1721 Locale locale = null;
1722 startViewRequest("/staticPageBindingValidator1.xhtml");
1723 processLifecycleExecute();
1724 locale = facesContext.getViewRoot().getLocale();
1725
1726 executeBuildViewCycle(facesContext);
1727 UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
1728
1729 executeViewHandlerRender(facesContext);
1730 executeAfterRender(facesContext);
1731
1732 client.submit(submitButton);
1733
1734 processLifecycleExecute();
1735
1736 FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get(
1737 ComponentSupport.FACELET_STATE_INSTANCE);
1738
1739 UIViewRoot root = new UIViewRoot();
1740 root.setLocale(locale);
1741 root.setRenderKitId("HTML_BASIC");
1742 root.setViewId("/staticPageBindingValidator1.xhtml");
1743
1744 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1745 ViewPool viewPool = processor.getViewPool(facesContext, root);
1746
1747 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
1748 Assert.assertNull(entry2);
1749 ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState);
1750 Assert.assertNull(entry3);
1751
1752 }
1753
1754
1755
1756
1757
1758
1759
1760
1761 @Test
1762 public void testStaticPageStateHolderConverter1() throws Exception
1763 {
1764 Locale locale = null;
1765 startViewRequest("/staticPageStateHolderConverter1.xhtml");
1766 processLifecycleExecute();
1767 locale = facesContext.getViewRoot().getLocale();
1768 executeBeforeRender(facesContext);
1769 executeBuildViewCycle(facesContext);
1770
1771 executeViewHandlerRender(facesContext);
1772 executeAfterRender(facesContext);
1773
1774 UIViewRoot root = new UIViewRoot();
1775 root.setLocale(locale);
1776 root.setRenderKitId("HTML_BASIC");
1777 root.setViewId("/staticPageStateHolderConverter1.xhtml");
1778
1779 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1780 ViewPool viewPool = processor.getViewPool(facesContext, root);
1781 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
1782 Assert.assertNotNull(entry);
1783 Assert.assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult());
1784 endRequest();
1785 }
1786
1787 @Test
1788 public void testStaticPageStateHolderConverter1_1() throws Exception
1789 {
1790 Locale locale = null;
1791 startViewRequest("/staticPageStateHolderConverter1.xhtml");
1792 processLifecycleExecute();
1793 locale = facesContext.getViewRoot().getLocale();
1794
1795 executeBuildViewCycle(facesContext);
1796 UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
1797
1798 executeViewHandlerRender(facesContext);
1799 executeAfterRender(facesContext);
1800
1801 client.submit(submitButton);
1802
1803 processLifecycleExecute();
1804
1805 FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get(
1806 ComponentSupport.FACELET_STATE_INSTANCE);
1807
1808 UIViewRoot root = new UIViewRoot();
1809 root.setLocale(locale);
1810 root.setRenderKitId("HTML_BASIC");
1811 root.setViewId("/staticPageStateHolderConverter1.xhtml");
1812
1813 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1814 ViewPool viewPool = processor.getViewPool(facesContext, root);
1815
1816 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
1817 Assert.assertNull(entry2);
1818 ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState);
1819 Assert.assertNull(entry3);
1820
1821 }
1822
1823
1824
1825
1826
1827
1828
1829
1830 @Test
1831 public void testStaticPageStateHolderConverter2() throws Exception
1832 {
1833 Locale locale = null;
1834 startViewRequest("/staticPageStateHolderConverter2.xhtml");
1835 processLifecycleExecute();
1836 locale = facesContext.getViewRoot().getLocale();
1837 executeBeforeRender(facesContext);
1838 executeBuildViewCycle(facesContext);
1839
1840 executeViewHandlerRender(facesContext);
1841 executeAfterRender(facesContext);
1842
1843 UIViewRoot root = new UIViewRoot();
1844 root.setLocale(locale);
1845 root.setRenderKitId("HTML_BASIC");
1846 root.setViewId("/staticPageStateHolderConverter2.xhtml");
1847
1848 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1849 ViewPool viewPool = processor.getViewPool(facesContext, root);
1850 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
1851 Assert.assertNotNull(entry);
1852 Assert.assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult());
1853 endRequest();
1854 }
1855
1856 @Test
1857 public void testStaticPageStateHolderConverter2_1() throws Exception
1858 {
1859 Locale locale = null;
1860 startViewRequest("/staticPageStateHolderConverter2.xhtml");
1861 processLifecycleExecute();
1862 locale = facesContext.getViewRoot().getLocale();
1863
1864 executeBuildViewCycle(facesContext);
1865 UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
1866
1867 executeViewHandlerRender(facesContext);
1868 executeAfterRender(facesContext);
1869
1870 client.submit(submitButton);
1871
1872 processLifecycleExecute();
1873
1874 FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get(
1875 ComponentSupport.FACELET_STATE_INSTANCE);
1876
1877 UIViewRoot root = new UIViewRoot();
1878 root.setLocale(locale);
1879 root.setRenderKitId("HTML_BASIC");
1880 root.setViewId("/staticPageStateHolderConverter2.xhtml");
1881
1882 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1883 ViewPool viewPool = processor.getViewPool(facesContext, root);
1884
1885 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
1886 Assert.assertNull(entry2);
1887 ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState);
1888 Assert.assertNull(entry3);
1889
1890 }
1891
1892 @Test
1893 public void testPartialPage1() throws Exception
1894 {
1895 Locale locale = null;
1896 startViewRequest("/partialPage1.xhtml");
1897 processLifecycleExecute();
1898 locale = facesContext.getViewRoot().getLocale();
1899
1900 executeBeforeRender(facesContext);
1901 executeBuildViewCycle(facesContext);
1902
1903
1904
1905
1906 UIPanel panel = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel1");
1907
1908 panel.getParent().getChildren().remove(panel);
1909
1910 executeViewHandlerRender(facesContext);
1911 executeAfterRender(facesContext);
1912
1913 UIViewRoot root = new UIViewRoot();
1914 root.setLocale(locale);
1915 root.setRenderKitId("HTML_BASIC");
1916 root.setViewId("/partialPage1.xhtml");
1917
1918 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1919 ViewPool viewPool = processor.getViewPool(facesContext, root);
1920 ViewEntry entry = viewPool.popStaticOrPartialStructureView(facesContext, root);
1921 Assert.assertNotNull(entry);
1922 Assert.assertEquals(RestoreViewFromPoolResult.REFRESH_REQUIRED, entry.getResult());
1923 endRequest();
1924 }
1925
1926 @Test
1927 public void testPartialPage1_1() throws Exception
1928 {
1929 Locale locale = null;
1930 startViewRequest("/partialPage1.xhtml");
1931 processLifecycleExecute();
1932 locale = facesContext.getViewRoot().getLocale();
1933
1934 executeBuildViewCycle(facesContext);
1935
1936
1937
1938
1939 UIPanel panel = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel1");
1940 panel.getParent().getChildren().remove(panel);
1941
1942 UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
1943
1944 executeViewHandlerRender(facesContext);
1945 executeAfterRender(facesContext);
1946
1947 client.submit(submitButton);
1948
1949 processLifecycleExecute();
1950
1951 FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get(
1952 ComponentSupport.FACELET_STATE_INSTANCE);
1953
1954 UIViewRoot root = new UIViewRoot();
1955 root.setLocale(locale);
1956 root.setRenderKitId("HTML_BASIC");
1957 root.setViewId("/partialPage1.xhtml");
1958
1959 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
1960 ViewPool viewPool = processor.getViewPool(facesContext, root);
1961
1962 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
1963 Assert.assertNull(entry2);
1964 ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState);
1965 Assert.assertNull(entry3);
1966
1967 }
1968
1969 @Test
1970 public void testPartialPage1_2() throws Exception
1971 {
1972 Locale locale = null;
1973 startViewRequest("/partialPage1.xhtml");
1974 processLifecycleExecute();
1975 locale = facesContext.getViewRoot().getLocale();
1976
1977 executeBuildViewCycle(facesContext);
1978
1979
1980
1981
1982 UIPanel panel = (UIPanel) facesContext.getViewRoot().findComponent("mainForm:panel1");
1983 panel.getParent().getChildren().remove(panel);
1984
1985 facesContext.getViewRoot().getViewMap().put("someKey", "someValue");
1986
1987 UICommand submitButton = (UICommand) facesContext.getViewRoot().findComponent("mainForm:submit");
1988
1989 executeViewHandlerRender(facesContext);
1990 executeAfterRender(facesContext);
1991
1992 client.submit(submitButton);
1993
1994 processLifecycleExecute();
1995
1996 Assert.assertEquals("someValue", facesContext.getViewRoot().getViewMap().get("someKey"));
1997
1998 FaceletState faceletState = (FaceletState) facesContext.getViewRoot().getAttributes().get(
1999 ComponentSupport.FACELET_STATE_INSTANCE);
2000
2001 UIViewRoot root = new UIViewRoot();
2002 root.setLocale(locale);
2003 root.setRenderKitId("HTML_BASIC");
2004 root.setViewId("/partialPage1.xhtml");
2005
2006 ViewPoolProcessor processor = ViewPoolProcessor.getInstance(facesContext);
2007 ViewPool viewPool = processor.getViewPool(facesContext, root);
2008
2009 ViewEntry entry2 = viewPool.popStaticOrPartialStructureView(facesContext, root);
2010 Assert.assertNull(entry2);
2011 ViewEntry entry3 = viewPool.popDynamicStructureView(facesContext, root, faceletState);
2012 Assert.assertNull(entry3);
2013
2014 }
2015
2016
2017
2018
2019 }