1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.application.flow;
20
21 import javax.el.ExpressionFactory;
22 import javax.faces.application.ConfigurableNavigationHandler;
23 import javax.faces.application.NavigationCase;
24 import javax.faces.application.StateManager;
25 import javax.faces.component.UICommand;
26 import javax.faces.flow.Flow;
27 import javax.faces.flow.FlowHandler;
28 import javax.faces.render.ResponseStateManager;
29 import org.apache.myfaces.mc.test.core.AbstractMyFacesRequestTestCase;
30 import org.apache.myfaces.shared.config.MyfacesConfig;
31 import org.junit.Assert;
32 import org.junit.Test;
33
34
35
36
37
38 public class FlowMyFacesRequestTestCase extends AbstractMyFacesRequestTestCase
39 {
40
41 @Override
42 protected boolean isScanAnnotations()
43 {
44 return true;
45 }
46
47 @Override
48 protected void setUpWebConfigParams() throws Exception
49 {
50 super.setUpWebConfigParams();
51 servletContext.addInitParameter("org.apache.myfaces.annotation.SCAN_PACKAGES","org.apache.myfaces.application.flow");
52 servletContext.addInitParameter(StateManager.STATE_SAVING_METHOD_PARAM_NAME, StateManager.STATE_SAVING_METHOD_CLIENT);
53 servletContext.addInitParameter("javax.faces.PARTIAL_STATE_SAVING", "true");
54 servletContext.addInitParameter(MyfacesConfig.INIT_PARAM_REFRESH_TRANSIENT_BUILD_ON_PSS, "auto");
55 servletContext.addInitParameter("javax.faces.CONFIG_FILES", "/WEB-INF/flow1-flow.xml");
56 servletContext.addInitParameter("javax.faces.CLIENT_WINDOW_MODE", "url");
57 }
58
59 @Test
60 public void testFlow1_1() throws Exception
61 {
62 startViewRequest("/flow1_1.xhtml");
63 processLifecycleExecute();
64
65 ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
66
67 NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow1");
68
69 Assert.assertNotNull(navCase);
70
71 NavigationCase contentCase = handler.getNavigationCase(facesContext, null, "flow1_content");
72
73 Assert.assertNull(contentCase);
74
75
76 Assert.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext));
77
78 renderResponse();
79
80
81 UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow1");
82 client.submit(button);
83
84 processLifecycleExecute();
85
86 Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
87 Assert.assertNotNull(currentFlow);
88
89 contentCase = handler.getNavigationCase(facesContext, null, "flow1_content");
90
91 Assert.assertNotNull(contentCase);
92 }
93
94 @Test
95 public void testFlow1_2() throws Exception
96 {
97 startViewRequest("/flow1_2.xhtml");
98 processLifecycleExecute();
99
100 ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
101
102 NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow1");
103
104 Assert.assertNotNull(navCase);
105
106 NavigationCase contentCase = handler.getNavigationCase(facesContext, null, "flow1_content");
107
108 Assert.assertNull(contentCase);
109
110
111 Assert.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext));
112
113 renderResponse();
114
115
116 UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow1");
117 client.submit(button);
118
119 processLifecycleExecute();
120
121 Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
122 Assert.assertNotNull(currentFlow);
123 Assert.assertEquals("flow1", currentFlow.getId());
124
125 facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow1","value1");
126
127 renderResponse();
128
129 UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow2");
130 client.submit(button2);
131
132 processLifecycleExecute();
133
134 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
135 Assert.assertNotNull(currentFlow);
136 Assert.assertEquals("flow2", currentFlow.getId());
137 Assert.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1"));
138 facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow2","value2");
139
140 renderResponse();
141
142
143 Assert.assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId());
144
145 UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:content");
146 client.submit(button3);
147 processLifecycleExecute();
148 renderResponse();
149
150 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
151 Assert.assertNotNull(currentFlow);
152 Assert.assertEquals("flow2", currentFlow.getId());
153
154 NavigationCase endCase = handler.getNavigationCase(facesContext, null, "end");
155 Assert.assertNotNull(endCase);
156
157 UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:end_flow");
158 client.submit(button4);
159
160 processLifecycleExecute();
161
162
163
164
165 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
166 Assert.assertNull(currentFlow);
167 Assert.assertEquals("/flow1_end.xhtml", facesContext.getViewRoot().getViewId());
168 }
169
170 @Test
171 public void testFlow1_3() throws Exception
172 {
173 startViewRequest("/flow1_2.xhtml");
174 processLifecycleExecute();
175
176 ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
177
178 NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow1");
179
180 Assert.assertNotNull(navCase);
181
182 NavigationCase contentCase = handler.getNavigationCase(facesContext, null, "flow1_content");
183
184 Assert.assertNull(contentCase);
185
186
187 Assert.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext));
188
189 renderResponse();
190
191
192 UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow1");
193 client.submit(button);
194
195 processLifecycleExecute();
196
197 Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
198 Assert.assertNotNull(currentFlow);
199 Assert.assertEquals("flow1", currentFlow.getId());
200
201 facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow1","value1");
202
203 renderResponse();
204
205 UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow2");
206 client.submit(button2);
207
208 processLifecycleExecute();
209
210 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
211 Assert.assertNotNull(currentFlow);
212 Assert.assertEquals("flow2", currentFlow.getId());
213 Assert.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1"));
214 facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow2","value2");
215
216 renderResponse();
217
218
219 Assert.assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId());
220
221 UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:content");
222 client.submit(button3);
223 processLifecycleExecute();
224 renderResponse();
225
226 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
227 Assert.assertNotNull(currentFlow);
228 Assert.assertEquals("flow2", currentFlow.getId());
229
230 NavigationCase endCase = handler.getNavigationCase(facesContext, null, "back");
231 Assert.assertNotNull(endCase);
232
233 UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:back_flow");
234 client.submit(button4);
235
236 processLifecycleExecute();
237
238
239 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
240 Assert.assertNotNull(currentFlow);
241 Assert.assertEquals("flow1", currentFlow.getId());
242 Assert.assertTrue(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1"));
243
244 Assert.assertEquals("/flow1/begin.xhtml", facesContext.getViewRoot().getViewId());
245
246 renderResponse();
247
248 endCase = handler.getNavigationCase(facesContext, null, "back");
249 Assert.assertNotNull(endCase);
250
251 UICommand button5 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:back_flow");
252 client.submit(button5);
253
254 processLifecycleExecute();
255
256 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
257 Assert.assertNull(currentFlow);
258 Assert.assertEquals("/flow1_2.xhtml", facesContext.getViewRoot().getViewId());
259
260 }
261
262 @Test
263 public void testFlow1_4() throws Exception
264 {
265 startViewRequest("/flow1_2.xhtml");
266 processLifecycleExecute();
267
268 ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
269
270 NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow1");
271
272 Assert.assertNotNull(navCase);
273
274
275 Assert.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext));
276
277 renderResponse();
278
279
280 UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow1");
281 client.submit(button);
282
283 processLifecycleExecute();
284
285 Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
286 Assert.assertNotNull(currentFlow);
287 Assert.assertEquals("flow1", currentFlow.getId());
288
289 facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow1","value1");
290
291 renderResponse();
292
293 UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow2");
294 client.submit(button2);
295
296 processLifecycleExecute();
297
298 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
299 Assert.assertNotNull(currentFlow);
300 Assert.assertEquals("flow2", currentFlow.getId());
301 Assert.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1"));
302 facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow2","value2");
303
304 renderResponse();
305
306
307 Assert.assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId());
308
309 UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:content");
310 client.submit(button3);
311 processLifecycleExecute();
312 renderResponse();
313
314 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
315 Assert.assertNotNull(currentFlow);
316 Assert.assertEquals("flow2", currentFlow.getId());
317
318 NavigationCase endCase = handler.getNavigationCase(facesContext, null, "back");
319 Assert.assertNotNull(endCase);
320 String toViewId = endCase.getToViewId(facesContext);
321 String fromOutcome = endCase.getFromOutcome();
322 String clientWindowId = facesContext.getExternalContext().getClientWindow().getId();
323
324 endRequest();
325 startViewRequest(toViewId);
326 request.addParameter(FlowHandler.TO_FLOW_DOCUMENT_ID_REQUEST_PARAM_NAME, FlowHandler.NULL_FLOW);
327 request.addParameter(FlowHandler.FLOW_ID_REQUEST_PARAM_NAME, fromOutcome);
328 request.addParameter(ResponseStateManager.CLIENT_WINDOW_URL_PARAM, clientWindowId);
329
330 processLifecycleExecute();
331
332
333 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
334 Assert.assertNotNull(currentFlow);
335 Assert.assertEquals("flow1", currentFlow.getId());
336 Assert.assertTrue(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1"));
337
338
339
340 renderResponse();
341
342 endCase = handler.getNavigationCase(facesContext, null, "back");
343 Assert.assertNotNull(endCase);
344
345 toViewId = endCase.getToViewId(facesContext);
346 fromOutcome = endCase.getFromOutcome();
347 clientWindowId = facesContext.getExternalContext().getClientWindow().getId();
348
349 endRequest();
350 startViewRequest(toViewId);
351 request.addParameter(FlowHandler.TO_FLOW_DOCUMENT_ID_REQUEST_PARAM_NAME, FlowHandler.NULL_FLOW);
352 request.addParameter(FlowHandler.FLOW_ID_REQUEST_PARAM_NAME, fromOutcome);
353 request.addParameter(ResponseStateManager.CLIENT_WINDOW_URL_PARAM, clientWindowId);
354
355 processLifecycleExecute();
356
357 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
358 Assert.assertNull(currentFlow);
359 Assert.assertEquals("/flow1_2.xhtml", facesContext.getViewRoot().getViewId());
360 }
361
362 @Test
363 public void testFlow1_5() throws Exception
364 {
365 startViewRequest("/flow1_2.xhtml");
366 processLifecycleExecute();
367
368 ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
369
370 NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow3");
371
372 Assert.assertNotNull(navCase);
373
374
375 Assert.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext));
376
377 renderResponse();
378 String clientWindowId = facesContext.getExternalContext().getClientWindow().getId();
379
380 startViewRequest(navCase.getToViewId(facesContext));
381 request.addParameter(FlowHandler.TO_FLOW_DOCUMENT_ID_REQUEST_PARAM_NAME, navCase.getToFlowDocumentId());
382 request.addParameter(FlowHandler.FLOW_ID_REQUEST_PARAM_NAME, navCase.getFromOutcome());
383 request.addParameter(ResponseStateManager.CLIENT_WINDOW_URL_PARAM, clientWindowId);
384
385
386
387
388
389 processLifecycleExecute();
390
391 Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
392 Assert.assertNotNull(currentFlow);
393 Assert.assertEquals("flow1", currentFlow.getId());
394
395 facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow1","value1");
396
397 renderResponse();
398
399
400
401 navCase = handler.getNavigationCase(facesContext, null, "call_flow2");
402
403 clientWindowId = facesContext.getExternalContext().getClientWindow().getId();
404
405 startViewRequest(navCase.getToViewId(facesContext));
406 request.addParameter(FlowHandler.TO_FLOW_DOCUMENT_ID_REQUEST_PARAM_NAME, navCase.getToFlowDocumentId());
407 request.addParameter(FlowHandler.FLOW_ID_REQUEST_PARAM_NAME, navCase.getFromOutcome());
408 request.addParameter(ResponseStateManager.CLIENT_WINDOW_URL_PARAM, clientWindowId);
409
410 processLifecycleExecute();
411
412 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
413 Assert.assertNotNull(currentFlow);
414 Assert.assertEquals("flow2", currentFlow.getId());
415 Assert.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1"));
416 facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow2","value2");
417
418 renderResponse();
419
420
421 Assert.assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId());
422
423 UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:content");
424 client.submit(button3);
425 processLifecycleExecute();
426 renderResponse();
427
428 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
429 Assert.assertNotNull(currentFlow);
430 Assert.assertEquals("flow2", currentFlow.getId());
431
432 NavigationCase endCase = handler.getNavigationCase(facesContext, null, "back");
433 Assert.assertNotNull(endCase);
434 String toViewId = endCase.getToViewId(facesContext);
435 String fromOutcome = endCase.getFromOutcome();
436 clientWindowId = facesContext.getExternalContext().getClientWindow().getId();
437
438 endRequest();
439 startViewRequest(toViewId);
440 request.addParameter(FlowHandler.TO_FLOW_DOCUMENT_ID_REQUEST_PARAM_NAME, FlowHandler.NULL_FLOW);
441 request.addParameter(FlowHandler.FLOW_ID_REQUEST_PARAM_NAME, fromOutcome);
442 request.addParameter(ResponseStateManager.CLIENT_WINDOW_URL_PARAM, clientWindowId);
443
444 processLifecycleExecute();
445
446
447 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
448 Assert.assertNotNull(currentFlow);
449 Assert.assertEquals("flow1", currentFlow.getId());
450 Assert.assertTrue(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1"));
451
452 Assert.assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId());
453
454 renderResponse();
455
456 endCase = handler.getNavigationCase(facesContext, null, "switchBack");
457 Assert.assertNotNull(endCase);
458
459 toViewId = endCase.getToViewId(facesContext);
460
461 Assert.assertEquals(toViewId, "/flow3/content.xhtml");
462 fromOutcome = endCase.getFromOutcome();
463 clientWindowId = facesContext.getExternalContext().getClientWindow().getId();
464
465 endRequest();
466 startViewRequest(toViewId);
467 request.addParameter(FlowHandler.TO_FLOW_DOCUMENT_ID_REQUEST_PARAM_NAME, FlowHandler.NULL_FLOW);
468 request.addParameter(FlowHandler.FLOW_ID_REQUEST_PARAM_NAME, fromOutcome);
469 request.addParameter(ResponseStateManager.CLIENT_WINDOW_URL_PARAM, clientWindowId);
470
471 processLifecycleExecute();
472
473 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
474 Assert.assertNotNull(currentFlow);
475
476
477 }
478
479 protected ExpressionFactory createExpressionFactory()
480 {
481 return new org.apache.el.ExpressionFactoryImpl();
482 }
483
484
485
486
487
488
489
490
491
492
493
494
495
496 @Test
497 public void testFlow1_6() throws Exception
498 {
499 startViewRequest("/flow_base.xhtml");
500 processLifecycleExecute();
501
502 ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
503
504 NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow1");
505
506 Assert.assertNotNull(navCase);
507
508
509 Assert.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext));
510
511 renderResponse();
512
513
514 UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow1");
515 client.submit(button);
516
517 processLifecycleExecute();
518
519 Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
520 Assert.assertNotNull(currentFlow);
521 Assert.assertEquals(currentFlow.getId(), "flow1");
522
523 renderResponse();
524
525 NavigationCase goFlowBase = handler.getNavigationCase(facesContext, null, "flow_base");
526 Assert.assertNotNull(goFlowBase);
527
528 UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
529 client.submit(button2);
530
531 processLifecycleExecute();
532
533 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
534
535 renderResponse();
536
537 UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow2");
538 client.submit(button3);
539
540 processLifecycleExecute();
541
542 Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
543 Assert.assertNotNull(currentFlow2);
544 Assert.assertEquals(currentFlow2.getId(), "flow2");
545
546 renderResponse();
547
548 UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
549 client.submit(button4);
550
551 processLifecycleExecute();
552
553 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
554
555 renderResponse();
556
557 UICommand button5 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:returnFlow1");
558 client.submit(button5);
559
560 processLifecycleExecute();
561
562 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
563
564 Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
565 Assert.assertNotNull(currentFlow3);
566 Assert.assertEquals(currentFlow3.getId(), "flow2");
567
568 renderResponse();
569
570 UICommand button6 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:returnFlow2");
571 client.submit(button6);
572
573 processLifecycleExecute();
574
575 Flow currentFlow4 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
576 Assert.assertNull(currentFlow4);
577
578 renderResponse();
579 }
580
581
582
583
584
585
586
587
588
589
590
591
592 @Test
593 public void testFlow1_7() throws Exception
594 {
595 startViewRequest("/flow_base.xhtml");
596 processLifecycleExecute();
597
598 ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
599
600 NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow1");
601
602 Assert.assertNotNull(navCase);
603
604
605 Assert.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext));
606
607 renderResponse();
608
609
610 UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow1");
611 client.submit(button);
612
613 processLifecycleExecute();
614
615 Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
616 Assert.assertNotNull(currentFlow);
617 Assert.assertEquals(currentFlow.getId(), "flow1");
618
619 renderResponse();
620
621 UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow2");
622 client.submit(button3);
623
624 processLifecycleExecute();
625
626 Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
627 Assert.assertNotNull(currentFlow2);
628 Assert.assertEquals(currentFlow2.getId(), "flow2");
629
630 renderResponse();
631
632 UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
633 client.submit(button4);
634
635 processLifecycleExecute();
636
637 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
638
639 renderResponse();
640
641 UICommand button5 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:returnFlow1");
642 client.submit(button5);
643
644 processLifecycleExecute();
645
646 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
647
648 Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
649 Assert.assertNull(currentFlow3);
650 }
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665 @Test
666 public void testFlow1_8() throws Exception
667 {
668 startViewRequest("/flow_base.xhtml");
669 processLifecycleExecute();
670
671 ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
672
673 renderResponse();
674
675
676 UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow3");
677 client.submit(button);
678
679 processLifecycleExecute();
680
681 Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
682 Assert.assertNotNull(currentFlow);
683 Assert.assertEquals(currentFlow.getId(), "flow1");
684
685 renderResponse();
686
687 UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow2");
688 client.submit(button3);
689
690 processLifecycleExecute();
691
692 Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
693 Assert.assertNotNull(currentFlow2);
694 Assert.assertEquals(currentFlow2.getId(), "flow2");
695
696 renderResponse();
697
698 UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
699 client.submit(button4);
700
701 processLifecycleExecute();
702
703 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
704
705 renderResponse();
706
707 UICommand button5 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:returnFlow1");
708 client.submit(button5);
709
710 processLifecycleExecute();
711
712 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
713
714 Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
715 Assert.assertNotNull(currentFlow3);
716 Assert.assertEquals(currentFlow3.getId(), "flow3");
717 }
718
719
720
721
722
723
724
725
726
727
728
729 @Test
730 public void testFlow1_9() throws Exception
731 {
732 startViewRequest("/flow_base.xhtml");
733 processLifecycleExecute();
734
735 ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
736
737 renderResponse();
738
739
740 UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow2");
741 client.submit(button);
742
743 processLifecycleExecute();
744
745 Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
746 Assert.assertNotNull(currentFlow);
747 Assert.assertEquals(currentFlow.getId(), "flow2");
748
749 renderResponse();
750
751 NavigationCase goFlowBase = handler.getNavigationCase(facesContext, null, "flow_base");
752 Assert.assertNotNull(goFlowBase);
753
754 UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
755 client.submit(button2);
756
757 processLifecycleExecute();
758
759 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
760
761 renderResponse();
762
763 UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow3");
764 client.submit(button3);
765
766 processLifecycleExecute();
767
768 Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
769 Assert.assertNotNull(currentFlow2);
770 Assert.assertEquals(currentFlow2.getId(), "flow1");
771
772 renderResponse();
773
774 UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
775 client.submit(button4);
776
777 processLifecycleExecute();
778
779 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
780
781 renderResponse();
782
783 UICommand button5 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:returnFlow1_3");
784 client.submit(button5);
785
786 processLifecycleExecute();
787
788 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
789
790 Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
791 Assert.assertNotNull(currentFlow3);
792 Assert.assertEquals(currentFlow3.getId(), "flow2");
793
794 renderResponse();
795
796 UICommand button6 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:returnFlow2");
797 client.submit(button6);
798
799 processLifecycleExecute();
800
801 Flow currentFlow4 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
802 Assert.assertNull(currentFlow4);
803
804 renderResponse();
805 }
806
807
808
809
810
811
812
813
814
815
816
817 @Test
818 public void testFlow1_9_1() throws Exception
819 {
820 startViewRequest("/flow_base.xhtml");
821 processLifecycleExecute();
822
823 ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
824
825 renderResponse();
826
827
828 UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow2");
829 client.submit(button);
830
831 processLifecycleExecute();
832
833 Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
834 Assert.assertNotNull(currentFlow);
835 Assert.assertEquals(currentFlow.getId(), "flow2");
836
837 renderResponse();
838
839 NavigationCase goFlowBase = handler.getNavigationCase(facesContext, null, "flow_base");
840 Assert.assertNotNull(goFlowBase);
841
842 UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
843 client.submit(button2);
844
845 processLifecycleExecute();
846
847 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
848
849 renderResponse();
850
851 UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow3");
852 client.submit(button3);
853
854 processLifecycleExecute();
855
856 Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
857 Assert.assertNotNull(currentFlow2);
858 Assert.assertEquals(currentFlow2.getId(), "flow1");
859
860 renderResponse();
861
862 UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
863 client.submit(button4);
864
865 processLifecycleExecute();
866
867 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
868
869 renderResponse();
870
871
872
873
874 NavigationCase endCase = handler.getNavigationCase(facesContext, null, "back_flow_1_3");
875 Assert.assertNotNull(endCase);
876
877 String toViewId = endCase.getToViewId(facesContext);
878
879 Assert.assertEquals(toViewId, "/flow_base.xhtml");
880 String fromOutcome = endCase.getFromOutcome();
881 String clientWindowId = facesContext.getExternalContext().getClientWindow().getId();
882
883 endRequest();
884 startViewRequest(toViewId);
885 request.addParameter(FlowHandler.TO_FLOW_DOCUMENT_ID_REQUEST_PARAM_NAME, FlowHandler.NULL_FLOW);
886 request.addParameter(FlowHandler.FLOW_ID_REQUEST_PARAM_NAME, fromOutcome);
887 request.addParameter(ResponseStateManager.CLIENT_WINDOW_URL_PARAM, clientWindowId);
888
889 processLifecycleExecute();
890
891 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
892
893 Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
894 Assert.assertNotNull(currentFlow3);
895 Assert.assertEquals(currentFlow3.getId(), "flow2");
896
897 renderResponse();
898
899 UICommand button6 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:returnFlow2");
900 client.submit(button6);
901
902 processLifecycleExecute();
903
904 Flow currentFlow4 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
905 Assert.assertNull(currentFlow4);
906
907 renderResponse();
908 }
909
910
911
912
913
914
915
916
917
918
919
920
921 @Test
922 public void testFlow1_10() throws Exception
923 {
924 startViewRequest("/flow_base.xhtml");
925 processLifecycleExecute();
926
927 ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
928
929 renderResponse();
930
931
932 UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow3");
933 client.submit(button);
934
935 processLifecycleExecute();
936
937 Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
938 Assert.assertNotNull(currentFlow);
939 Assert.assertEquals(currentFlow.getId(), "flow1");
940
941 renderResponse();
942
943 NavigationCase goFlowBase = handler.getNavigationCase(facesContext, null, "flow_base");
944 Assert.assertNotNull(goFlowBase);
945
946 UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
947 client.submit(button2);
948
949 processLifecycleExecute();
950
951 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
952
953 renderResponse();
954
955 UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow2");
956 client.submit(button3);
957
958 processLifecycleExecute();
959
960 Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
961 Assert.assertNotNull(currentFlow2);
962 Assert.assertEquals(currentFlow2.getId(), "flow2");
963
964 renderResponse();
965
966 UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
967 client.submit(button4);
968
969 processLifecycleExecute();
970
971 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
972
973 renderResponse();
974
975 UICommand button5 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:returnFlow2");
976 client.submit(button5);
977
978 processLifecycleExecute();
979
980 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
981
982 Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
983 Assert.assertNotNull(currentFlow3);
984 Assert.assertEquals(currentFlow3.getId(), "flow1");
985
986 renderResponse();
987
988 UICommand button6 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:returnFlow1_3");
989 client.submit(button6);
990
991 processLifecycleExecute();
992
993 Flow currentFlow4 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
994 Assert.assertNull(currentFlow4);
995
996 renderResponse();
997 }
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009 @Test
1010 public void testFlow1_10_1() throws Exception
1011 {
1012 startViewRequest("/flow_base.xhtml");
1013 processLifecycleExecute();
1014
1015 ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
1016
1017 renderResponse();
1018
1019
1020 UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow3");
1021 client.submit(button);
1022
1023 processLifecycleExecute();
1024
1025 Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1026 Assert.assertNotNull(currentFlow);
1027 Assert.assertEquals(currentFlow.getId(), "flow1");
1028
1029 renderResponse();
1030
1031 NavigationCase goFlowBase = handler.getNavigationCase(facesContext, null, "flow_base");
1032 Assert.assertNotNull(goFlowBase);
1033
1034 UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
1035 client.submit(button2);
1036
1037 processLifecycleExecute();
1038
1039 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
1040
1041 renderResponse();
1042
1043 UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow2");
1044 client.submit(button3);
1045
1046 processLifecycleExecute();
1047
1048 Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1049 Assert.assertNotNull(currentFlow2);
1050 Assert.assertEquals(currentFlow2.getId(), "flow2");
1051
1052 renderResponse();
1053
1054 UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
1055 client.submit(button4);
1056
1057 processLifecycleExecute();
1058
1059 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
1060
1061 renderResponse();
1062
1063 UICommand button5 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:returnFlow1_3");
1064 client.submit(button5);
1065
1066 processLifecycleExecute();
1067
1068 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
1069
1070 Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1071 Assert.assertNotNull(currentFlow3);
1072 Assert.assertEquals(currentFlow3.getId(), "flow2");
1073
1074 renderResponse();
1075
1076 UICommand button6 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:returnFlow2");
1077 client.submit(button6);
1078
1079 processLifecycleExecute();
1080
1081 Flow currentFlow4 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1082 Assert.assertNull(currentFlow4);
1083
1084 renderResponse();
1085 }
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097 @Test
1098 public void testFlow1_10_2() throws Exception
1099 {
1100 startViewRequest("/flow_base.xhtml");
1101 processLifecycleExecute();
1102
1103 ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
1104
1105 renderResponse();
1106
1107
1108 UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow3");
1109 client.submit(button);
1110
1111 processLifecycleExecute();
1112
1113 Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1114 Assert.assertNotNull(currentFlow);
1115 Assert.assertEquals(currentFlow.getId(), "flow1");
1116
1117 renderResponse();
1118
1119 NavigationCase goFlowBase = handler.getNavigationCase(facesContext, null, "flow_base");
1120 Assert.assertNotNull(goFlowBase);
1121
1122 UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
1123 client.submit(button2);
1124
1125 processLifecycleExecute();
1126
1127 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
1128
1129 renderResponse();
1130
1131 UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow2");
1132 client.submit(button3);
1133
1134 processLifecycleExecute();
1135
1136 Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1137 Assert.assertNotNull(currentFlow2);
1138 Assert.assertEquals(currentFlow2.getId(), "flow2");
1139
1140 renderResponse();
1141
1142 UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
1143 client.submit(button4);
1144
1145 processLifecycleExecute();
1146
1147 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
1148
1149 renderResponse();
1150
1151
1152
1153 NavigationCase endCase = handler.getNavigationCase(facesContext, null, "back_flow_1_3");
1154 Assert.assertNotNull(endCase);
1155
1156 String toViewId = endCase.getToViewId(facesContext);
1157
1158 Assert.assertEquals(toViewId, "/flow_base.xhtml");
1159 String fromOutcome = endCase.getFromOutcome();
1160 String clientWindowId = facesContext.getExternalContext().getClientWindow().getId();
1161
1162 endRequest();
1163 startViewRequest(toViewId);
1164 request.addParameter(FlowHandler.TO_FLOW_DOCUMENT_ID_REQUEST_PARAM_NAME, FlowHandler.NULL_FLOW);
1165 request.addParameter(FlowHandler.FLOW_ID_REQUEST_PARAM_NAME, fromOutcome);
1166 request.addParameter(ResponseStateManager.CLIENT_WINDOW_URL_PARAM, clientWindowId);
1167
1168 processLifecycleExecute();
1169
1170 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
1171
1172 Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1173 Assert.assertNotNull(currentFlow3);
1174 Assert.assertEquals(currentFlow3.getId(), "flow2");
1175
1176 renderResponse();
1177
1178 UICommand button6 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:returnFlow2");
1179 client.submit(button6);
1180
1181 processLifecycleExecute();
1182
1183 Flow currentFlow4 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1184 Assert.assertNull(currentFlow4);
1185
1186 renderResponse();
1187 }
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200 @Test
1201 public void testFlow1_11() throws Exception
1202 {
1203 startViewRequest("/flow_base.xhtml");
1204 processLifecycleExecute();
1205
1206 ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
1207
1208 renderResponse();
1209
1210
1211 UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow4");
1212 client.submit(button);
1213
1214 processLifecycleExecute();
1215
1216 Assert.assertEquals("/flow4/flow4.xhtml", facesContext.getViewRoot().getViewId());
1217
1218 Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1219 Assert.assertNotNull(currentFlow);
1220 Assert.assertEquals(currentFlow.getId(), "flow4");
1221
1222 renderResponse();
1223
1224 NavigationCase goFlowBase = handler.getNavigationCase(facesContext, null, "flow_base");
1225 Assert.assertNotNull(goFlowBase);
1226
1227 UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
1228 client.submit(button2);
1229
1230 processLifecycleExecute();
1231
1232 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
1233
1234 renderResponse();
1235
1236 UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow2");
1237 client.submit(button3);
1238
1239 processLifecycleExecute();
1240
1241 Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1242 Assert.assertNotNull(currentFlow2);
1243 Assert.assertEquals(currentFlow2.getId(), "flow2");
1244
1245 renderResponse();
1246
1247 UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
1248 client.submit(button4);
1249
1250 processLifecycleExecute();
1251
1252 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
1253
1254 renderResponse();
1255
1256 UICommand button5 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow1_4");
1257 client.submit(button5);
1258
1259 processLifecycleExecute();
1260
1261 Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1262 Assert.assertNotNull(currentFlow3);
1263 Assert.assertEquals(currentFlow3.getId(), "flow1");
1264
1265 renderResponse();
1266
1267 UICommand button6 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
1268 client.submit(button6);
1269
1270 processLifecycleExecute();
1271
1272 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
1273
1274 renderResponse();
1275
1276
1277 UICommand button7 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:returnFlow1_4");
1278 client.submit(button7);
1279
1280 processLifecycleExecute();
1281
1282 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
1283
1284 Flow currentFlow4 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1285 Assert.assertNotNull(currentFlow4);
1286 Assert.assertEquals(currentFlow4.getId(), "flow2");
1287
1288 renderResponse();
1289
1290 UICommand button8 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:returnFlow2");
1291 client.submit(button8);
1292
1293 processLifecycleExecute();
1294
1295 Flow currentFlow5 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1296 Assert.assertNull(currentFlow5);
1297
1298 renderResponse();
1299
1300 }
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313 @Test
1314 public void testFlow1_11_1() throws Exception
1315 {
1316 startViewRequest("/flow_base.xhtml");
1317 processLifecycleExecute();
1318
1319 ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
1320
1321 renderResponse();
1322
1323
1324 UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow4");
1325 client.submit(button);
1326
1327 processLifecycleExecute();
1328
1329 Assert.assertEquals("/flow4/flow4.xhtml", facesContext.getViewRoot().getViewId());
1330
1331 Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1332 Assert.assertNotNull(currentFlow);
1333 Assert.assertEquals(currentFlow.getId(), "flow4");
1334
1335 renderResponse();
1336
1337 NavigationCase goFlowBase = handler.getNavigationCase(facesContext, null, "flow_base");
1338 Assert.assertNotNull(goFlowBase);
1339
1340 UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
1341 client.submit(button2);
1342
1343 processLifecycleExecute();
1344
1345 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
1346
1347 renderResponse();
1348
1349 UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow2");
1350 client.submit(button3);
1351
1352 processLifecycleExecute();
1353
1354 Flow currentFlow2 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1355 Assert.assertNotNull(currentFlow2);
1356 Assert.assertEquals(currentFlow2.getId(), "flow2");
1357
1358 renderResponse();
1359
1360 UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
1361 client.submit(button4);
1362
1363 processLifecycleExecute();
1364
1365 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
1366
1367 renderResponse();
1368
1369 UICommand button5 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow1_4");
1370 client.submit(button5);
1371
1372 processLifecycleExecute();
1373
1374 Flow currentFlow3 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1375 Assert.assertNotNull(currentFlow3);
1376 Assert.assertEquals(currentFlow3.getId(), "flow1");
1377
1378 renderResponse();
1379
1380 UICommand button6 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
1381 client.submit(button6);
1382
1383 processLifecycleExecute();
1384
1385 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
1386
1387 renderResponse();
1388
1389
1390
1391
1392 NavigationCase endCase = handler.getNavigationCase(facesContext, null, "back_flow_1_4");
1393 Assert.assertNotNull(endCase);
1394
1395 String toViewId = endCase.getToViewId(facesContext);
1396
1397 Assert.assertEquals(toViewId, "/flow_base.xhtml");
1398 String fromOutcome = endCase.getFromOutcome();
1399 String clientWindowId = facesContext.getExternalContext().getClientWindow().getId();
1400
1401 endRequest();
1402 startViewRequest(toViewId);
1403 request.addParameter(FlowHandler.TO_FLOW_DOCUMENT_ID_REQUEST_PARAM_NAME, FlowHandler.NULL_FLOW);
1404 request.addParameter(FlowHandler.FLOW_ID_REQUEST_PARAM_NAME, fromOutcome);
1405 request.addParameter(ResponseStateManager.CLIENT_WINDOW_URL_PARAM, clientWindowId);
1406
1407 processLifecycleExecute();
1408
1409 Assert.assertEquals("/flow_base.xhtml", facesContext.getViewRoot().getViewId());
1410
1411 Flow currentFlow4 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1412 Assert.assertNotNull(currentFlow4);
1413 Assert.assertEquals(currentFlow4.getId(), "flow2");
1414
1415 renderResponse();
1416
1417 UICommand button8 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:returnFlow2");
1418 client.submit(button8);
1419
1420 processLifecycleExecute();
1421
1422 Flow currentFlow5 = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1423 Assert.assertNull(currentFlow5);
1424
1425 renderResponse();
1426
1427 }
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440 @Test
1441 public void testFlowA_1() throws Exception
1442 {
1443 startViewRequest("/flow_base.xhtml");
1444 processLifecycleExecute();
1445
1446 ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
1447
1448 renderResponse();
1449
1450
1451 UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlowA");
1452 client.submit(button);
1453
1454 processLifecycleExecute();
1455
1456 facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowA","valueA_1");
1457 Assert.assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId());
1458
1459 Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1460 Assert.assertNotNull(currentFlow);
1461 Assert.assertEquals(currentFlow.getId(), "flowA");
1462
1463 renderResponse();
1464
1465 UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow_B");
1466 client.submit(button2);
1467
1468 processLifecycleExecute();
1469
1470 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1471 Assert.assertNotNull(currentFlow);
1472 Assert.assertEquals("flowB", currentFlow.getId());
1473 Assert.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowA"));
1474 facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowB","valueB_1");
1475
1476 renderResponse();
1477
1478
1479 Assert.assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId());
1480
1481 UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow_A");
1482 client.submit(button3);
1483
1484 processLifecycleExecute();
1485
1486 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1487 Assert.assertNotNull(currentFlow);
1488 Assert.assertEquals("flowA", currentFlow.getId());
1489 Assert.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowB"));
1490 facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowA","valueA_2");
1491
1492 renderResponse();
1493
1494
1495 Assert.assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId());
1496
1497 UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow_B");
1498 client.submit(button4);
1499
1500 processLifecycleExecute();
1501
1502 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1503 Assert.assertNotNull(currentFlow);
1504 Assert.assertEquals("flowB", currentFlow.getId());
1505 Assert.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowA"));
1506 facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowB","valueB_2");
1507
1508 renderResponse();
1509
1510
1511 Assert.assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId());
1512
1513 UICommand button5 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:end_flow");
1514 client.submit(button5);
1515
1516 processLifecycleExecute();
1517
1518 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1519 Assert.assertNotNull(currentFlow);
1520 Assert.assertEquals("flowA", currentFlow.getId());
1521 Assert.assertEquals("valueA_2", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA"));
1522
1523 renderResponse();
1524
1525 UICommand button6 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:end_flow");
1526 client.submit(button6);
1527
1528 processLifecycleExecute();
1529
1530 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1531 Assert.assertNotNull(currentFlow);
1532 Assert.assertEquals("flowB", currentFlow.getId());
1533 Assert.assertEquals("valueB_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowB"));
1534
1535 renderResponse();
1536
1537 UICommand button7 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:end_flow");
1538 client.submit(button7);
1539
1540 processLifecycleExecute();
1541
1542 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1543 Assert.assertNotNull(currentFlow);
1544 Assert.assertEquals("flowA", currentFlow.getId());
1545 Assert.assertEquals("valueA_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA"));
1546
1547 renderResponse();
1548 }
1549
1550 @Test
1551 public void testFlowA_2() throws Exception
1552 {
1553 startViewRequest("/flow_base.xhtml");
1554 processLifecycleExecute();
1555
1556 ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
1557
1558 renderResponse();
1559
1560
1561 UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlowA");
1562 client.submit(button);
1563
1564 processLifecycleExecute();
1565
1566 facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowA","valueA_1");
1567 Assert.assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId());
1568
1569 Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1570 Assert.assertNotNull(currentFlow);
1571 Assert.assertEquals(currentFlow.getId(), "flowA");
1572
1573 renderResponse();
1574
1575
1576 UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:go_flow_base");
1577 client.submit(button2);
1578
1579 processLifecycleExecute();
1580
1581 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1582 Assert.assertNotNull(currentFlow);
1583
1584 Assert.assertEquals("flowA", currentFlow.getId());
1585
1586 renderResponse();
1587
1588
1589 UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlowB");
1590 client.submit(button3);
1591
1592 processLifecycleExecute();
1593
1594 facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowB","valueB_1");
1595 Assert.assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId());
1596
1597 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1598 Assert.assertNotNull(currentFlow);
1599 Assert.assertEquals(currentFlow.getId(), "flowB");
1600
1601 renderResponse();
1602
1603
1604 UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow_A");
1605 client.submit(button4);
1606
1607 processLifecycleExecute();
1608
1609 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1610 Assert.assertNotNull(currentFlow);
1611 Assert.assertEquals("flowA", currentFlow.getId());
1612 Assert.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowB"));
1613 facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowA","valueA_2");
1614
1615 renderResponse();
1616
1617
1618 Assert.assertEquals("/flowA/flowA.xhtml", facesContext.getViewRoot().getViewId());
1619
1620
1621 UICommand button5 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow_B");
1622 client.submit(button5);
1623
1624 processLifecycleExecute();
1625
1626 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1627 Assert.assertNotNull(currentFlow);
1628 Assert.assertEquals("flowB", currentFlow.getId());
1629 Assert.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flowA"));
1630 facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flowB","valueB_2");
1631
1632 renderResponse();
1633
1634
1635 Assert.assertEquals("/flowB/flowB.xhtml", facesContext.getViewRoot().getViewId());
1636
1637 UICommand button6 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:end_flow");
1638 client.submit(button6);
1639
1640 processLifecycleExecute();
1641
1642 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1643 Assert.assertNotNull(currentFlow);
1644 Assert.assertEquals("flowA", currentFlow.getId());
1645 Assert.assertEquals("valueA_2", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA"));
1646
1647 renderResponse();
1648
1649 UICommand button7 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:end_flow");
1650 client.submit(button7);
1651
1652 processLifecycleExecute();
1653
1654 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1655 Assert.assertNotNull(currentFlow);
1656 Assert.assertEquals("flowB", currentFlow.getId());
1657 Assert.assertEquals("valueB_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowB"));
1658
1659 renderResponse();
1660
1661 UICommand button8 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:end_flow");
1662 client.submit(button8);
1663
1664 processLifecycleExecute();
1665
1666 currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
1667 Assert.assertNotNull(currentFlow);
1668 Assert.assertEquals("flowA", currentFlow.getId());
1669 Assert.assertEquals("valueA_1", facesContext.getApplication().getFlowHandler().getCurrentFlowScope().get("flowA"));
1670
1671 renderResponse();
1672
1673 }
1674
1675 }