| <?xml version="1.0" encoding="UTF-8"?> |
| <!-- |
| Copyright 2004, 2005 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. |
| --> |
| |
| <mock-test> |
| <context name="selopt" root="context11" /> |
| |
| <servlet name="app" class="org.apache.tapestry.ApplicationServlet" /> |
| |
| <request> |
| |
| <assert-output name="Page Title"> |
| <![CDATA[ |
| <title>Home</title> |
| ]]> |
| </assert-output> |
| |
| <assert-output name="Form"> |
| <![CDATA[ |
| <form method="post" action="/selopt/app" id="Form"> |
| ]]> |
| </assert-output> |
| |
| <assert-output-matches name="Hidden Fields" subgroup="1"> |
| <![CDATA[ |
| <input type="hidden" (name="(.*?)" value="(.*?)") /> |
| ]]> |
| <match>name="formids" value="Select"</match> |
| <match>name="seedids" value="BrO0ABXdQAE4sc2VydmljZSQwLHBhZ2UkMCxjb21wb25lbnQkMCxjb250YWluZXIkMCxzZXNzaW9uJDAsc3AkMCxTaGVsbCQwLEJvZHkkMCxGb3JtJDA="</match> |
| <match>name="component" value="$Form"</match> |
| <match>name="page" value="Home"</match> |
| <match>name="service" value="direct"</match> |
| <match>name="submitmode" value=""</match> |
| <match>name="submitname" value=""</match> |
| </assert-output-matches> |
| |
| <assert-regexp name="Select Tag"> |
| <![CDATA[ |
| <select name="Select" id="Select">\s+<option/> |
| ]]> |
| </assert-regexp> |
| |
| <assert-output-matches name="Option Tags"> |
| <![CDATA[ |
| <option value="(.*?)">(.*?)</option> |
| ]]> |
| <match><![CDATA[<option value="0">Animal</option>]]></match> |
| <match><![CDATA[<option value="1">Vegetable</option>]]></match> |
| <match><![CDATA[<option value="2">Mineral (or unknown)</option>]]></match> |
| </assert-output-matches> |
| |
| </request> |
| |
| <!-- Submit the form, and specify nothing. --> |
| |
| <request> |
| <parameter name="service" value="direct" /> |
| <parameter name="page" value="Home" /> |
| <parameter name="component" value="$Form" /> |
| <parameter name="formids" value="Select" /> |
| |
| <assert-output name="Page Title"> |
| <![CDATA[ |
| <title>Result</title> |
| ]]> |
| </assert-output> |
| |
| <assert-output name="Selections"> |
| Selections: none. |
| </assert-output> |
| |
| </request> |
| |
| <!-- Select one of the items. --> |
| |
| <request> |
| <parameter name="service" value="direct" /> |
| <parameter name="page" value="Home" /> |
| <parameter name="component" value="$Form" /> |
| <parameter name="formids" value="Select" /> |
| <parameter name="Select" value="1" /> |
| |
| <assert-output name="Page Title"> |
| <![CDATA[ |
| <title>Result</title> |
| ]]> |
| </assert-output> |
| |
| <assert-output name="Selections"> |
| Selections: vegetable. |
| </assert-output> |
| |
| </request> |
| |
| |
| <!-- Go to the page with the persistent multiple options. --> |
| |
| <request> |
| <parameter name="service" value="page" /> |
| <parameter name="page" value="Two" /> |
| |
| <assert-output name="Page Title"> |
| <![CDATA[ |
| <title>Two</title> |
| ]]> |
| </assert-output> |
| |
| <assert-output name="Form"> |
| <![CDATA[ |
| <form method="post" action="/selopt/app" id="Form"> |
| ]]> |
| </assert-output> |
| |
| <assert-output-matches name="Hidden Fields" subgroup="1"> |
| <![CDATA[ |
| <input type="hidden" (name="(.*?)" value="(.*?)") /> |
| ]]> |
| <match>name="formids" value="Select"</match> |
| <match>name="seedids" value="BrO0ABXdQAE4sc2VydmljZSQwLHBhZ2UkMCxjb21wb25lbnQkMCxjb250YWluZXIkMCxzZXNzaW9uJDAsc3AkMCxTaGVsbCQwLEJvZHkkMCxGb3JtJDA="</match> |
| <match>name="component" value="$Form"</match> |
| <match>name="page" value="Two"</match> |
| <match>name="service" value="direct"</match> |
| <match>name="submitmode" value=""</match> |
| <match>name="submitname" value=""</match> |
| </assert-output-matches> |
| |
| <assert-output name="Select Tag"> |
| <![CDATA[ |
| <select name="Select" multiple="multiple" id="Select"> |
| ]]> |
| </assert-output> |
| |
| <assert-output-matches name="Option Tags"> |
| <![CDATA[ |
| <option value="(.*?)"(.*?)>(.*?)</option> |
| ]]> |
| <match><![CDATA[<option value="0">Animal</option>]]></match> |
| <match><![CDATA[<option value="1">Vegetable</option>]]></match> |
| <match><![CDATA[<option value="2">Mineral (or unknown)</option>]]></match> |
| </assert-output-matches> |
| |
| </request> |
| |
| |
| |
| <!-- Select two items. --> |
| |
| <request> |
| <parameter name="service" value="direct" /> |
| <parameter name="page" value="Two" /> |
| <parameter name="component" value="$Form" /> |
| <parameter name="formids" value="Select" /> |
| <parameter name="Select"> |
| <value>1</value> |
| <value>2</value> |
| </parameter> |
| |
| <assert-output name="Page Title"> |
| <![CDATA[ |
| <title>Result</title> |
| ]]> |
| </assert-output> |
| |
| <assert-output name="Selections"> |
| Selections: vegetable, mineral. |
| </assert-output> |
| |
| </request> |
| |
| <!-- Back to the page, see if the tags reflect right values. --> |
| |
| <request> |
| <parameter name="service" value="page" /> |
| <parameter name="page" value="Two" /> |
| |
| |
| <assert-output name="Page Title"> |
| <![CDATA[ |
| <title>Two</title> |
| ]]> |
| </assert-output> |
| |
| <assert-output-matches name="Option Tags"> |
| <![CDATA[ |
| <option value="(.*?)"(.*?)>(.*?)</option> |
| ]]> |
| <match><![CDATA[<option value="0">Animal</option>]]></match> |
| <match><![CDATA[<option value="1" selected="selected">Vegetable</option>]]></match> |
| <match><![CDATA[<option value="2" selected="selected">Mineral (or unknown)</option>]]></match> |
| </assert-output-matches> |
| </request> |
| |
| <!-- Next up, a page that has a disabled Select. --> |
| |
| <request> |
| <parameter name="service" value="page" /> |
| <parameter name="page" value="Three" /> |
| |
| <assert-output name="Page Title"> |
| <![CDATA[ |
| <title>Three</title> |
| ]]> |
| </assert-output> |
| |
| <assert-output name="Form"> |
| <![CDATA[ |
| <form method="post" action="/selopt/app" id="Form"> |
| ]]> |
| </assert-output> |
| |
| <assert-output-matches name="Hidden Fields" subgroup="1"> |
| <![CDATA[ |
| <input type="hidden" (name="(.*?)" value="(.*?)") /> |
| ]]> |
| |
| <!-- Remember the persistent properties? Those made the app go stateful. --> |
| |
| <match>name="formids" value="Select"</match> |
| <match>name="seedids" value="BrO0ABXdQAE4sc2VydmljZSQwLHBhZ2UkMCxjb21wb25lbnQkMCxjb250YWluZXIkMCxzZXNzaW9uJDAsc3AkMCxTaGVsbCQwLEJvZHkkMCxGb3JtJDA="</match> |
| <match>name="component" value="$Form"</match> |
| <match>name="page" value="Three"</match> |
| <match>name="service" value="direct"</match> |
| <match>name="session" value="T"</match> |
| <match>name="submitmode" value=""</match> |
| <match>name="submitname" value=""</match> |
| </assert-output-matches> |
| |
| <assert-output name="Select Tag"> |
| <![CDATA[ |
| <select name="Select" disabled="disabled" id="Select"> |
| ]]> |
| </assert-output> |
| |
| <assert-output-matches name="Option Tags"> |
| <![CDATA[ |
| <option value="(.*?)"(.*?)>(.*?)</option> |
| ]]> |
| <match><![CDATA[<option value="0">Animal</option>]]></match> |
| <match><![CDATA[<option value="1">Vegetable</option>]]></match> |
| <match><![CDATA[<option value="2">Mineral (or unknown)</option>]]></match> |
| </assert-output-matches> |
| |
| </request> |
| |
| <!-- Pretend to be a browser that ignores the disabled flag on the select. |
| Check that the values are ignored. --> |
| |
| <request> |
| <parameter name="service" value="direct" /> |
| <parameter name="session" value="T" /> |
| <parameter name="page" value="Three" /> |
| <parameter name="component" value="$Form" /> |
| <parameter name="formids" value="Select" /> |
| <parameter name="Select" value="1" /> |
| |
| <assert-output name="Page Title"> |
| <![CDATA[ |
| <title>Result</title> |
| ]]> |
| </assert-output> |
| |
| <assert-output name="Selections"> |
| Selections: none. |
| </assert-output> |
| |
| </request> |
| |
| <!-- Page Four has a second form that uses the action service. We check |
| that the form containing the Select ignores the request property. --> |
| |
| <request> |
| <parameter name="service" value="page" /> |
| <parameter name="page" value="Four" /> |
| |
| <assert-output name="Page Title"> |
| <![CDATA[ |
| <title>Four</title> |
| ]]> |
| </assert-output> |
| |
| <assert-output name="Second Form"> |
| <![CDATA[ |
| <form method="post" action="/selopt/app" id="Form_0" direct="false"> |
| ]]> |
| </assert-output> |
| </request> |
| |
| <!-- Submit the second form. --> |
| |
| <request> |
| <parameter name="service" value="direct" /> |
| <parameter name="direct" value="1" /> |
| <parameter name="session" value="1" /> |
| <parameter name="page" value="Four" /> |
| <parameter name="component" value="$Form_0" /> |
| <parameter name="formids" value="" /> |
| |
| <assert-output name="Page Title"> |
| <![CDATA[ |
| <title>Result</title> |
| ]]> |
| </assert-output> |
| |
| <assert-output name="Message"> |
| Second form triggered. |
| </assert-output> |
| |
| </request> |
| |
| <!-- And on to the degenerate cases. --> |
| |
| <!-- #1 Select not in a Form (removed) --> |
| |
| <!-- #2 Nested Selects. --> |
| |
| <request> |
| <parameter name="service" value="page" /> |
| <parameter name="page" value="Six" /> |
| |
| <assert-output name="Page Title"> |
| <![CDATA[ |
| <title>Exception</title> |
| ]]> |
| </assert-output> |
| |
| <assert-output name="Message"> |
| Select components may not be nested. |
| </assert-output> |
| </request> |
| |
| <!-- #3: Option not in a Select --> |
| |
| <request> |
| <parameter name="service" value="page" /> |
| <parameter name="page" value="Seven" /> |
| |
| <assert-output name="Page Title"> |
| <![CDATA[ |
| <title>Exception</title> |
| ]]> |
| </assert-output> |
| |
| <assert-output name="Message"> |
| Option component must be contained within a Select. |
| </assert-output> |
| </request> |
| |
| </mock-test> |