1 16 package org.apache.myfaces.application; 17 18 import org.apache.myfaces.MyFacesBaseTest; 19 20 import javax.faces.application.NavigationHandler; 21 import javax.faces.component.UIViewRoot; 22 23 37 public class NavigationHandlerImplTest 38 extends MyFacesBaseTest 39 { 40 42 public NavigationHandlerImplTest(String name) 43 { 44 super(name); 45 } 46 47 public void test() 48 { 49 NavigationHandler navigationHandler = _application.getNavigationHandler(); 50 51 UIViewRoot viewRoot = new UIViewRoot(); 52 53 viewRoot.setViewId("/anypage.jsp"); 55 _facesContext.setViewRoot(viewRoot); 56 navigationHandler.handleNavigation(_facesContext, "#{anyaction}", "outcome1"); 57 assertEquals(_facesContext.getViewRoot().getViewId(), "/page1.jsp"); 58 59 viewRoot.setViewId("/anypage.jsp"); 61 _facesContext.setViewRoot(viewRoot); 62 navigationHandler.handleNavigation(_facesContext, "#{anyaction}", "outcome2"); 63 assertEquals(_facesContext.getViewRoot().getViewId(), "/page2.jsp"); 64 65 viewRoot.setViewId("/anypage.jsp"); 67 _facesContext.setViewRoot(viewRoot); 68 navigationHandler.handleNavigation(_facesContext, "#{action3}", "outcome3"); 69 assertEquals(_facesContext.getViewRoot().getViewId(), "/page3.jsp"); 70 71 viewRoot.setViewId("/anypage.jsp"); 73 _facesContext.setViewRoot(viewRoot); 74 navigationHandler.handleNavigation(_facesContext, "#{action4}", "anyoutcome"); 75 assertEquals(_facesContext.getViewRoot().getViewId(), "/page4.jsp"); 76 77 viewRoot.setViewId("/from5.jsp"); 79 _facesContext.setViewRoot(viewRoot); 80 navigationHandler.handleNavigation(_facesContext, "#{anyaction}", "outcome5"); 81 assertEquals(_facesContext.getViewRoot().getViewId(), "/page5.jsp"); 82 83 viewRoot.setViewId("/context6/anypage.jsp"); 85 _facesContext.setViewRoot(viewRoot); 86 navigationHandler.handleNavigation(_facesContext, "#{anyaction}", "outcome6"); 87 assertEquals(_facesContext.getViewRoot().getViewId(), "/page6.jsp"); 88 89 viewRoot.setViewId("/anycontext/anypage.jsp"); 91 _facesContext.setViewRoot(viewRoot); 92 navigationHandler.handleNavigation(_facesContext, "#{anyaction}", "anyoutcome"); 93 assertEquals(_facesContext.getViewRoot().getViewId(), "/anycontext/anypage.jsp"); 94 95 } 96 97 } 98 | Popular Tags |