@@ -0,0 +1,2747 @@
+/*%0A * Copyright 2006 the original author or authors.%0A * %0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A * %0A *      http://www.apache.org/licenses/LICENSE-2.0%0A * %0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.springframework.web.jsf.navigation;%0A%0Aimport javax.faces.application.NavigationHandler;%0Aimport javax.faces.context.FacesContext;%0A%0Aimport junit.framework.TestCase;%0A%0Aimport org.springframework.beans.BeansException;%0Aimport org.springframework.web.jsf.MockFacesContext;%0A%0A/**%0A * Test for DelegatingNavigationHandler%0A * %0A * @author Colin Sampaleanu%0A */%0Apublic class DelegatingNavigationHandlerTests extends TestCase %7B%0A%0A%09public void testHandleNavigation() %7B%0A%0A%09%09MockFacesContext facesContext = new MockFacesContext();%0A%09%09final StaticMockNavigationHandler firstHandler = new StaticMockNavigationHandler(%0A%09%09%09%09new JsfChainingNavigationHandler());%0A%09%09StaticMockNavigationHandler jsfHandler = new StaticMockNavigationHandler();%0A%0A%09%09DelegatingNavigationHandler delNavHandler = new DelegatingNavigationHandler(%0A%09%09%09%09jsfHandler) %7B%0A%0A%09%09%09protected NavigationHandler getNavigationHandler(FacesContext facesContext)%0A%09%09%09%09%09throws BeansException %7B%0A%09%09%09%09return firstHandler;%0A%09%09%09%7D%0A%09%09%7D;%0A%0A%09%09delNavHandler.handleNavigation(facesContext, %22action%22, %22myViewId%22);%0A%09%09assertEquals(jsfHandler.lastFromAction, %22fromAction%22);%0A%09%09assertEquals(jsfHandler.lastOutcome, %22myViewId%22);%0A%09%7D%0A%0A%09public static class StaticMockNavigationHandler extends NavigationHandler %7B%0A%0A%09%09private NavigationHandler original;%0A%0A%09%09private String%09%09%09lastFromAction;%0A%0A%09%09private String%09%09%09lastOutcome;%0A%0A%09%09public StaticMockNavigationHandler() %7B%0A%09%09%7D%0A%0A%09%09public StaticMockNavigationHandler(NavigationHandler original) %7B%0A%09%09%09this.original = original;%0A%09%09%7D%0A%0A%09%09/**%0A         * @param facesContext%0A         *            %3Ccode%3EFacesContext%3C/code%3E for the current request%0A         * @param fromAction%0A         *            The action binding expression that was evaluated to%0A         *            retrieve the specified outcome (if any)%0A         * @param outcome%0A         *            The logical outcome returned by the specified action%0A         */%0A%09%09public void handleNavigation(FacesContext facesContext, String fromAction,%0A%09%09%09%09String outcome) %7B%0A%09%09%09lastFromAction = fromAction;%0A%09%09%09lastOutcome = outcome;%0A%09%09%09if (original != null)%0A%09%09%09%09original.handleNavigation(facesContext, fromAction, outcome);%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add a delegating JSF NavigationHandler implementation