Author: dsvyatobatsko
Date: 2008-08-04 12:51:09 -0400 (Mon, 04 Aug 2008)
New Revision: 9901
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JFormTestBean.java
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxForm/ajaxFormTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxFormTest.java
Log:
ajaxForm test fixed
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JFormTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JFormTestBean.java 2008-08-04
15:25:02 UTC (rev 9900)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JFormTestBean.java 2008-08-04
16:51:09 UTC (rev 9901)
@@ -3,15 +3,15 @@
public class A4JFormTestBean {
private String name = "before submit";
-
+
private Boolean ajaxSubmit;
-
+
private Boolean ignoreDupResponses;
-
+
private Boolean prependId;
-
+
private String rerender = "";
-
+
private Boolean rendered = false;
public String getRerender() {
@@ -61,9 +61,19 @@
public void setRendered(Boolean rendered) {
this.rendered = rendered;
}
-
+
public void changeName() {
- this.name = "after submit";
+ this.name = "after submit";
}
-
+
+ public String reset() {
+ name = "before submit";
+ ajaxSubmit = false;
+ ignoreDupResponses = false;
+ prependId = false;
+ rerender = "";
+ rendered = false;
+ return null;
+ }
+
}
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxForm/ajaxFormTest.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxForm/ajaxFormTest.xhtml 2008-08-04
15:25:02 UTC (rev 9900)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxForm/ajaxFormTest.xhtml 2008-08-04
16:51:09 UTC (rev 9901)
@@ -58,6 +58,10 @@
<a4j:commandButton id= "submit2" value="Submit"
reRender="group2"/>
</a4j:form>
</h:panelGroup>
+ <h:form id="_form">
+ <br/>
+ <a4j:commandButton id="reset" action="#{formBean.reset}"
value="Reset"/>
+ </h:form>
</ui:define>
</ui:composition>
</html>
\ No newline at end of file
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxFormTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxFormTest.java 2008-08-04
15:25:02 UTC (rev 9900)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxFormTest.java 2008-08-04
16:51:09 UTC (rev 9901)
@@ -6,116 +6,131 @@
import org.testng.annotations.Test;
public class AjaxFormTest extends SeleniumTestBase {
-
+
private final static String TEST_URL =
"pages/ajaxForm/ajaxFormTest.xhtml";
-
+
private final static String FORM_ID = "a4j_form";
-
+
private static final String STANDART_FORM = "staticForm";
-
+
private final static String INNER_INPUT_ID = "inner_name";
-
+
private final static String OUTER_INPUT_ID = "outer_name";
-
+
private final static String TEST_FIELD_ID = "test_field_name";
-
+
private final static String BUTTON_ID = "submit";
-
+
private final static String PREV_TEXT = "before submit";
-
+
private final static String NEXT_TEXT = "after submit";
-
+
private final static String CHECK_ID_AJAXSUBMIT = "ajaxSubmit";
-
+
private final static String CHECK_ID_IGNOREDUPRESPONSES =
"ignoreDupResponses";
-
+
private final static String CHECK_ID_PREPENDID = "prependId";
-
+
private final static String CHECK_ID_RENDERED = "rendered";
-
+
private final static String PANEL_GROUP = "content";
-
+
private final static String RERENDER_ID = "rerender";
-
+
private final static String LINK_ID = "link";
@Test
public void testAttrAjaxSubmit(Template template) throws Exception {
- renderPage(template);
+ renderPage(template);
- //clickOnCheckbox(CHECK_ID_AJAXSUBMIT, BUTTON_ID);
- test(BUTTON_ID, INNER_INPUT_ID,
STANDART_FORM.concat(":").concat(OUTER_INPUT_ID), TEST_FIELD_ID, true, null,
null, null, "testAttrAjaxSubmit");
+ // clickOnCheckbox(CHECK_ID_AJAXSUBMIT, BUTTON_ID);
+ test(BUTTON_ID, INNER_INPUT_ID,
STANDART_FORM.concat(":").concat(OUTER_INPUT_ID), TEST_FIELD_ID, true, null,
+ null, null, "testAttrAjaxSubmit");
+
+ resetTestData();
}
@Test
public void testAttrPrependId(Template template) {
- renderPage(template);
+ renderPage(template);
- if (!PREV_TEXT.equals(getValueById(getFullComponentId(INNER_INPUT_ID, "1"))))
{
- assertFail(null, null, true, null, "testAttrPrependId");
- }
+ if (!PREV_TEXT.equals(getValueById(getFullComponentId(INNER_INPUT_ID,
"1")))) {
+ assertFail(null, null, true, null, "testAttrPrependId");
+ }
+
+ resetTestData();
}
- /*@Test
- public void testAttrIgnoreDupResponses() {
- //TODO: will be implemented in future
- }*/
-
- /*@Test
- public void testAttrTimeout() {
- //TODO: will be implemented in future
- }*/
+ /*
+ * @Test public void testAttrIgnoreDupResponses() { //TODO: will be
+ * implemented in future }
+ */
+ /*
+ * @Test public void testAttrTimeout() { //TODO: will be implemented in
+ * future }
+ */
+
@Test
public void testProcessingLinks(Template template) {
- renderPage(template);
+ renderPage(template);
- clickOnCheckbox(CHECK_ID_RENDERED, BUTTON_ID, "2");
- clickById(LINK_ID.concat("2"));
- waitForAjaxCompletion();
- if (!NEXT_TEXT.equals(getTextById(TEST_FIELD_ID.concat("2")))) {
- assertFail(null, null, null, null, "testProcessingLinks");
- }
+ clickOnCheckbox(CHECK_ID_RENDERED, BUTTON_ID, "2");
+ clickById(getParentId() + LINK_ID.concat("2"));
+ waitForAjaxCompletion();
+ if (!NEXT_TEXT.equals(getTextById(getParentId() +
TEST_FIELD_ID.concat("2")))) {
+ assertFail(null, null, null, null, "testProcessingLinks");
+ }
+
+ resetTestData();
}
private String getFullComponentId(String componentId, String index) {
- return FORM_ID.concat(index).concat(":").concat(componentId.concat(index));
+ return getParentId() + FORM_ID + index + ":" + componentId + index;
}
-
+
private boolean isAjaxSubmitSuccessfull(String innerInputId, String outerInputId) {
- String innerText = getTextById(innerInputId);
- String outerText = getValueById(outerInputId);
- return (NEXT_TEXT.equals(innerText) && (PREV_TEXT.equals(outerText)));
+ String innerText = getTextById(getParentId() + innerInputId);
+ String outerText = getValueById(getParentId() + outerInputId);
+ return (NEXT_TEXT.equals(innerText) && (PREV_TEXT.equals(outerText)));
}
-
+
private void submitForm(String buttonId) {
- clickById(buttonId);
- waitForAjaxCompletion();
+ writeStatus("Submit form");
+ clickAjaxCommandAndWait(getParentId() + buttonId);
}
-
+
private void test(String buttonId, String innerInputId, String outerInputId, String
testInputId,
- Boolean ajaxSubmit, Boolean ignoreDupResponses,
- Integer timeout, Boolean prependId, String testName) {
- setValueById(innerInputId, NEXT_TEXT);
- submitForm(buttonId);
- if (!isAjaxSubmitSuccessfull(testInputId, outerInputId)) {
- assertFail(ajaxSubmit, ignoreDupResponses, prependId, timeout, testName);
- }
+ Boolean ajaxSubmit, Boolean ignoreDupResponses, Integer timeout, Boolean
prependId, String testName) {
+ setValueById(getParentId() + innerInputId, NEXT_TEXT);
+ submitForm(buttonId);
+ if (!isAjaxSubmitSuccessfull(testInputId, outerInputId)) {
+ assertFail(ajaxSubmit, ignoreDupResponses, prependId, timeout, testName);
+ }
}
-
- private void assertFail(Boolean ajaxSubmit, Boolean ignoreDupResponses, Boolean
prependId, Integer timeout, String testName) {
- Assert.fail("<a4j:form> [ajaxSubmit=" + ajaxSubmit + " ;
ignoreDupResponses="
- + ignoreDupResponses + " ; timeout=" + timeout
- + " ; prependId=" + prependId + "] test '" + testName +
"' failure.");
+
+ private void assertFail(Boolean ajaxSubmit, Boolean ignoreDupResponses, Boolean
prependId, Integer timeout,
+ String testName) {
+ Assert.fail("<a4j:form> [ajaxSubmit=" + ajaxSubmit + " ;
ignoreDupResponses=" + ignoreDupResponses
+ + " ; timeout=" + timeout + " ; prependId=" +
prependId + "] test '" + testName + "' failure.");
}
-
+
private void clickOnCheckbox(String checkId, String bottonId, String index) {
- clickById(checkId.concat(index));
- clickById(bottonId.concat(index));
- waitForAjaxCompletion();
+ clickById(getParentId() + checkId + index);
+ clickById(getParentId() + bottonId +index);
+ waitForAjaxCompletion();
}
-
+
+ private void resetTestData() {
+ String id = getParentId() + "_form:reset";
+ selenium.highlight(id);
+ isPresentById(id);
+ delay(1000);
+ clickAjaxCommandAndWait(id);
+ delay(1000);
+ }
+
public String getTestUrl() {
- return TEST_URL;
+ return TEST_URL;
}
}