* HiddenField.
*
* CLK-267.
*/
public void testDuplicateOnSubmitCheck() {
MockContext context = MockContext.initContext("test-form.htm");
MockRequest request = (MockRequest) context.getMockRequest();
request.setParameter("form_name", "form");
Page page = new Page();
// Set the page to stateful
page.setStateful(true);
Form form = new Form("form");
// Construct name of submit token
String submitCheckName = Form.SUBMIT_CHECK + form.getName() + "_" + context.getResourcePath();
// Simulate a submit check
boolean valid = form.onSubmitCheck(page, "/invalid-submit.html");
Assert.assertTrue(valid);
// Assert that the submitCheck hidden field was created
Field submitCheckField = form.getField(submitCheckName);
Assert.assertNotNull(submitCheckField);
// Add submitCheckField as a request parameter
request.getParameterMap().put(Form.SUBMIT_CHECK + form.getName() + "_" + context.getResourcePath(), submitCheckField.getValue());
// Simulate a second submit check.
valid = form.onSubmitCheck(page, "/invalid-submit.html");
// Assert the second onSubmitCheck did succeed as well.