public void testFlow1_2() throws Exception
{
setupRequest("/flow1_2.xhtml");
processLifecycleExecute();
ConfigurableNavigationHandler handler = (ConfigurableNavigationHandler) facesContext.getApplication().getNavigationHandler();
NavigationCase navCase = handler.getNavigationCase(facesContext, null, "flow1");
Assert.assertNotNull(navCase);
NavigationCase contentCase = handler.getNavigationCase(facesContext, null, "flow1_content");
Assert.assertNull(contentCase);
// Check begin view node
Assert.assertEquals("/flow1/begin.xhtml", navCase.getToViewId(facesContext));
processRender();
//Enter flow 1
UICommand button = (UICommand) facesContext.getViewRoot().findComponent("mainForm:startFlow1");
submit(button);
processLifecycleExecute();
Flow currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
Assert.assertNotNull(currentFlow);
Assert.assertEquals("flow1", currentFlow.getId());
facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow1","value1");
// Check the bean with @FlowScoped annotation can be instantiated
Flow1Bean bean1 = facesContext.getApplication().evaluateExpressionGet(
facesContext, "#{flow1Bean}", Flow1Bean.class);
Assert.assertNotNull(bean1);
Assert.assertEquals(bean1.getPostConstructCalled(), "true");
bean1.setName("John");
processRender();
UICommand button2 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:call_flow2");
submit(button2);
processLifecycleExecute();
currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
Assert.assertNotNull(currentFlow);
Assert.assertEquals("flow2", currentFlow.getId());
Assert.assertFalse(facesContext.getApplication().getFlowHandler().getCurrentFlowScope().containsKey("flow1"));
facesContext.getApplication().getFlowHandler().getCurrentFlowScope().put("flow2","value2");
Flow2Bean bean2 = facesContext.getApplication().evaluateExpressionGet(
facesContext, "#{flow2Bean}", Flow2Bean.class);
Assert.assertNotNull(bean2);
Assert.assertEquals(bean2.getPostConstructCalled(), "true");
Flow1Bean bean1_1 = facesContext.getApplication().evaluateExpressionGet(
facesContext, "#{flow1Bean}", Flow1Bean.class);
Assert.assertEquals(bean1_1.getName(), "John");
Flow21Bean bean2_1 = facesContext.getApplication().evaluateExpressionGet(
facesContext, "#{flow21Bean}", Flow21Bean.class);
Assert.assertNotNull(bean2_1);
Assert.assertEquals(bean2_1.getPostConstructCalled(), "true");
Assert.assertNotNull(bean2_1.getFlow1Bean());
processRender();
//Check current view is the begin of flow2
Assert.assertEquals("/flow2/begin.xhtml", facesContext.getViewRoot().getViewId());
UICommand button3 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:content");
submit(button3);
processLifecycleExecute();
processRender();
currentFlow = facesContext.getApplication().getFlowHandler().getCurrentFlow(facesContext);
Assert.assertNotNull(currentFlow);
Assert.assertEquals("flow2", currentFlow.getId());
NavigationCase endCase = handler.getNavigationCase(facesContext, null, "end");
Assert.assertNotNull(endCase);
UICommand button4 = (UICommand) facesContext.getViewRoot().findComponent("mainForm:end_flow");
submit(button4);