You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2008/01/14 19:33:20 UTC
svn commit: r611881 [2/2] - in
/tapestry/tapestry4/branches/MultipleFormIDGeneration:
tapestry-examples/Vlib/ tapestry-examples/VlibBeans/
tapestry-framework/src/descriptor/META-INF/
tapestry-framework/src/java/org/apache/tapestry/ tapestry-framework/s...
Modified: tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/scripts/TestSelectOption.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/scripts/TestSelectOption.xml?rev=611881&r1=611880&r2=611881&view=diff
==============================================================================
--- tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/scripts/TestSelectOption.xml (original)
+++ tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/scripts/TestSelectOption.xml Mon Jan 14 10:33:16 2008
@@ -18,341 +18,344 @@
<mock-test>
<context name="selopt" root="context11" />
- <servlet name="app" class="org.apache.tapestry.ApplicationServlet" />
+ <servlet name="app" class="org.apache.tapestry.ApplicationServlet" />
- <request>
-
- <assert-output name="Page Title">
-<![CDATA[
+ <request>
+
+ <assert-output name="Page Title">
+ <![CDATA[
<title>Home</title>
-]]>
- </assert-output>
-
- <assert-output name="Form">
-<![CDATA[
+]]>
+ </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[
+ </assert-output>
+
+ <assert-output-matches name="Hidden Fields" subgroup="1">
+ <![CDATA[
<input type="hidden" (name="(.*?)" value="(.*?)") />
]]>
- <match>name="formids" value="Select"</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>
+ <match>name="formids" value="Select"</match>
+ <match>name="seedids" value="BrO0ABXcYABYsU2hlbGwkMCxCb2R5JDAsRm9ybSQw"</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[
+ <assert-regexp name="Select Tag">
+ <![CDATA[
<select name="Select" id="Select">\s+<option/>
]]>
- </assert-regexp>
+ </assert-regexp>
- <assert-output-matches name="Option Tags">
-<![CDATA[
+ <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[
+ <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[
+]]>
+ </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[
+]]>
+ </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[
+]]>
+ </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[
+ </assert-output>
+
+ <assert-output-matches name="Hidden Fields" subgroup="1">
+ <![CDATA[
<input type="hidden" (name="(.*?)" value="(.*?)") />
]]>
- <match>name="formids" value="Select"</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>
+ <match>name="formids" value="Select"</match>
+ <match>name="seedids" value="BrO0ABXcYABYsU2hlbGwkMCxCb2R5JDAsRm9ybSQw"</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[
+ <assert-output name="Select Tag">
+ <![CDATA[
<select name="Select" multiple="multiple" id="Select">
]]>
- </assert-output>
+ </assert-output>
- <assert-output-matches name="Option Tags">
-<![CDATA[
+ <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[
+ <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[
+]]>
+ </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[
+]]>
+ </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[
+ <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[
+]]>
+ </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[
+ </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. -->
+ <!-- Remember the persistent properties? Those made the app go stateful. -->
- <match>name="formids" value="Select"</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>
+ <match>name="formids" value="Select"</match>
+ <match>name="seedids" value="BrO0ABXcYABYsU2hlbGwkMCxCb2R5JDAsRm9ybSQw"</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[
+ <assert-output name="Select Tag">
+ <![CDATA[
<select name="Select" disabled="disabled" id="Select">
]]>
- </assert-output>
+ </assert-output>
- <assert-output-matches name="Option Tags">
-<![CDATA[
+ <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[
+ <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[
+]]>
+ </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[
+]]>
+ </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[
+]]>
+ </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[
+]]>
+ </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[
+]]>
+ </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>
-
+]]>
+ </assert-output>
+
+ <assert-output name="Message">
+ Option component must be contained within a Select.
+ </assert-output>
+ </request>
+
</mock-test>
Modified: tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/scripts/TestWMLComponents.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/scripts/TestWMLComponents.xml?rev=611881&r1=611880&r2=611881&view=diff
==============================================================================
--- tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/scripts/TestWMLComponents.xml (original)
+++ tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/scripts/TestWMLComponents.xml Mon Jan 14 10:33:16 2008
@@ -111,6 +111,7 @@
]]>
<match>u</match>
<match>formids</match>
+ <match>seedids</match>
<match>component</match>
<match>page</match>
<match>service</match>
@@ -125,6 +126,7 @@
]]>
<match>u,l</match>
<match>0</match>
+ <match><![CDATA[ZH4sIAAAAAAAAAFvzloG1PIMhTcclX8VAJyc/HUSFZOamFgFpz9zE9FQgnZuYmQek/PNcy1LzSoCs4NSSssQiOCPeAMgs9cwrKAVJFqfmpCZDVBWVZSan+mTmZQN5IJMB1AU3oG4AAAA=]]></match>
<match>go</match>
<match>Home</match>
<match>direct</match>
Modified: tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/scripts/TestWMLStaleSession.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/scripts/TestWMLStaleSession.xml?rev=611881&r1=611880&r2=611881&view=diff
==============================================================================
--- tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/scripts/TestWMLStaleSession.xml (original)
+++ tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/scripts/TestWMLStaleSession.xml Mon Jan 14 10:33:16 2008
@@ -20,16 +20,16 @@
<servlet name="app" class="org.apache.tapestry.ApplicationServlet">
<init-parameter
- name="org.apache.tapestry.application-specification"
- value="/org/apache/tapestry/junit/mock/wml/Mock.application" />
+ name="org.apache.tapestry.application-specification"
+ value="/org/apache/tapestry/junit/mock/wml/Mock.application" />
<init-parameter
- name="org.apache.tapestry.application-mode" value="wml" />
+ name="org.apache.tapestry.application-mode" value="wml" />
</servlet>
<request>
<parameter name="service" value="page" />
<parameter name="page" value="Stale" />
-
+
<assert-output name="Do component">
<![CDATA[
<do type="prev">
@@ -53,6 +53,7 @@
<postfield name="(.*?)".*?/>
]]>
<match>formids</match>
+ <match>seedids</match>
<match>component</match>
<match>page</match>
<match>service</match>
@@ -65,6 +66,7 @@
<postfield .*?value="(.*?)" />
]]>
<match></match>
+ <match>BrO0ABXcoACYsRG8kMCxTdGFsZVNlc3Npb24kMCxkaXJlY3RMaW5rJDAsZ28kMA==</match>
<match>go</match>
<match>Stale</match>
<match>direct</match>
Modified: tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java?rev=611881&r1=611880&r2=611881&view=diff
==============================================================================
--- tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java (original)
+++ tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/test/org/apache/tapestry/form/FormSupportTest.java Mon Jan 14 10:33:16 2008
@@ -23,9 +23,11 @@
import org.apache.tapestry.internal.event.impl.ComponentEventInvoker;
import org.apache.tapestry.listener.ListenerInvoker;
import org.apache.tapestry.services.ResponseBuilder;
+import org.apache.tapestry.util.IdAllocator;
import org.apache.tapestry.valid.IValidationDelegate;
+import org.easymock.EasyMock;
import static org.easymock.EasyMock.*;
-import org.testng.annotations.DataProvider;
+import org.easymock.IAnswer;
import org.testng.annotations.Test;
import java.util.HashMap;
@@ -39,33 +41,16 @@
*/
@Test(sequential = true)
public class FormSupportTest extends BaseComponentTestCase {
-
- @DataProvider(name = "allSupports")
- public Object[][] createAllSupports()
- {
- return new Object[][]{
- {new FormSupportFactoryImpl()},
- {new MultipleFormSupportFactory()}
- };
- }
-
- @DataProvider(name = "mainSupport")
- public Object[][] createMainSupport()
+
+ protected FormSupport newFormSupport(IMarkupWriter writer, IRequestCycle cycle, IForm form)
{
- return new Object[][]{ {new FormSupportFactoryImpl()}
- };
- }
-
- protected FormSupport newFormSupport(IRequestCycle cycle)
- {
- return new FormSupportImpl(cycle);
+ return new FormSupportImpl(writer, cycle, form);
}
private IRender newComponentRenderBody(final FormSupport fs, final IFormComponent component,
final IMarkupWriter nested)
{
- return newComponentsRenderBody(fs, new IFormComponent[]
- {component}, nested);
+ return newComponentsRenderBody(fs, new IFormComponent[] {component}, nested);
}
private IRender newComponentsRenderBody(final FormSupport fs, final IFormComponent[] component,
@@ -122,8 +107,25 @@
return component;
}
- @Test(dataProvider = "mainSupport")
- public void test_Cancel_Rewind(FormSupportFactory factory)
+ protected void trainCycleSeedEncoding(IRequestCycle cycle)
+ {
+ expect(cycle.encodeIdState()).andReturn("ENCODED").anyTimes();
+
+ expect(cycle.getUniqueId(isA(String.class))).andAnswer(new UniqueIdAnswer()).anyTimes();
+ }
+
+ public class UniqueIdAnswer implements IAnswer<String> {
+
+ IdAllocator _allocator = new IdAllocator();
+
+ public String answer()
+ throws Throwable
+ {
+ return _allocator.allocateId((String) EasyMock.getCurrentArguments()[0]);
+ }
+ }
+
+ public void test_Cancel_Rewind()
{
IMarkupWriter writer = newWriter();
IRequestCycle cycle = newCycle();
@@ -136,7 +138,7 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
@@ -157,8 +159,7 @@
verify();
}
- @Test(dataProvider = "mainSupport")
- public void test_Complex_Render(FormSupportFactory factory)
+ public void test_Complex_Render()
{
IMarkupWriter writer = newWriter();
NestedMarkupWriter nested = newNestedWriter();
@@ -167,7 +168,6 @@
IValidationDelegate delegate = newDelegate();
ILink link = newLink();
IRender render = newRender();
-
MockForm form = new MockForm(delegate);
trainIsRewound(cycle, form, false);
@@ -178,25 +178,24 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
+ trainCycleSeedEncoding(cycle);
+
final IFormComponent barney1 = newFormComponent("barney", "barney");
final IFormComponent wilma = newFormComponent("wilma", "wilma");
final IFormComponent barney2 = newFormComponent("barney", "barney_0");
- IRender body = newComponentsRenderBody(fs, new IFormComponent[]
- {barney1, wilma, barney2}, nested);
+ IRender body = newComponentsRenderBody(fs, new IFormComponent[] {barney1, wilma, barney2}, nested);
form.setBody(body);
trainRegister(support, form, "myform");
- trainGetParameterNames(link, new String[]
- {"service"});
- trainGetParameterValues(link, "service", new String[]
- {"fred"});
+ trainGetParameterNames(link, new String[] {"service"});
+ trainGetParameterValues(link, "service", new String[] {"fred"});
trainGetNestedWriter(writer, nested);
@@ -237,8 +236,7 @@
verify();
}
- @Test(dataProvider = "mainSupport")
- public void test_Complex_Rewind(FormSupportFactory factory)
+ public void test_Complex_Rewind()
{
IMarkupWriter writer = newWriter();
IRequestCycle cycle = newCycle();
@@ -254,20 +252,20 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
-
+
delegate.clear();
trainCycleForRewind(cycle, "barney,wilma,barney_0", null);
+ trainCycleSeedEncoding(cycle);
final IFormComponent barney1 = newFormComponent("barney", "barney");
final IFormComponent wilma = newFormComponent("wilma", "wilma");
final IFormComponent barney2 = newFormComponent("barney", "barney_0");
- IRender body = newComponentsRenderBody(fs, new IFormComponent[]
- {barney1, wilma, barney2}, writer);
+ IRender body = newComponentsRenderBody(fs, new IFormComponent[] {barney1, wilma, barney2}, writer);
form.setBody(body);
form.setEventInvoker(invoker);
@@ -287,8 +285,7 @@
verify();
}
- @Test(dataProvider = "allSupports")
- public void test_Complex_Submit_Event_Handler(FormSupportFactory factory)
+ public void test_Complex_Submit_Event_Handler()
{
IMarkupWriter writer = newWriter();
NestedMarkupWriter nested = newNestedWriter();
@@ -306,10 +303,12 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
+ trainCycleSeedEncoding(cycle);
+
form.setBody(new IRender() {
public void render(IMarkupWriter pwriter, IRequestCycle pcycle)
{
@@ -320,12 +319,8 @@
});
trainRegister(support, form, "myform");
-
- trainGetParameterNames(link, new String[]
- {"service"});
-
- trainGetParameterValues(link, "service", new String[]
- {"fred"});
+ trainGetParameterNames(link, new String[] {"service"});
+ trainGetParameterValues(link, "service", new String[] {"fred"});
trainGetNestedWriter(writer, nested);
@@ -341,13 +336,11 @@
+ "\n{\n mySubmit1();\n mySubmit2();\n mySubmit3();\n});\n");
render.render(writer, cycle);
-
writer.println();
trainHiddenBlock(cycle, builder, writer, form, "fred", "");
nested.close();
-
writer.end();
support.addInitializationScript(form, "dojo.require(\"tapestry.form\");");
@@ -365,8 +358,7 @@
verify();
}
- @Test(dataProvider = "allSupports")
- public void test_Encoding_Type(FormSupportFactory factory)
+ public void test_Encoding_Type()
{
IMarkupWriter writer = newWriter();
NestedMarkupWriter nested = newNestedWriter();
@@ -385,10 +377,12 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
+ trainCycleSeedEncoding(cycle);
+
form.setBody(new IRender() {
public void render(IMarkupWriter pwriter, IRequestCycle pcycle)
{
@@ -435,8 +429,7 @@
verify();
}
- @Test(dataProvider = "allSupports")
- public void test_Field_Prerender_Twice(FormSupportFactory factory)
+ public void test_Field_Prerender_Twice()
{
IFormComponent field = newField();
IMarkupWriter writer = newWriter();
@@ -462,7 +455,7 @@
replay();
- FormSupport fs = newFormSupport(cycle);
+ FormSupport fs = new FormSupportImpl(cycle);
fs.prerenderField(writer, field, l);
@@ -491,8 +484,7 @@
}
- @Test(dataProvider = "allSupports")
- public void test_Hidden_Values(FormSupportFactory factory)
+ public void test_Hidden_Values()
{
IMarkupWriter writer = newWriter();
NestedMarkupWriter nested = newNestedWriter();
@@ -510,10 +502,12 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
+ trainCycleSeedEncoding(cycle);
+
form.setBody(new IRender() {
public void render(IMarkupWriter pwriter, IRequestCycle pcycle)
{
@@ -546,7 +540,9 @@
trainDiv(writer, form);
+
trainHidden(writer, "formids", "");
+ trainHidden(writer, "seedids", "ENCODED");
trainHidden(writer, "service", "fred");
trainHidden(writer, "submitmode", "");
trainHidden(writer, FormConstants.SUBMIT_NAME_PARAMETER, "");
@@ -572,8 +568,7 @@
verify();
}
- @Test(dataProvider = "allSupports")
- public void test_Invalid_Encoding_Type(FormSupportFactory factory)
+ public void test_Invalid_Encoding_Type()
{
IMarkupWriter writer = newWriter();
NestedMarkupWriter nested = newNestedWriter();
@@ -591,10 +586,12 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
+ trainCycleSeedEncoding(cycle);
+
form.setBody(new IRender() {
public void render(IMarkupWriter pwriter, IRequestCycle pcycle)
{
@@ -605,11 +602,8 @@
trainRegister(support, form, "myform");
- trainGetParameterNames(link, new String[]
- {"service"});
-
- trainGetParameterValues(link, "service", new String[]
- {"fred"});
+ trainGetParameterNames(link, new String[]{"service"});
+ trainGetParameterValues(link, "service", new String[]{"fred"});
trainGetNestedWriter(writer, nested);
@@ -629,8 +623,7 @@
verify();
}
- @Test(dataProvider = "mainSupport")
- public void test_Refresh_Rewind(FormSupportFactory factory)
+ public void test_Refresh_Rewind()
{
IMarkupWriter writer = newWriter();
IRequestCycle cycle = newCycle();
@@ -639,15 +632,15 @@
ComponentEventInvoker invoker = org.easymock.classextension.EasyMock.createMock(ComponentEventInvoker.class);
trainIsRewound(cycle, form, true);
-
trainGetPageRenderSupport(cycle, null);
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
+ trainCycleSeedEncoding(cycle);
delegate.clear();
trainCycleForRewind(cycle, "refresh", "barney", null);
@@ -672,8 +665,7 @@
verify();
}
- @Test(dataProvider = "mainSupport")
- public void test_Render_Extra_Reserved_Ids(FormSupportFactory factory)
+ public void test_Render_Extra_Reserved_Ids()
{
IMarkupWriter writer = newWriter();
NestedMarkupWriter nested = newNestedWriter();
@@ -692,10 +684,12 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
+ trainCycleSeedEncoding(cycle);
+
final IFormComponent component = newFormComponent("action", "action_0");
IRender body = newComponentRenderBody(fs, component, nested);
@@ -703,12 +697,8 @@
form.setBody(body);
trainRegister(support, form, "myform");
-
- trainGetParameterNames(link, new String[]
- {"action"});
-
- trainGetParameterValues(link, "action", new String[]
- {"fred"});
+ trainGetParameterNames(link, new String[]{"action"});
+ trainGetParameterValues(link, "action", new String[] {"fred"});
trainGetNestedWriter(writer, nested);
@@ -725,21 +715,19 @@
writer.println();
expect(cycle.getResponseBuilder()).andReturn(builder);
-
expect(builder.contains(form)).andReturn(false);
trainDiv(writer, form);
trainHidden(writer, "formids", "action_0");
+ trainHidden(writer, "seedids", "ENCODED");
trainHidden(writer, "action", "fred");
trainHidden(writer, "reservedids", "action");
trainHidden(writer, "submitmode", "");
trainHidden(writer, FormConstants.SUBMIT_NAME_PARAMETER, "");
writer.end();
-
nested.close();
-
writer.end();
support.addInitializationScript(form, "dojo.require(\"tapestry.form\");");
@@ -755,8 +743,7 @@
verify();
}
- @Test(dataProvider = "allSupports")
- public void test_Reset_Event_Handler(FormSupportFactory factory)
+ public void test_Reset_Event_Handler()
{
IMarkupWriter writer = newWriter();
NestedMarkupWriter nested = newNestedWriter();
@@ -776,10 +763,11 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
+ trainCycleSeedEncoding(cycle);
form.setBody(new IRender() {
public void render(IMarkupWriter pwriter, IRequestCycle pcycle)
{
@@ -790,11 +778,8 @@
trainRegister(support, form, "myform");
- trainGetParameterNames(link, new String[]
- {"service"});
-
- trainGetParameterValues(link, "service", new String[]
- {"fred"});
+ trainGetParameterNames(link, new String[] {"service"});
+ trainGetParameterValues(link, "service", new String[] {"fred"});
trainGetNestedWriter(writer, nested);
@@ -816,7 +801,6 @@
trainHiddenBlock(cycle, builder, writer, form, "fred", "");
nested.close();
-
writer.end();
support.addInitializationScript(form, "dojo.require(\"tapestry.form\");");
@@ -832,8 +816,7 @@
verify();
}
- @Test(dataProvider = "mainSupport")
- public void test_Rewind_Extra_Reserved_Ids(FormSupportFactory factory)
+ public void test_Rewind_Extra_Reserved_Ids()
{
IMarkupWriter writer = newWriter();
IRequestCycle cycle = newCycle();
@@ -849,10 +832,11 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
+ trainCycleSeedEncoding(cycle);
delegate.clear();
trainCycleForRewind(cycle, "action_0", "action");
@@ -875,8 +859,7 @@
verify();
}
- @Test(dataProvider = "mainSupport")
- public void test_Rewind_Mismatch(FormSupportFactory factory)
+ public void test_Rewind_Mismatch()
{
IMarkupWriter writer = newWriter();
IRequestCycle cycle = newCycle();
@@ -889,10 +872,11 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
+ trainCycleSeedEncoding(cycle);
Location l = newLocation();
delegate.clear();
@@ -929,8 +913,7 @@
verify();
}
- @Test(dataProvider = "mainSupport")
- public void test_Rewind_Too_Long(FormSupportFactory factory)
+ public void test_Rewind_Too_Long()
{
IMarkupWriter writer = newWriter();
IRequestCycle cycle = newCycle();
@@ -943,12 +926,13 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
+ trainCycleSeedEncoding(cycle);
+
Location l = newLocation();
-
delegate.clear();
// So, the scenario here is that component "barney" was inside
@@ -983,8 +967,7 @@
verify();
}
- @Test(dataProvider = "mainSupport")
- public void test_Rewind_Too_Short(FormSupportFactory factory)
+ public void test_Rewind_Too_Short()
{
Location l = newLocation();
IMarkupWriter writer = newWriter();
@@ -999,10 +982,11 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
+ trainCycleSeedEncoding(cycle);
delegate.clear();
// So, the scenario here is that component "barney" was inside
@@ -1040,8 +1024,7 @@
verify();
}
- @Test(dataProvider = "mainSupport")
- public void test_Simple_Render(FormSupportFactory factory)
+ public void test_Simple_Render()
{
IMarkupWriter writer = newWriter();
NestedMarkupWriter nested = newNestedWriter();
@@ -1061,10 +1044,11 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
+ trainCycleSeedEncoding(cycle);
final IFormComponent component = newFormComponent("barney", "barney");
IRender body = newComponentRenderBody(fs, component, nested);
@@ -1117,8 +1101,7 @@
verify();
}
- @Test(dataProvider = "allSupports")
- public void test_Simple_Render_With_Deferred_Runnable(FormSupportFactory factory)
+ public void test_Simple_Render_With_Deferred_Runnable()
{
IMarkupWriter writer = newWriter();
NestedMarkupWriter nested = newNestedWriter();
@@ -1138,10 +1121,11 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
+ trainCycleSeedEncoding(cycle);
IRender body = new IRender() {
public void render(final IMarkupWriter pwriter, IRequestCycle pcycle)
{
@@ -1199,8 +1183,7 @@
verify();
}
- @Test(dataProvider = "mainSupport")
- public void test_Simple_Render_With_Scheme(FormSupportFactory factory)
+ public void test_Simple_Render_With_Scheme()
{
IMarkupWriter writer = newWriter();
NestedMarkupWriter nested = newNestedWriter();
@@ -1220,10 +1203,11 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
+ trainCycleSeedEncoding(cycle);
final IFormComponent component = newFormComponent("barney", "barney");
IRender body = newComponentRenderBody(fs, component, nested);
@@ -1278,8 +1262,7 @@
verify();
}
- @Test(dataProvider = "mainSupport")
- public void test_Simple_Rewind(FormSupportFactory factory)
+ public void test_Simple_Rewind()
{
IMarkupWriter writer = newWriter();
IRequestCycle cycle = newCycle();
@@ -1294,10 +1277,11 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
+ trainCycleSeedEncoding(cycle);
delegate.clear();
trainCycleForRewind(cycle, "barney", null);
@@ -1320,8 +1304,7 @@
verify();
}
- @Test(dataProvider = "mainSupport")
- public void test_Simple_Rewind_With_Deferred_Runnable(FormSupportFactory factory)
+ public void test_Simple_Rewind_With_Deferred_Runnable()
{
IMarkupWriter writer = newWriter();
IRequestCycle cycle = newCycle();
@@ -1336,10 +1319,11 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
+ trainCycleSeedEncoding(cycle);
delegate.clear();
trainCycleForRewind(cycle, "", null);
@@ -1374,8 +1358,7 @@
verify();
}
- @Test(dataProvider = "allSupports")
- public void test_Simple_Submit_Event_Handler(FormSupportFactory factory)
+ public void test_Simple_Submit_Event_Handler()
{
IMarkupWriter writer = newWriter();
NestedMarkupWriter nested = newNestedWriter();
@@ -1395,10 +1378,11 @@
replay();
- final FormSupport fs = factory.createFormSupport(writer, cycle, form);
+ final FormSupport fs = newFormSupport(writer, cycle, form);
verify();
+ trainCycleSeedEncoding(cycle);
trainRegister(support, form, "myform");
trainGetParameterNames(link, new String[]
@@ -1457,6 +1441,9 @@
private void trainCycleForRewind(IRequestCycle cycle, String submitMode, String allocatedIds,
String reservedIds)
{
+ trainGetParameter(cycle, FormSupportImpl.SEED_IDS, "");
+ cycle.initializeIdState("");
+
trainGetParameter(cycle, FormSupportImpl.SUBMIT_MODE, submitMode);
trainGetParameter(cycle, FormSupportImpl.FORM_IDS, allocatedIds);
trainGetParameter(cycle, FormSupportImpl.RESERVED_FORM_IDS, reservedIds);
@@ -1521,6 +1508,7 @@
trainDiv(writer, form);
trainHidden(writer, "formids", formIds);
+ trainHidden(writer, "seedids", "ENCODED");
trainHidden(writer, "service", serviceName);
trainHidden(writer, "submitmode", "");
trainHidden(writer, FormConstants.SUBMIT_NAME_PARAMETER, "");
Modified: tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/test/org/apache/tapestry/util/TestIdAllocator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/test/org/apache/tapestry/util/TestIdAllocator.java?rev=611881&r1=611880&r2=611881&view=diff
==============================================================================
--- tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/test/org/apache/tapestry/util/TestIdAllocator.java (original)
+++ tapestry/tapestry4/branches/MultipleFormIDGeneration/tapestry-framework/src/test/org/apache/tapestry/util/TestIdAllocator.java Mon Jan 14 10:33:16 2008
@@ -13,8 +13,8 @@
// limitations under the License.
package org.apache.tapestry.util;
-import static org.testng.AssertJUnit.*;
-
+import org.apache.tapestry.util.io.CompressedDataEncoder;
+import static org.testng.AssertJUnit.assertEquals;
import org.testng.annotations.Test;
@@ -24,6 +24,7 @@
@Test
public class TestIdAllocator
{
+
public void test_Simple_Allocation()
{
IdAllocator ida = new IdAllocator();
@@ -76,5 +77,89 @@
assertEquals("name", ida.allocateId("name"));
assertEquals("name_0", ida.allocateId("Name"));
+ }
+
+ public void test_To_External_String()
+ {
+ IdAllocator ida = new IdAllocator();
+
+ ida.allocateId("ext");
+
+ assertEquals(",ext$0", ida.toExternalString());
+
+ ida.allocateId("ext");
+ ida.allocateId("ext2");
+
+ assertEquals(",ext$1,ext2$0", ida.toExternalString());
+ }
+
+ public void test_Empty_To_External_String()
+ {
+ IdAllocator ida = new IdAllocator();
+
+ assertEquals("", ida.toExternalString());
+ }
+
+ public void test_To_External_String_Namespace()
+ {
+ IdAllocator ida = new IdAllocator("NS");
+
+ ida.allocateId("ext");
+
+ assertEquals("NS,extNS$0", ida.toExternalString());
+ }
+
+ public void test_From_External_String()
+ {
+ String seed = "NS,extNS$3,testNS$2,simpleNS$0";
+
+ assertEquals(seed, IdAllocator.fromExternalString(seed).toExternalString());
+
+ seed = ",ext$0";
+ assertEquals(seed, IdAllocator.fromExternalString(seed).toExternalString());
+
+ seed = "";
+ assertEquals(seed, IdAllocator.fromExternalString(seed).toExternalString());
+ }
+
+ public void test_From_External_String_State()
+ {
+ String seed = "NS,extNS$3,testNS$2,simpleNS$0,ext_0NS$0";
+ IdAllocator ida = IdAllocator.fromExternalString(seed);
+
+ assertEquals("NS", ida._namespace);
+ assertEquals(9, ida._generatorMap.size());
+ assertEquals(4, ida._uniqueGenerators.size());
+ assertEquals("extNS_3", ida.allocateId("ext"));
+ }
+
+ public void test_Compressed_External_String()
+ {
+ String seed = "NS,extNS$3,testNS$2,simpleNS$0,ext_0NS$0";
+
+ String compressed = CompressedDataEncoder.encodeString(seed);
+ assertEquals(seed, CompressedDataEncoder.decodeString(compressed));
+
+ IdAllocator ida = IdAllocator.fromExternalString(CompressedDataEncoder.decodeString(compressed));
+
+ assertEquals("NS", ida._namespace);
+ assertEquals(9, ida._generatorMap.size());
+ assertEquals(4, ida._uniqueGenerators.size());
+ assertEquals("extNS_3", ida.allocateId("ext"));
+ }
+
+ public void test_Clear()
+ {
+ String seed = "NS,extNS$3,testNS$2,simpleNS$0,ext_0NS$0";
+ IdAllocator ida = IdAllocator.fromExternalString(seed);
+
+ assertEquals("NS", ida._namespace);
+ assertEquals(9, ida._generatorMap.size());
+ assertEquals(4, ida._uniqueGenerators.size());
+
+ ida.clear();
+
+ assertEquals(0, ida._generatorMap.size());
+ assertEquals(0, ida._uniqueGenerators.size());
}
}