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:42:35 UTC
svn commit: r1037409 -
/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
Author: mgrigorov
Date: Sun Nov 21 10:42:35 2010
New Revision: 1037409
URL: http://svn.apache.org/viewvc?rev=1037409&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()
Modified:
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
Modified: wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java
URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java?rev=1037409&r1=1037408&r2=1037409&view=diff
==============================================================================
--- wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java (original)
+++ wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/util/tester/BaseWicketTester.java Sun Nov 21 10:42:35 2010
@@ -720,17 +720,7 @@ public class BaseWicketTester extends Mo
{
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
@@ -1184,6 +1174,8 @@ public class BaseWicketTester extends Mo
{
if (b instanceof AjaxSelfUpdatingTimerBehavior)
{
+ checkUsability(component);
+
log.debug("Triggering AjaxSelfUpdatingTimerBehavior: " +
component.getClassRelativePath());
AjaxSelfUpdatingTimerBehavior abstractAjaxBehaviour = (AjaxSelfUpdatingTimerBehavior)b;
@@ -1245,17 +1237,7 @@ public class BaseWicketTester extends Mo
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);
// Run through all the behavior and select the LAST ADDED behavior which
// matches the event parameter.
@@ -1390,6 +1372,9 @@ public class BaseWicketTester extends Mo
String failMessage = "No form attached to the submitlink.";
notNull(failMessage, form);
+
+ checkUsability(form);
+
/*
* Means that an button or an ajax link was clicked and needs to be added to the request
* parameters to their form component correctly resolves the submit origin
@@ -1536,6 +1521,26 @@ public class BaseWicketTester extends Mo
return Result.pass();
}
+ /**
+ * 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);
+ }
+ }
+
protected final void fail(String message)
{
throw new WicketRuntimeException(message);