Repository: wicket
Updated Branches:
  refs/heads/wicket-6.x e4c1d939f -> 0199bfab7


Added WicketTester support for IAjaxLink

WicketTester didn't click direct IAjaxLink implementations using an
Ajax request but a normal request. Some components implement
IAjaxLink directly instead of subclassing AjaxLink or other
components.

Fixes WICKET-5900


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/0199bfab
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/0199bfab
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/0199bfab

Branch: refs/heads/wicket-6.x
Commit: 0199bfab7cc27e14759d634a1b48f92c9e59a9d2
Parents: e4c1d93
Author: Martijn Dashorst <[email protected]>
Authored: Wed May 6 11:22:55 2015 +0200
Committer: Martijn Dashorst <[email protected]>
Committed: Wed May 6 11:25:22 2015 +0200

----------------------------------------------------------------------
 .../org/apache/wicket/util/tester/BaseWicketTester.java  | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/0199bfab/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java 
b/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
index 2849c3c..8b230b8 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
@@ -59,6 +59,7 @@ import org.apache.wicket.ajax.AjaxEventBehavior;
 import org.apache.wicket.ajax.form.AjaxFormSubmitBehavior;
 import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
 import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.ajax.markup.html.IAjaxLink;
 import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
 import org.apache.wicket.behavior.AbstractAjaxBehavior;
 import org.apache.wicket.core.request.handler.BookmarkablePageRequestHandler;
@@ -1881,6 +1882,16 @@ public class BaseWicketTester
                        submitAjaxFormSubmitBehavior(link,
                                
(AjaxFormSubmitBehavior)WicketTesterHelper.findAjaxEventBehavior(link, 
"onclick"));
                }
+               // if the link is an IAjaxLink, use it (do check if AJAX is 
expected)
+               else if (linkComponent instanceof IAjaxLink && isAjax)
+               {
+                       List<AjaxEventBehavior> behaviors = 
WicketTesterHelper.findAjaxEventBehaviors(
+                               linkComponent, "click");
+                       for (AjaxEventBehavior behavior : behaviors)
+                       {
+                               executeBehavior(behavior);
+                       }
+               }
                /*
                 * If the link is a submitlink then we pretend to have clicked 
it
                 */

Reply via email to