Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-555

WicketTester.assertComponentOnAjaxResponse fails if AJAX response contains line breaks

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.2.6, 1.2.7, 1.3.0-beta1
    • 1.3.0-beta3
    • wicket
    • None

    Description

      (Note: I've found this on 1.2.6 – I'm reporting as existing on later versions based on reading the code.)

      When any of the components replaced by an AJAX response renders multiple HTML lines, or if the AJAX response contains line breaks for any other reasons, the WicketTester.assertComponentOnAjaxResponse always returns false.

      I've traced this to this statement:

      boolean isComponentInAjaxResponse = ajaxResponse.matches(".*<component id=\"" + markupId
      + "\" ?>.*");

      which never matches if ajaxResponse contains a \n because, in Java RegExps, the dot doesn't match these unless DOTALL is set (and it is not by default).

      In the latest version I've found in SVN (sorry I'm not yet quite familiar with the codebase,) this code has been moved unchanged to org.apache.wicket.util.tester.BaseWicketTester.java – so I assume the bug is still there.

      The easiest solution is to add a single-line "(?s)" flag in front of the regular expression:

      boolean isComponentInAjaxResponse = ajaxResponse.matches("(?s).*<component id=\"" + markupId
      + "\" ?>.*");

      Attachments

        Issue Links

          Activity

            People

              almaw Alastair Maw
              jsalvata@apache.org Jordi Salvat i Alabart
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: