click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r779281 - in /incubator/click/trunk/click: extras/test/org/apache/click/extras/tree/TreeTest.java framework/test/org/apache/click/control/FormTest.java mock/src/org/apache/click/MockContext.java mock/test/org/apache/click/MockRequestTest.java
Date Wed, 27 May 2009 19:33:50 GMT
Author: sabob
Date: Wed May 27 19:33:50 2009
New Revision: 779281

URL: http://svn.apache.org/viewvc?rev=779281&view=rev
Log:
updated tests to reflect Form insert changes and added new MockContext method executeActionListeners

Modified:
    incubator/click/trunk/click/extras/test/org/apache/click/extras/tree/TreeTest.java
    incubator/click/trunk/click/framework/test/org/apache/click/control/FormTest.java
    incubator/click/trunk/click/mock/src/org/apache/click/MockContext.java
    incubator/click/trunk/click/mock/test/org/apache/click/MockRequestTest.java

Modified: incubator/click/trunk/click/extras/test/org/apache/click/extras/tree/TreeTest.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/extras/test/org/apache/click/extras/tree/TreeTest.java?rev=779281&r1=779280&r2=779281&view=diff
==============================================================================
--- incubator/click/trunk/click/extras/test/org/apache/click/extras/tree/TreeTest.java (original)
+++ incubator/click/trunk/click/extras/test/org/apache/click/extras/tree/TreeTest.java Wed
May 27 19:33:50 2009
@@ -21,6 +21,7 @@
 import junit.framework.*;
 import java.util.List;
 import org.apache.click.MockContext;
