CVS: Tapestry/junit/src/net/sf/tapestry/junit/mock TestStaleForm.xml,NONE,1.1.2.1 TestBlock.xml,1.1.2.1,1.1.2.2 MockTestCase.java,1.10.2.11,1.10.2.12 TestRegisterForm.xml,1.4.2.2,1.4.2.3 TestStaleSessionException.xml,1.2.2.2,1.2.2.3

Howard Lewis Ship <[email protected]>
Newsgroups gmane.comp.java.tapestry.cvs
Message-ID <[email protected]>
Update of /cvsroot/tapestry/Tapestry/junit/src/net/sf/tapestry/junit/mock
In directory sc8-pr-cvs1:/tmp/cvs-serv8557/junit/src/net/sf/tapestry/junit/mock

Modified Files:
      Tag: hship-2-3
	TestBlock.xml MockTestCase.java TestRegisterForm.xml 
	TestStaleSessionException.xml 
Added Files:
      Tag: hship-2-3
	TestStaleForm.xml 
Log Message:
Change Form to record allocated element ids as a hidden field, and compare against it when the form is submitted.
Change StaleLink page to display the message from the StaleLinkException.

--- NEW FILE: TestStaleForm.xml ---
<?xml version="1.0" encoding="UTF-8"?>

<!-- $Id: TestStaleForm.xml,v 1.1.2.1 2002/12/21 13:05:46 hship Exp $ -->

<!-- Performs some tests to simulate a StaleLink scenario when submitting a form.  -->

<mock-test>
    <context name="mock"/>
    <servlet name="app" class="net.sf.tapestry.ApplicationServlet">
  		<init-parameter
  			name="net.sf.tapestry.application-specification"
  			value="/net/sf/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"/>
  		<parameter name="context" value="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>context</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</match>
			<match>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"/>
  		<parameter name="context" value="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"/>
  		<parameter name="context" value="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"/>
  		<parameter name="context" value="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>	
Index: TestBlock.xml
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/junit/src/net/sf/tapestry/junit/mock/Attic/TestBlock.xml,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** TestBlock.xml	19 Dec 2002 12:26:59 -0000	1.1.2.1
--- TestBlock.xml	21 Dec 2002 13:05:46 -0000	1.1.2.2
***************
*** 76,80 ****
  		<parameter name="sp" value="S1"/>
  		<parameter name="$Submit" value="Trigger"/>
! 		<parameter name="Form1" value="1"/>
  		
  		<assert-output name="Form Status">
--- 76,80 ----
  		<parameter name="sp" value="S1"/>
  		<parameter name="$Submit" value="Trigger"/>
! 		<parameter name="Form1" value="$Submit"/>
  		
  		<assert-output name="Form Status">

