BaseWicketTester.isComponentOnAjaxResponse() test is too strong
---------------------------------------------------------------
Key: WICKET-1473
URL: https://issues.apache.org/jira/browse/WICKET-1473
Project: Wicket
Issue Type: Bug
Components: wicket
Affects Versions: 1.3.2
Environment: Testing my ajax autocomplete usage
Reporter: Michael Lefevre
Priority: Minor
Using 1.3.0 but still present in 1.3.2 source.
The response i got from the ajax request was :
<?xml version="1.0" encoding="UTF-8"?><ajax-response><header-contribution
encoding="wicket1" ><![CDATA[<head
xmlns:wicket="http://wicket.apache.org"><script type="text/javascript"
src="resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js"></script>
<script type="text/javascript"
src="resources/org.apache.wicket.ajax.WicketAjaxReference/wicket-ajax.js"></script>
<script type="text/javascript"
src="resources/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/wicket-ajax-debug.js"></script>
<script type="text/javascript"
id="wicket-ajax-debug-enable"><!--/*--><![CDATA[/*><!--*/
wicketAjaxDebugEnable=true;
/*-->]^]^>*/</script>
<script type="text/javascript"
src="resources/org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteBehavior/wicket-autocomplete.js"></script>
<script type="text/javascript"
src="resources/com.amdm.ajf.wicket.component.autocomplete.ImprovedAutoCompleteBehavior/improved-autocomplete.js"></script>
</head>]]></header-contribution><component id="ville9" encoding="wicket1"
><![CDATA[<input value="TOULOUSE" autocomplete="off" maxlength="26" type="text"
onfocus="this.className='focus';" size="28"
name="view:adresse:adresseInner:villeFrancaiseDiv:ville"
onchange="wicketThrottler.throttle( 'th1', 200, function() { var
wcall=wicketAjaxPost('?wicket:interface=:0:updateExpertWizard:form:view:adresse:adresseInner:villeFrancaiseDiv:ville::IBehaviorListener:3:-1',
wicketSerialize(Wicket.$('ville9')),null,null, function() {return
Wicket.$('ville9') != null;}.bind(this));});" id="ville9"
onblur="this.className='normal';"/><script
type="text/javascript"><!--/*--><![CDATA[/*><!--*/
new
Wicket.AutoComplete('ville9','?wicket:interface=:0:updateExpertWizard:form:view:adresse:adresseInner:villeFrancaiseDiv:ville::IActivePageBehaviorListener:1:-1&wicket:ignoreIfNotActive=true',false);
/*-->]^]^>*/</script>
]]></component><component id="codePostalBinde8" encoding="wicket1"
><![CDATA[<input value="34200" autocomplete="off" maxlength="5" type="text"
onfocus="this.className='focus';" size="5"
name="view:adresse:adresseInner:villeFrancaiseDiv:codePostalBinde"
onchange="wicketThrottler.throttle( 'th2', 200, function() { var
wcall=wicketAjaxPost('?wicket:interface=:0:updateExpertWizard:form:view:adresse:adresseInner:villeFrancaiseDiv:codePostalBinde::IBehaviorListener:3:-1',
wicketSerialize(Wicket.$('codePostalBinde8')),null,null, function() {return
Wicket.$('codePostalBinde8') != null;}.bind(this));});" id="codePostalBinde8"
onblur="this.className='normal';"/><script
type="text/javascript"><!--/*--><![CDATA[/*><!--*/
new
Wicket.AutoComplete('codePostalBinde8','?wicket:interface=:0:updateExpertWizard:form:view:adresse:adresseInner:villeFrancaiseDiv:codePostalBinde::IActivePageBehaviorListener:1:-1&wicket:ignoreIfNotActive=true',false);
/*-->]^]^>*/</script>
]]></component></ajax-response>
And my test is :
tester.assertComponentOnAjaxResponse("updateExpertWizard:form:view:adresse:adresseInner:villeFrancaiseDiv:ville");
It fails in BaseWicketTester.isComponentOnAjaxResponse() :
// 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";
because of the attribut { encoding="wicket1" } present in the component tag.
The regex must be sweeter like (for example):
"(?s).*<component id=\"" + markupId + "\" .* ?>.*" (or much much better ;-)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.