You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Mikko Peltonen (JIRA)" <ji...@apache.org> on 2007/12/19 14:22:43 UTC

[jira] Commented: (WICKET-555) WicketTester.assertComponentOnAjaxResponse fails if AJAX response contains line breaks

    [ https://issues.apache.org/jira/browse/WICKET-555?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12553357 ] 

Mikko Peltonen commented on WICKET-555:
---------------------------------------

It looks as there's still a problem in trunk (and 1.3.0-rc2) in this regexp. Can't confirm if it's something to do with JDK version (I'm using 1.5.0_13), but I needed to change this:

"(?s).*<component id=\"" + markupId + "\" ?>.*"

to this (grouping in the end):

"(?s).*<component id=\"" + markupId + "\" (?>.*)"

for it to match my ajax response (or alternatively to "(?s).*<component id=\"" + markupId + "\" .*").

> WicketTester.assertComponentOnAjaxResponse fails if AJAX response contains line breaks
> --------------------------------------------------------------------------------------
>
>                 Key: WICKET-555
>                 URL: https://issues.apache.org/jira/browse/WICKET-555
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.2.6, 1.2.7, 1.3.0-beta1
>            Reporter: Jordi Salvat i Alabart
>            Assignee: Alastair Maw
>             Fix For: 1.3.0-beta3
>
>
> (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
> 				+ "\" ?>.*");

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.