Index: MockTestCase.java
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/junit/src/net/sf/tapestry/junit/mock/MockTestCase.java,v
retrieving revision 1.10.2.11
retrieving revision 1.10.2.12
diff -C2 -d -r1.10.2.11 -r1.10.2.12
*** MockTestCase.java	19 Dec 2002 12:26:58 -0000	1.10.2.11
--- MockTestCase.java	21 Dec 2002 13:05:46 -0000	1.10.2.12
***************
*** 43,46 ****
--- 43,57 ----
  
      /**
+      *  Test several Stale Link scenarios for the Form component.
+      * 
+      **/
+     
+     public void testStaleForm()
+     throws Exception
+     {
+         attempt("TestStaleForm.xml");
+     }
+ 
+     /**
       *  Test Block and InsertBlock, especially w.r.t. links and forms
       *  inside the Block on foriegn pages.

Index: TestRegisterForm.xml
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/junit/src/net/sf/tapestry/junit/mock/TestRegisterForm.xml,v
retrieving revision 1.4.2.2
retrieving revision 1.4.2.3
diff -C2 -d -r1.4.2.2 -r1.4.2.3
*** TestRegisterForm.xml	19 Dec 2002 12:26:59 -0000	1.4.2.2
--- TestRegisterForm.xml	21 Dec 2002 13:05:46 -0000	1.4.2.3
***************
*** 33,37 ****
  		</assert-output>
  		
! 		<assert-matches name="Hidden Fields - Names" subgroup="1">
  <![CDATA[
  <input type="hidden" name="(.*?)" value="(.*?)"/>
--- 33,37 ----
  		</assert-output>
  		
! 		<assert-output-matches name="Hidden Fields - Names" subgroup="1">
  <![CDATA[
  <input type="hidden" name="(.*?)" value="(.*?)"/>
***************
*** 41,47 ****
  			<match>sp</match>
  			<match>Form0</match>
! 		</assert-matches>
  				
! 		<assert-matches name="Hidden Fields - Values" subgroup="2">
  <![CDATA[
  <input type="hidden" name="(.*?)" value="(.*?)"/>
--- 41,47 ----
  			<match>sp</match>
  			<match>Form0</match>
! 		</assert-output-matches>
  				
! 		<assert-output-matches name="Hidden Fields - Values" subgroup="2">
  <![CDATA[
  <input type="hidden" name="(.*?)" value="(.*?)"/>
***************
*** 50,63 ****
  			<match>0/Register/form</match>
  			<match>S0</match>
! 			<match>4</match>
! 		</assert-matches>
  			 	
! 		<assert-matches name="Text Fields" subgroup="1">
  <![CDATA[
! <input type="text" name="(.*?)" size="40" maxlength="100"/>
  ]]>
  			<match>inputFirstName</match>
  			<match>inputLastName</match>	
! 		</assert-matches>
  		
  		<assert-output name="Radio Button - Male">
--- 50,63 ----
  			<match>0/Register/form</match>
  			<match>S0</match>
! 			<match>inputFirstName,inputLastName,inputSex,inputAgeRange</match>
! 		</assert-output-matches>
  			 	
! 		<assert-output-matches name="Text Fields" subgroup="1">
  <![CDATA[
! <input type="text" name="(.*?)" (.*?)/>
  ]]>
  			<match>inputFirstName</match>
  			<match>inputLastName</match>	
! 		</assert-output-matches>
  		
  		<assert-output name="Radio Button - Male">
***************
*** 79,85 ****
  		</assert-output>
  		
! 		<assert-matches name="Option Values" subgroup="1">
  <![CDATA[
! <option value="(.*?)" (selected="selected")?>(.*?)</option>
  ]]>
  			<match>0</match>
--- 79,85 ----
  		</assert-output>
  		
! 		<assert-output-matches name="Option Values" subgroup="1">
  <![CDATA[
! <option value="(.*?)"( selected="selected")?>(.*?)</option>
  ]]>
  			<match>0</match>
***************
*** 88,96 ****
  			<match>3</match>
  			<match>4</match>
! 		</assert-matches>
  		
! 		<assert-matches name="Option Labels" subgroup="3">
  <![CDATA[
! <option value="(.*?)" (selected="selected")?>(.*?)</option>
  ]]>
  			<match>Child (0 - 9)</match>
--- 88,96 ----
  			<match>3</match>
  			<match>4</match>
! 		</assert-output-matches>
  		
! 		<assert-output-matches name="Option Labels" subgroup="3">
  <![CDATA[
! <option value="(.*?)"( selected="selected")?>(.*?)</option>
  ]]>
  			<match>Child (0 - 9)</match>
***************
*** 99,110 ****
  			<match>Retiree (61 - 75)</match>
  			<match>Elderly (76+)</match>
! 		</assert-matches>
  				
! 		<assert-matches name="Selected Option" subgroup="1">
  <![CDATA[
  <option value="(.*?)" selected="selected"
  ]]>
  			<match>2</match>
! 		</assert-matches>												 		
    	</request>
    	
--- 99,110 ----
  			<match>Retiree (61 - 75)</match>
  			<match>Elderly (76+)</match>
! 		</assert-output-matches>
  				
! 		<assert-output-matches name="Selected Option" subgroup="1">
  <![CDATA[
  <option value="(.*?)" selected="selected"
  ]]>
  			<match>2</match>
! 		</assert-output-matches>												 		
    	</request>
    	
***************
*** 119,123 ****
    		<parameter name="inputSex" value="1"/>
    		<parameter name="inputAgeRange" value="1"/>
!   		<parameter name="Form0" value="4"/>
    		
      		
--- 119,123 ----
    		<parameter name="inputSex" value="1"/>
    		<parameter name="inputAgeRange" value="1"/>
!   		<parameter name="Form0" value="inputFirstName,inputLastName,inputSex,inputAgeRange"/>
    		
      		
***************
*** 143,159 ****
   		</assert-output>
   		 				
!   		<assert-matches name="Selected Option" subgroup="1">
  <![CDATA[
  <option value="(.*?)" selected="selected"
  ]]>
  			<match>1</match>
! 		</assert-matches>	
  		
! 		<assert-matches name="Selected Radio" subgroup="1">
  <![CDATA[
  <input type="radio" name="inputSex" checked="checked" value="(.*?)"/>
  ]]>
  			<match>1</match>
! 		</assert-matches>
  		
  <!-- This can be tricky, the order in which the maxlength and size attributes
--- 143,159 ----
   		</assert-output>
   		 				
!   		<assert-output-matches name="Selected Option" subgroup="1">
  <![CDATA[
  <option value="(.*?)" selected="selected"
  ]]>
  			<match>1</match>
! 		</assert-output-matches>	
  		
! 		<assert-output-matches name="Selected Radio" subgroup="1">
  <![CDATA[
  <input type="radio" name="inputSex" checked="checked" value="(.*?)"/>
  ]]>
  			<match>1</match>
! 		</assert-output-matches>
  		
  <!-- This can be tricky, the order in which the maxlength and size attributes
***************
*** 181,185 ****
    		<parameter name="inputSex" value="1"/>
    		<parameter name="inputAgeRange" value="2"/>
!   		<parameter name="Form0" value="4"/>	
    		
    		
--- 181,185 ----
    		<parameter name="inputSex" value="1"/>
    		<parameter name="inputAgeRange" value="2"/>
!   		<parameter name="Form0" value="inputFirstName,inputLastName,inputSex,inputAgeRange"/>	
    		
    		

Index: TestStaleSessionException.xml
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/junit/src/net/sf/tapestry/junit/mock/TestStaleSessionException.xml,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -C2 -d -r1.2.2.2 -r1.2.2.3
*** TestStaleSessionException.xml	19 Dec 2002 12:26:59 -0000	1.2.2.2
--- TestStaleSessionException.xml	21 Dec 2002 13:05:46 -0000	1.2.2.3
***************
*** 57,61 ****
  			<match>0/Stale/form</match>
  			<match>S1</match>
! 			<match>0</match>
  		</assert-output-matches>
  
--- 57,61 ----
  			<match>0/Stale/form</match>
  			<match>S1</match>
! 			<match></match>
  		</assert-output-matches>
  
***************
*** 100,104 ****
  		<parameter name="context" value="1/Stale/form"/>
  		<parameter name="sp" value="S1"/>
! 		<parameter name="Form1" value="0"/>
  		
  		<assert-output name="StaleSession (Form)">
--- 100,104 ----
  		<parameter name="context" value="1/Stale/form"/>
  		<parameter name="sp" value="S1"/>
! 		<parameter name="Form1" value=""/>
  		
  		<assert-output name="StaleSession (Form)">



-------------------------------------------------------
This SF.NET email is sponsored by: Order your Holiday Geek Presents Now!
Green Lasers, Hip Geek T-Shirts, Remote Control Tanks, Caffeinated Soap,
MP3 Players,  XBox Games,  Flying Saucers,  WebCams,  Smart Putty.
T H I N K G E E K . C O M       http://www.thinkgeek.com/sf/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.