Author: craigmcc
Date: Mon Nov  6 23:35:41 2006
New Revision: 472015

URL: http://svn.apache.org/viewvc?view=rev&rev=472015
Log:
Update the integration tests to include a simulation of back button behavior,
which currently (IMHO) does the right thing -- it redisplays the current page
with an error if you try to resubmit the same form again.  AFAICT, the trunk
code currently functions as designed, so I'll post the WAR file on SHALE-287
so other people can experiment and see if they can prove me wrong :-).


Modified:
    shale/framework/trunk/shale-apps/shale-test-core/src/main/webapp/token1.jsp
    
shale/framework/trunk/shale-apps/shale-test-core/src/test/java/org/apache/shale/examples/test/core/systest/IntegrationTestCase.java

Modified: 
shale/framework/trunk/shale-apps/shale-test-core/src/main/webapp/token1.jsp
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-core/src/main/webapp/token1.jsp?view=diff&rev=472015&r1=472014&r2=472015
==============================================================================
--- shale/framework/trunk/shale-apps/shale-test-core/src/main/webapp/token1.jsp 
(original)
+++ shale/framework/trunk/shale-apps/shale-test-core/src/main/webapp/token1.jsp 
Mon Nov  6 23:35:41 2006
@@ -34,7 +34,7 @@
 
     <h:form                          id="form">
         <h:messages                  id="global"
-                             globalOnly="true"/>
+                             globalOnly="false"/>
         <h:panelGrid                 id="grid"
                                 columns="3">
 

Modified: 
shale/framework/trunk/shale-apps/shale-test-core/src/test/java/org/apache/shale/examples/test/core/systest/IntegrationTestCase.java
URL: 
http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/shale-test-core/src/test/java/org/apache/shale/examples/test/core/systest/IntegrationTestCase.java?view=diff&rev=472015&r1=472014&r2=472015
==============================================================================
--- 
shale/framework/trunk/shale-apps/shale-test-core/src/test/java/org/apache/shale/examples/test/core/systest/IntegrationTestCase.java
 (original)
+++ 
shale/framework/trunk/shale-apps/shale-test-core/src/test/java/org/apache/shale/examples/test/core/systest/IntegrationTestCase.java
 Mon Nov  6 23:35:41 2006
@@ -21,6 +21,8 @@
 
 import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
 import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlHiddenInput;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
 import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
 import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
 import junit.framework.Test;
@@ -190,6 +192,44 @@
 
         // Should have returned to the main menu
         assertEquals("Shale Test App (Core Library)", title());
+
+    }
+
+
+    // Test /token1.jsp simulating a resubmit of the same page
+    public void testTokenResubmit() throws Exception {
+
+        HtmlHiddenInput hidden;
+        HtmlTextInput input;
+        HtmlSubmitInput submit;
+        page("/token1.faces");
+
+        // /token1.jsp valid input
+        assertEquals("Token Processor Test (Page 1)", title());
+        input = (HtmlTextInput) element("form:input");
+        assertNotNull(input);
+        input.setValueAttribute("abc");
+        hidden = (HtmlHiddenInput) element("form:token");
+        assertNotNull(hidden);
+        submit = (HtmlSubmitInput) element("form:submit");
+        assertNotNull(submit);
+        HtmlPage page = page();
+        submit(submit);
+
+        // Should have switched to /token2.jsp
+        assertEquals("Token Processor Test (Page 2)", title());
+
+        // /token1.jsp valid input (resubmitted)
+        reset(page);
+        assertEquals("Token Processor Test (Page 1)", title());
+        hidden = (HtmlHiddenInput) element("form:token");
+        assertNotNull(hidden);
+        submit = (HtmlSubmitInput) element("form:submit");
+        assertNotNull(submit);
+        submit(submit);
+
+        // Should still be on /token1.jsp
+        assertEquals("Token Processor Test (Page 1)", title());
 
     }
 


Reply via email to