super(name);
}
public void test()
{
NavigationHandler navigationHandler = _application.getNavigationHandler();
UIViewRoot viewRoot = new UIViewRoot();
// case 1: no from-view-id
viewRoot.setViewId("/anypage.jsp");
_facesContext.setViewRoot(viewRoot);
navigationHandler.handleNavigation(_facesContext, "#{anyaction}", "outcome1");
assertEquals(_facesContext.getViewRoot().getViewId(), "/page1.jsp");
// case 2: from-view-id = *, with from-outcome, no from-action
viewRoot.setViewId("/anypage.jsp");
_facesContext.setViewRoot(viewRoot);
navigationHandler.handleNavigation(_facesContext, "#{anyaction}", "outcome2");
assertEquals(_facesContext.getViewRoot().getViewId(), "/page2.jsp");
// case 3: from-view-id = *, with from-outcome and from-action
viewRoot.setViewId("/anypage.jsp");
_facesContext.setViewRoot(viewRoot);
navigationHandler.handleNavigation(_facesContext, "#{action3}", "outcome3");
assertEquals(_facesContext.getViewRoot().getViewId(), "/page3.jsp");
// case 4: from-view-id = *, no from-outcome, with from-action
viewRoot.setViewId("/anypage.jsp");
_facesContext.setViewRoot(viewRoot);
navigationHandler.handleNavigation(_facesContext, "#{action4}", "anyoutcome");
assertEquals(_facesContext.getViewRoot().getViewId(), "/page4.jsp");
// case 5: exact from-view-id match, with from-outcome, no from-action
viewRoot.setViewId("/from5.jsp");
_facesContext.setViewRoot(viewRoot);
navigationHandler.handleNavigation(_facesContext, "#{anyaction}", "outcome5");
assertEquals(_facesContext.getViewRoot().getViewId(), "/page5.jsp");
// case 6: wildcard from-view-id match, with from-outcome, no from-action
viewRoot.setViewId("/context6/anypage.jsp");
_facesContext.setViewRoot(viewRoot);
navigationHandler.handleNavigation(_facesContext, "#{anyaction}", "outcome6");
assertEquals(_facesContext.getViewRoot().getViewId(), "/page6.jsp");
// no match
viewRoot.setViewId("/anycontext/anypage.jsp");
_facesContext.setViewRoot(viewRoot);
navigationHandler.handleNavigation(_facesContext, "#{anyaction}", "anyoutcome");
assertEquals(_facesContext.getViewRoot().getViewId(), "/anycontext/anypage.jsp");
}