tester.startPage(MockPageWithFormAndAjaxFormSubmitBehavior.class);
// Get the page
MockPageWithFormAndAjaxFormSubmitBehavior page = (MockPageWithFormAndAjaxFormSubmitBehavior)tester.getLastRenderedPage();
Pojo pojo = page.getPojo();
assertEquals("Mock name", pojo.getName());
TextField<?> name = (TextField<?>)tester.getComponentFromLastRenderedPage("form:name");
assertEquals("Mock name", name.getValue());
assertFalse(page.isExecuted());
tester.getRequest().getPostParameters().setParameterValue(name.getInputName(), "Mock name");
// Execute the ajax event
tester.executeAjaxEvent(MockPageWithFormAndAjaxFormSubmitBehavior.EVENT_COMPONENT,
"onclick");
assertTrue("AjaxFormSubmitBehavior.onSubmit() has not been executed in " +
MockPageWithFormAndAjaxFormSubmitBehavior.class, page.isExecuted());
assertEquals("Mock name",
((TextField<?>)tester.getComponentFromLastRenderedPage("form:name")).getValue());
// The name of the pojo should still be the same. If the
// executeAjaxEvent weren't submitting the form the name would have been
// reset to null, because the form would have been updated but there
// wouldn't be any data to update it with.
assertNotNull("executeAjaxEvent() did not properly submit the form", pojo.getName());
assertEquals("Mock name", pojo.getName());
}