+import org.apache.click.control.ActionLink;
 import org.apache.click.servlet.MockRequest;
 
 /**
@@ -52,6 +53,7 @@
     public void testExpandAndCollapse() {
         MockRequest mockRequest = mockContext.getMockRequest();
         mockRequest.setParameter(Tree.EXPAND_TREE_NODE_PARAM, testIds);
+        mockRequest.setParameter(ActionLink.ACTION_LINK, tree.getExpandLink().getName());
 
         assertExpandOrCollapse(tree, testIds, false);//test for expansion
         assertExpandOrCollapse(tree, testIds, true);//should reverse expand and collapse
@@ -63,6 +65,7 @@
     public void testSelectAndDeselect() {
         MockRequest mockRequest = mockContext.getMockRequest();
         mockRequest.setParameter(Tree.SELECT_TREE_NODE_PARAM, testIds);
+        mockRequest.setParameter(ActionLink.ACTION_LINK, tree.getSelectLink().getName());
 
         assertSelectOrDeselect(tree, testIds, false);//test for selection
         assertSelectOrDeselect(tree, testIds, true);//should reverse selection and deselect
@@ -168,7 +171,7 @@
             assertTrue("IsExpanded must be " + expected,node.isExpanded() == expected);
         }
         tree.onProcess();
-        context.fireActionEventsAndClearRegistry();
+        context.executeActionListeners();
         for(int i = 0; i < nodeIds.length; i++) {
             TreeNode node = tree.find(nodeIds[i]);
             assertTrue("IsExpanded must be " + !expected,node.isExpanded() == !expected);
@@ -182,7 +185,7 @@
             assertTrue("IsExpanded must be " + expected,node.isSelected() == expected);
         }
         tree.onProcess();
-        context.fireActionEventsAndClearRegistry();
+        context.executeActionListeners();
         for(int i = 0; i < nodeIds.length; i++) {
             TreeNode node = tree.find(nodeIds[i]);
             assertTrue("IsExpanded must be " + !expected,node.isSelected() == !expected);

Modified: incubator/click/trunk/click/framework/test/org/apache/click/control/FormTest.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/framework/test/org/apache/click/control/FormTest.java?rev=779281&r1=779280&r2=779281&view=diff
==============================================================================
--- incubator/click/trunk/click/framework/test/org/apache/click/control/FormTest.java (original)
+++ incubator/click/trunk/click/framework/test/org/apache/click/control/FormTest.java Wed
May 27 19:33:50 2009
@@ -63,7 +63,7 @@
         // Simulate a second submit check.
         valid = form.onSubmitCheck(page, "/invalid-submit.html");
         
-        // Assert the second onSubmitCheck did succeeded as well.
+        // Assert the second onSubmitCheck did succeed as well.
         Assert.assertTrue(valid);
     }
 
@@ -200,15 +200,15 @@
         // Add new field
         form.add(nameField);
 
-        // nameField index: #controls=1
-        assertTrue(form.getControls().indexOf(nameField) == 1);
-        // nameField index: #fieldList=1
-        assertTrue(form.getFieldList().indexOf(nameField) == 1);
+        // nameField index: #controls=0
+        assertTrue(form.getControls().indexOf(nameField) == 0);
+        // nameField index: #fieldList=0
+        assertTrue(form.getFieldList().indexOf(nameField) == 0);
         
         // trackField index: #controls=1
-        assertTrue(form.getControls().indexOf(trackField) == 0);
+        assertTrue(form.getControls().indexOf(trackField) == 1);
         // trackField index: #fieldList=1
-        assertTrue(form.getFieldList().indexOf(trackField) == 0);
+        assertTrue(form.getFieldList().indexOf(trackField) == 1);
     }
 
     /**
@@ -225,13 +225,13 @@
 
         // nameField index: #controls=0
         assertTrue(form.getControls().indexOf(nameField) == 0);
-        // nameField index: #fieldList=1
-        assertTrue(form.getFieldList().indexOf(nameField) == 1);
+        // nameField index: #fieldList=0
+        assertTrue(form.getFieldList().indexOf(nameField) == 0);
         
         // trackField index: #controls=1
         assertTrue(form.getControls().indexOf(trackField) == 1);
-        // trackField index: #fieldList=0
-        assertTrue(form.getFieldList().indexOf(trackField) == 0);
+        // trackField index: #fieldList=1
+        assertTrue(form.getFieldList().indexOf(trackField) == 1);
     }
 
     /**
@@ -293,13 +293,13 @@
 
         // hidden index: #controls=0
         assertTrue(form.getControls().indexOf(hidden) == 0);
-        // hidden index: #fieldList=1
-        assertTrue(form.getFieldList().indexOf(hidden) == 1);
+        // hidden index: #fieldList=0
+        assertTrue(form.getFieldList().indexOf(hidden) == 0);
         
         // trackField index: #controls=1
         assertTrue(form.getControls().indexOf(trackField) == 1);
-        // trackField index: #fieldList=0
-        assertTrue(form.getFieldList().indexOf(trackField) == 0);
+        // trackField index: #fieldList=1
+        assertTrue(form.getFieldList().indexOf(trackField) == 1);
     }
 
     /**
@@ -312,13 +312,13 @@
 
         // field index: #controls=0
         assertTrue(form.getControls().indexOf(field) == 0);
-        // field index: #fieldList=1
-        assertTrue(form.getFieldList().indexOf(field) == 1);
+        // field index: #fieldList=0
+        assertTrue(form.getFieldList().indexOf(field) == 0);
 
         // trackField index: #controls=1
         assertTrue(form.getControls().indexOf(trackField) == 1);
-        // trackField index: #fieldList=0
-        assertTrue(form.getFieldList().indexOf(trackField) == 0);
+        // trackField index: #fieldList=1
+        assertTrue(form.getFieldList().indexOf(trackField) == 1);
         
         int expectedSize = 2;
         // Check the list sizes to be 2

Modified: incubator/click/trunk/click/mock/src/org/apache/click/MockContext.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/mock/src/org/apache/click/MockContext.java?rev=779281&r1=779280&r2=779281&view=diff
==============================================================================
--- incubator/click/trunk/click/mock/src/org/apache/click/MockContext.java (original)
+++ incubator/click/trunk/click/mock/src/org/apache/click/MockContext.java Wed May 27 19:33:50
2009
@@ -290,16 +290,26 @@
     }
 
     /**
+     * Execute all listeners that was registered by the processed Controls.
+     *
+     * @return true if all listeners returned true, false otherwise
+     */
+    public boolean executeActionListeners() {
+        ControlRegistry controlRegistry = ControlRegistry.getThreadLocalRegistry();
+
+        // Fire POST_ON_PROCESS events
+        return controlRegistry.fireActionEvents(this, ControlRegistry.POST_ON_PROCESS_EVENT);
+    }
+
+    /**
      * Fire all action events that was registered by the processed Controls, and
      * clears all registered listeners from the ControlRegistry.
      *
+     * @deprecated use {@link #executeActionListeners()} instead
+     *
      * @return true if all listeners returned true, false otherwise
      */
     public boolean fireActionEventsAndClearRegistry() {
-        ControlRegistry controlRegistry = ControlRegistry.getThreadLocalRegistry();
-        boolean continueProcessing = controlRegistry.fireActionEvents(this);
-
-        controlRegistry.clearRegistry();
-        return continueProcessing;
+        return executeActionListeners();
     }
 }

Modified: incubator/click/trunk/click/mock/test/org/apache/click/MockRequestTest.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/mock/test/org/apache/click/MockRequestTest.java?rev=779281&r1=779280&r2=779281&view=diff
==============================================================================
--- incubator/click/trunk/click/mock/test/org/apache/click/MockRequestTest.java (original)
+++ incubator/click/trunk/click/mock/test/org/apache/click/MockRequestTest.java Wed May 27
19:33:50 2009
@@ -54,7 +54,7 @@
         assertTrue(textArea.onProcess());
 
         // Fire all action events that was registered in the onProcess method
-        context.fireActionEventsAndClearRegistry();
+        context.executeActionListeners();
 
         assertTrue("TextArea action was not invoked", actionCalled);
         assertTrue(textArea.isValid());



Mime
View raw message