Author: schof
Date: Mon Sep  4 16:52:55 2006
New Revision: 440205

URL: http://svn.apache.org/viewvc?view=rev&rev=440205
Log:
Fixed a bug where navigation outcomes that were unrelated to the current dialog 
were being ignored. They're now delegated to the wrapped NavigationHandler.  
SHALE-275

Added:
    shale/sandbox/shale-dialog2/src/test/java/org/
    shale/sandbox/shale-dialog2/src/test/java/org/apache/
    shale/sandbox/shale-dialog2/src/test/java/org/apache/shale/
    shale/sandbox/shale-dialog2/src/test/java/org/apache/shale/dialog2/
    shale/sandbox/shale-dialog2/src/test/java/org/apache/shale/dialog2/faces/
    
shale/sandbox/shale-dialog2/src/test/java/org/apache/shale/dialog2/faces/Dialog2NavigationHandlerTest.java
   (with props)
Modified:
    shale/sandbox/shale-dialog2/pom.xml
    
shale/sandbox/shale-dialog2/src/main/java/org/apache/shale/dialog2/faces/Dialog2NavigationHandler.java

Modified: shale/sandbox/shale-dialog2/pom.xml
URL: 
http://svn.apache.org/viewvc/shale/sandbox/shale-dialog2/pom.xml?view=diff&rev=440205&r1=440204&r2=440205
==============================================================================
--- shale/sandbox/shale-dialog2/pom.xml (original)
+++ shale/sandbox/shale-dialog2/pom.xml Mon Sep  4 16:52:55 2006
@@ -53,6 +53,19 @@
         </dependency>
 -->
 
+                   <dependency>
+                             <groupId>org.apache.shale</groupId>
+                             <artifactId>shale-test</artifactId>
+                             <version>1.0.4-SNAPSHOT</version>
+                             <scope>test</scope>
+                   </dependency>  
+                   <dependency>
+                             <groupId>jmock</groupId>
+                             <artifactId>jmock-cglib</artifactId>
+                             <version>1.0.1</version>
+                             <scope>test</scope>
+                   </dependency>                   
+
     </dependencies>
 
 </project>

Modified: 
shale/sandbox/shale-dialog2/src/main/java/org/apache/shale/dialog2/faces/Dialog2NavigationHandler.java
URL: 
http://svn.apache.org/viewvc/shale/sandbox/shale-dialog2/src/main/java/org/apache/shale/dialog2/faces/Dialog2NavigationHandler.java?view=diff&rev=440205&r1=440204&r2=440205
==============================================================================
--- 
shale/sandbox/shale-dialog2/src/main/java/org/apache/shale/dialog2/faces/Dialog2NavigationHandler.java
 (original)
+++ 
shale/sandbox/shale-dialog2/src/main/java/org/apache/shale/dialog2/faces/Dialog2NavigationHandler.java
 Mon Sep  4 16:52:55 2006
@@ -135,6 +135,9 @@
                           + context + "' with navigation to viewId '"
                           + viewId + "'");
             }
+            if (viewId == null) {
+                original.handleNavigation(context, fromAction, outcome);
+            }
         }
         navigate(context, viewId);
 

Added: 
shale/sandbox/shale-dialog2/src/test/java/org/apache/shale/dialog2/faces/Dialog2NavigationHandlerTest.java
URL: 
http://svn.apache.org/viewvc/shale/sandbox/shale-dialog2/src/test/java/org/apache/shale/dialog2/faces/Dialog2NavigationHandlerTest.java?view=auto&rev=440205
==============================================================================
--- 
shale/sandbox/shale-dialog2/src/test/java/org/apache/shale/dialog2/faces/Dialog2NavigationHandlerTest.java
 (added)
+++ 
shale/sandbox/shale-dialog2/src/test/java/org/apache/shale/dialog2/faces/Dialog2NavigationHandlerTest.java
 Mon Sep  4 16:52:55 2006
@@ -0,0 +1,74 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.shale.dialog2.faces;
+
+import org.apache.shale.test.jmock.AbstractJmockJsfTestCase;
+import org.apache.shale.dialog2.DialogContext;
+import org.apache.shale.dialog2.Constants;
+import org.jmock.Mock;
+
+import javax.faces.application.NavigationHandler;
+import java.util.Map;
+
+
+/**
+ * @author Sean Schofield
+ */
+public class Dialog2NavigationHandlerTest extends AbstractJmockJsfTestCase {
+
+    private Mock mockNavigationHandler;
+    private Mock mockDialogContext;
+    private Dialog2NavigationHandler navigationHandler;
+
+    /** [EMAIL PROTECTED] */
+    public Dialog2NavigationHandlerTest(String s) {
+        super(s);
+    }
+
+    /** [EMAIL PROTECTED] */
+    public void setUp() throws Exception {
+        super.setUp();
+        mockNavigationHandler = mock(NavigationHandler.class);
+        mockDialogContext = mock(DialogContext.class);
+    }
+
+    /**
+     * Dialog2NavigationHandler should ignore navigation outcomes that do not 
correspond to a valid
+     * dialog transition.  These outcomes should be delegated to the wrapped 
NavigationHandler instead.
+     */
+    public void testHandleNavigationNullViewId() {
+
+        // the mock DialogContext will return null for its advance method
+        
mockDialogContext.expects(once()).method("getName").will(returnValue("foo 
dialog"));
+        
mockDialogContext.expects(once()).method("advance").will(returnValue(null));
+        Map requestMap = facesContext.getExternalContext().getRequestMap();
+        requestMap.put(Constants.CONTEXT_BEAN, mockDialogContext.proxy());
+
+        /**
+         * We expect our mock handler to be asked to deal with the outcome 
since the advance method indicates
+         * that no transition is to be performed.
+         */
+        mockNavigationHandler.expects(once()).method("handleNavigation");
+        navigationHandler = new 
Dialog2NavigationHandler((NavigationHandler)mockNavigationHandler.proxy());
+        navigationHandler.handleNavigation(facesContext, "foo action", "foo 
outcome");
+    }
+
+    /**
+     * If a dialog is in progress, periodic navigation outcomes that do not 
correspond to transitions should
+     * not alter the ability of the dialog to handle a transition outcome when 
it does finally encounter one.
+     */
+//    public void testHandleNavigationNullThenValidViewId() {
+//        TODO - add test
+//    }
+}

Propchange: 
shale/sandbox/shale-dialog2/src/test/java/org/apache/shale/dialog2/faces/Dialog2NavigationHandlerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to