blob: fc3a804d80b218256f403b9cdceca371307fe2c0 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id$ -->
<!--
Copyright 2004 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Performs some tests to simulate a StaleLink scenario when submitting a form. -->
<mock-test>
<context name="mock"/>
<servlet name="app" class="org.apache.tapestry.ApplicationServlet">
<init-parameter
name="org.apache.tapestry.application-specification"
value="/org/apache/tapestry/junit/mock/app/Mock.application"/>
</servlet>
<!-- Just for sanity's sake, duplicate some of the checks from TestRegisterForm.xml -->
<request>
<parameter name="service" value="page/Register"/>
<assert-output name="Title">
<![CDATA[
<title>Register</title>
]]>
</assert-output>
<assert-output-matches name="Hidden Fields - Names" subgroup="1">
<![CDATA[
<input type="hidden" name="(.*?)" value="(.*?)"/>
]]>
<match>service</match>
<match>sp</match>
<match>Form0</match>
</assert-output-matches>
<assert-output-matches name="Hidden Fields - Values" subgroup="2">
<![CDATA[
<input type="hidden" name="(.*?)" value="(.*?)"/>
]]>
<match>direct/0/Register/form</match>
<match>S0</match>
<match>inputFirstName,inputLastName,inputSex,inputAgeRange</match>
</assert-output-matches>
</request>
<!-- Provoke an error by "submitting" the form but gimicking things
as if there was another field when the form rendered.. -->
<request>
<parameter name="service" value="direct/0/Register/form"/>
<parameter name="sp" value="S0"/>
<parameter name="inputFirstName" value="Suzy"/>
<parameter name="inputLastName" value="Munchkin"/>
<parameter name="inputFavoriteColor" value="2"/>
<parameter name="inputSex" value="1"/>
<parameter name="inputAgeRange" value="1"/>
<parameter name="Form0" value="inputFirstName,inputLastName,inputFavoriteColor,inputSex,inputAgeRange"/>
<assert-output name="Title">
<![CDATA[
<title>Stale Link</title>
]]>
</assert-output>
<assert-output name="Mismatch Error Message">
Rewind of form Register/form expected allocated id #3 to be 'inputFavoriteColor', but was 'inputSex' (requested by component Register/inputSex).
</assert-output>
</request>
<!-- This time, we pretend that inputAgeRange didn't render but was submitted. -->
<request>
<parameter name="service" value="direct/0/Register/form"/>
<parameter name="sp" value="S0"/>
<parameter name="inputFirstName" value="Suzy"/>
<parameter name="inputLastName" value="Munchkin"/>
<parameter name="inputSex" value="1"/>
<parameter name="Form0" value="inputFirstName,inputLastName,inputSex"/>
<assert-output name="Title">
<![CDATA[
<title>Stale Link</title>
]]>
</assert-output>
<assert-output name="Too Many Error Message">
Rewind of form Register/form expected only 3 form elements, but an additional id was requested by component Register/inputAgeRange.
</assert-output>
</request>
<request>
<parameter name="service" value="direct/0/Register/form"/>
<parameter name="sp" value="S0"/>
<parameter name="inputFirstName" value="Suzy"/>
<parameter name="inputLastName" value="Munchkin"/>
<parameter name="inputSex" value="1"/>
<parameter name="inputAgeRange" value="1"/>
<parameter name="inputFavoriteColor" value="2"/>
<parameter name="Form0" value="inputFirstName,inputLastName,inputSex,inputAgeRange,inputFavoriteColor"/>
<assert-output name="Title">
<![CDATA[
<title>Stale Link</title>
]]>
</assert-output>
<assert-output name="Too Few Error Message">
Rewind of form Register/form expected 1 more form elements, starting with id 'inputFavoriteColor'.
</assert-output>
</request>
</mock-test>