Repository: wicket Updated Branches: refs/heads/wicket-6.x 72a7fb014 -> b9f358165
WICKET-6233 Add component info in the error messages related to WicketTester#assertComponentOnAjaxResponse() Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/b9f35816 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/b9f35816 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/b9f35816 Branch: refs/heads/wicket-6.x Commit: b9f35816553aea6373da71d019ff2e5cc3da91a6 Parents: 72a7fb0 Author: Martin Tzvetanov Grigorov <[email protected]> Authored: Fri Aug 26 16:59:26 2016 +0200 Committer: Martin Tzvetanov Grigorov <[email protected]> Committed: Fri Aug 26 17:00:06 2016 +0200 ---------------------------------------------------------------------- .../wicket/util/tester/BaseWicketTester.java | 18 +++++++++++------- .../apache/wicket/util/tester/WicketTester.java | 5 +++-- 2 files changed, 14 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/b9f35816/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 a9ec85f..600da9f 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 @@ -1581,7 +1581,7 @@ public class BaseWicketTester * @param path * Path to component * @param wantVisibleInHierarchy - * if true component needs to be VisibleInHierarchy else null is returned + * if true component needs to be visible in hierarchy else {@code null} is returned * @return The component at the path * @see org.apache.wicket.MarkupContainer#get(String) */ @@ -2267,10 +2267,12 @@ public class BaseWicketTester Result result; // test that the component renders the placeholder tag if it's not visible + String componentInfo = component.toString(); if (!component.isVisible()) { failMessage = "A component which is invisible and doesn't render a placeholder tag" - + " will not be rendered at all and thus won't be accessible for subsequent AJAX interaction"; + + " will not be rendered at all and thus won't be accessible for subsequent AJAX interaction. " + + componentInfo; result = isTrue(failMessage, component.getOutputMarkupPlaceholderTag()); if (result.wasFailed()) { @@ -2282,8 +2284,9 @@ public class BaseWicketTester String ajaxResponse = getLastResponseAsString(); // Test that the previous response was actually a AJAX response - failMessage = "The Previous response was not an AJAX response. " - + "You need to execute an AJAX event, using clickLink, before using this assert"; + failMessage = "The previous response was not an AJAX response. "+ + "You need to execute an AJAX event, using #clickLink() or " + + "#executeAjaxEvent(), before using this assertion method"; boolean isAjaxResponse = Pattern.compile( "^<\\?xml version=\"1.0\" encoding=\".*?\"\\?><ajax-response>") .matcher(ajaxResponse) @@ -2297,8 +2300,9 @@ public class BaseWicketTester // See if the component has a markup id String markupId = component.getMarkupId(); - failMessage = "The component doesn't have a markup id, " - + "which means that it can't have been added to the AJAX response"; + failMessage = "The component doesn't have a markup id, " + + "which means that it can't have been added to the AJAX response. " + + componentInfo; result = isTrue(failMessage, !Strings.isEmpty(markupId)); if (result.wasFailed()) { @@ -2308,7 +2312,7 @@ public class BaseWicketTester // Look for that the component is on the response, using the markup id boolean isComponentInAjaxResponse = ajaxResponse.matches("(?s).*<component id=\"" + markupId + "\"[^>]*?>.*"); - failMessage = "Component wasn't found in the AJAX response"; + failMessage = "Component wasn't found in the AJAX response. " + componentInfo; return isTrue(failMessage, isComponentInAjaxResponse); } http://git-wip-us.apache.org/repos/asf/wicket/blob/b9f35816/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java b/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java index 09869d9..0fd3053 100644 --- a/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java +++ b/wicket-core/src/main/java/org/apache/wicket/util/tester/WicketTester.java @@ -323,14 +323,15 @@ public class WicketTester extends BaseWicketTester */ public void assertComponentOnAjaxResponse(String componentPath) { - assertComponentOnAjaxResponse(getComponentFromLastRenderedPage(componentPath, false)); + Component component = getComponentFromLastRenderedPage(componentPath, false); + assertComponentOnAjaxResponse(component); } /** * Asserts the content of last rendered page contains (matches) a given regex pattern. * * @param pattern - * a reqex pattern to match + * a regex pattern to match */ public void assertContains(String pattern) {
