You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2010/11/21 11:47:58 UTC
svn commit: r1037411 -
/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
Author: mgrigorov
Date: Sun Nov 21 10:47:58 2010
New Revision: 1037411
URL: http://svn.apache.org/viewvc?rev=1037411&view=rev
Log:
WICKET-3164 executeAjaxEvent in WicketTester works although Component is not enabled
Add additional checks for 'enabled' and 'visible' component before executing WicketTester's #executeAllTimerBehaviors() and #submitAjaxFormSubmitBehavior()
merge r1037409 from 1.4.x
Modified:
wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java?rev=1037411&r1=1037410&r2=1037411&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java Sun Nov 21 10:47:58 2010
@@ -1139,17 +1139,7 @@ public class BaseWicketTester
{
Component linkComponent = getComponentFromLastRenderedPage(path);
- if (linkComponent.isVisibleInHierarchy() == false)
- {
- fail("The component is currently not visible in the hierarchy and thus you can not fire events on it." +
- " Component: " + linkComponent);
- }
-
- if (linkComponent.isEnabledInHierarchy() == false)
- {
- fail("The component is currently not enabled in the hierarchy and thus you can not be clicked." +
- " Component: " + linkComponent);
- }
+ checkUsability(linkComponent);
// if the link is an AjaxLink, we process it differently
// than a normal link
@@ -1538,6 +1528,8 @@ public class BaseWicketTester
List<AbstractAjaxTimerBehavior> behaviors = component.getBehaviors(AbstractAjaxTimerBehavior.class);
for (IBehavior b : behaviors)
{
+ checkUsability(component);
+
log.debug("Triggering AjaxSelfUpdatingTimerBehavior: " +
component.getClassRelativePath());
AbstractAjaxTimerBehavior timer = (AbstractAjaxTimerBehavior)b;
@@ -1593,17 +1585,7 @@ public class BaseWicketTester
failMessage = "event must not be null";
notNull(failMessage, event);
- if (component.isVisibleInHierarchy() == false)
- {
- fail("The component is currently not visible in the hierarchy and thus you can not fire events on it." +
- " Component: " + component + "; Event: " + event);
- }
-
- if (component.isEnabledInHierarchy() == false)
- {
- fail("The component is currently not enabled in the hierarchy and thus you can not fire events on it." +
- " Component: " + component + "; Event: " + event);
- }
+ checkUsability(component);
AjaxEventBehavior ajaxEventBehavior = WicketTesterHelper.findAjaxEventBehavior(component,
event);
@@ -1667,6 +1649,8 @@ public class BaseWicketTester
String failMessage = "No form attached to the submitlink.";
notNull(failMessage, form);
+ checkUsability(form);
+
serializeFormToRequest(form);
executeBehavior(behavior);
@@ -1852,6 +1836,26 @@ public class BaseWicketTester
}
/**
+ * Checks whether a component is visible and/or enabled before usage
+ *
+ * @param component
+ */
+ private void checkUsability(final Component component)
+ {
+ if (component.isVisibleInHierarchy() == false)
+ {
+ fail("The component is currently not visible in the hierarchy and thus you can not be used." +
+ " Component: " + component);
+ }
+
+ if (component.isEnabledInHierarchy() == false)
+ {
+ fail("The component is currently not enabled in the hierarchy and thus you can not be used." +
+ " Component: " + component);
+ }
+ }
+
+ /**
*
* @param message
*/