Author: alevkovsky
Date: 2008-07-01 08:58:39 -0400 (Tue, 01 Jul 2008)
New Revision: 9316
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JRepeatTestBean.java
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxRepeat/ajaxRepeatTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxRepeatTest.java
Log:
Add additional methods to a4j:repeat selenium test
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JRepeatTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JRepeatTestBean.java 2008-07-01
12:37:39 UTC (rev 9315)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/A4JRepeatTestBean.java 2008-07-01
12:58:39 UTC (rev 9316)
@@ -165,21 +165,19 @@
int rowKey = getRepeater().getRowIndex();
keys.add(rowKey);
setKeys(keys);
- A4JRepeatItemTestBean item = items.get(rowKey);
- item.setNotRerenderedChangeCounter(item.getNotRerenderedChangeCounter() + 1);
- item.setRerenderedChangeCounter(item.getRerenderedChangeCounter() + 1);
- //priceRef.processValidators(FacesContext.getCurrentInstance());
- //priceRef.processUpdates(FacesContext.getCurrentInstance());
+ for (A4JRepeatItemTestBean item : items) {
+ item.setNotRerenderedChangeCounter(item.getNotRerenderedChangeCounter() + 1);
+ item.setRerenderedChangeCounter(item.getRerenderedChangeCounter() + 1);
+ }
return null;
}
-
- public String change2() {
- int rowKey = getRepeater().getRowIndex();
- A4JRepeatItemTestBean item = items.get(rowKey);
- item.setNotRerenderedChangeCounter(item.getNotRerenderedChangeCounter() + 1);
- item.setRerenderedChangeCounter(item.getRerenderedChangeCounter() + 1);
- //priceRef.processValidators(FacesContext.getCurrentInstance());
- //priceRef.processUpdates(FacesContext.getCurrentInstance());
+
+ public String changeWhithoutAjaxKeys() {
+ setKeys(null);
+ for (A4JRepeatItemTestBean item : items) {
+ item.setNotRerenderedChangeCounter(item.getNotRerenderedChangeCounter() + 1);
+ item.setRerenderedChangeCounter(item.getRerenderedChangeCounter() + 1);
+ }
return null;
}
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxRepeat/ajaxRepeatTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxRepeatTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxRepeatTest.java 2008-07-01
12:37:39 UTC (rev 9315)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxRepeatTest.java 2008-07-01
12:58:39 UTC (rev 9316)
@@ -13,8 +13,9 @@
/**
* a4j:repeat component selenium test
+ *
* @author Alexandr Levkovsky
- *
+ *
*/
public class AjaxRepeatTest extends SeleniumTestBase {
@@ -46,22 +47,126 @@
private final static String LINK_ID = "link";
+ private final static String BUTTON_ID = "button";
+
private final static String RERENDERED_COUNTER_ID =
"rerendered_change_counter";
private final static String NOT_RERENDERED_COUNTER_ID =
"not_rerendered_change_counter";
+ private final static String INPUT_VALUE_OUTPUT_ID = "input_output";
+
@Override
public String getTestUrl() {
return "pages/ajaxRepeat/ajaxRepeatTest.xhtml";
}
@Test(dataProvider = "templates")
+ public void testRerenderingRowsWithAjaxKeysAttribute(Template template) throws
Exception {
+ renderPage(template);
+ writeStatus("Testing rerendering rows with ajaxKeys attribute...");
+ // link action update counter fields in all rows but add only current
+ // row number to ajaxKeys so only current row counter should be
+ // rerendered
+ clickReset();
+ AssertRendered(TABLE_ID);
+ assertRowsCount(DEFAULT_ROWS_COUNT, TABLE_ID);
+
+ for (int i = 0; i < DEFAULT_ROWS_COUNT; i++) {
+ for (int j = 0; j < DEFAULT_ROWS_COUNT; j++) {
+ if (j < i) {
+ assertOutputText(j, RERENDERED_COUNTER_ID, new Integer(j + 1).toString());
+ } else {
+ assertOutputText(j, RERENDERED_COUNTER_ID, "0");
+ }
+ assertOutputText(j, NOT_RERENDERED_COUNTER_ID, "0");
+ }
+
+ writeStatus("click link " + i);
+ String linkId = getFullTableElementId(i, LINK_ID);
+ clickAjaxCommandAndWait(linkId);
+
+ for (int j = 0; j < DEFAULT_ROWS_COUNT; j++) {
+ if (j < i) {
+ assertOutputText(j, RERENDERED_COUNTER_ID, new Integer(j + 1).toString());
+ } else if (j == i) {
+ assertOutputText(j, RERENDERED_COUNTER_ID, new Integer(j + 1).toString());
+ } else {
+ assertOutputText(j, RERENDERED_COUNTER_ID, "0");
+ }
+ assertOutputText(i, NOT_RERENDERED_COUNTER_ID, "0");
+ }
+ }
+ }
+
+ @Test(dataProvider = "templates")
+ public void testRerenderingRowsWithoutAjaxKeysAttribute(Template template) throws
Exception {
+ renderPage(template);
+ writeStatus("Testing rerendering rows without ajaxKeys attribute...");
+ // button action update counter fields in all rows and sets ajaxKeys to
+ // null so counters in all rows should be rerendered.
+ clickReset();
+ AssertRendered(TABLE_ID);
+ assertRowsCount(DEFAULT_ROWS_COUNT, TABLE_ID);
+
+ for (int i = 0; i < DEFAULT_ROWS_COUNT; i++) {
+ for (int j = 0; j < DEFAULT_ROWS_COUNT; j++) {
+ assertOutputText(j, RERENDERED_COUNTER_ID, new Integer(i).toString());
+ assertOutputText(j, NOT_RERENDERED_COUNTER_ID, "0");
+ }
+
+ writeStatus("click button " + i);
+ String buttonId = getFullTableElementId(i, BUTTON_ID);
+ clickAjaxCommandAndWait(buttonId);
+
+ for (int j = 0; j < DEFAULT_ROWS_COUNT; j++) {
+ assertOutputText(j, RERENDERED_COUNTER_ID, new Integer(i + 1).toString());
+ assertOutputText(j, NOT_RERENDERED_COUNTER_ID, "0");
+ }
+ }
+ }
+
+ @Test(dataProvider = "templates")
+ public void testRerenderingRowsWithValidation(Template template) throws Exception {
+ renderPage(template);
+ writeStatus("Testing rerendering rows with validation...");
+ clickReset();
+ AssertRendered(TABLE_ID);
+ assertRowsCount(DEFAULT_ROWS_COUNT, TABLE_ID);
+
+ for (Integer i = 0; i < DEFAULT_ROWS_COUNT; i++) {
+ assertInputValue(i, INPUT_ID, i.toString());
+ assertOutputText(i, INPUT_VALUE_OUTPUT_ID, i.toString());
+ assertOutputText(i, RERENDERED_COUNTER_ID, "0");
+
+ writeStatus("set not valid value for row " + i + " input...");
+ type(getFullTableElementId(i, INPUT_ID), "200");
+ writeStatus("click link " + i);
+ String linkId = getFullTableElementId(i, LINK_ID);
+ clickAjaxCommandAndWait(linkId);
+
+ assertInputValue(i, INPUT_ID, "200");
+ assertOutputText(i, INPUT_VALUE_OUTPUT_ID, i.toString());
+ assertOutputText(i, RERENDERED_COUNTER_ID, "0");
+
+ writeStatus("set valid value for row " + i + " input...");
+ type(getFullTableElementId(i, INPUT_ID), "99");
+ writeStatus("click link " + i);
+ clickAjaxCommandAndWait(linkId);
+
+ assertInputValue(i, INPUT_ID, "99");
+ assertOutputText(i, INPUT_VALUE_OUTPUT_ID, "99");
+ assertOutputText(i, RERENDERED_COUNTER_ID, new Integer(i + 1).toString());
+ }
+ }
+
+ @Test(dataProvider = "templates")
public void testRenderedAttribute(Template template) throws Exception {
renderPage(template);
writeStatus("Testing rendered attribute...");
clickReset();
AssertRendered(TABLE_ID);
- // repeat has rendered=true and should present on page as table with default 5 rows
+ // repeat has rendered=true and should present on page as table with
+ // default 5 rows
assertRowsCount(5, TABLE_ID);
writeStatus("change rendered attribute to false");
@@ -71,7 +176,8 @@
writeStatus("Click apply");
clickApply();
- // repeat now has rendered=false and should not present on page as table with default 0
rows
+ // repeat now has rendered=false and should not present on page as table
+ // with default 0 rows
assertRowsCount(0, TABLE_ID);
}
@@ -81,7 +187,8 @@
writeStatus("Testing first attribute...");
clickReset();
AssertRendered(TABLE_ID);
- // repeat has rendered=true and should present on page as table with default 5 rows
+ // repeat has rendered=true and should present on page as table with
+ // default 5 rows
assertRowsCount(5, TABLE_ID);
// first row default value 0
String fullInput0Id = getParentId() + FORM2_ID + REPEAT_ID + ":" + 0 +
":" + OUTPUT_ID;
@@ -106,7 +213,8 @@
writeStatus("Testing rows attribute...");
clickReset();
AssertRendered(TABLE_ID);
- // repeat has rows=0 and table with all default 5 rows should present on page
+ // repeat has rows=0 and table with all default 5 rows should present on
+ // page
assertRowsCount(5, TABLE_ID);
writeStatus("change rendered attribute to false");
@@ -116,7 +224,8 @@
writeStatus("Click apply");
clickApply();
- // repeat now has rendered=false and should not present on page as table with default 0
rows
+ // repeat now has rendered=false and should not present on page as table
+ // with default 0 rows
assertRowsCount(3, TABLE_ID);
// last row should have value 2
assertInputValue(2, INPUT_ID, "2");
@@ -140,25 +249,6 @@
}
}
- @Test(dataProvider = "templates")
- public void testAjaxKeysAttribute(Template template) throws Exception {
- renderPage(template);
- writeStatus("Testing ajaxKeys attribute...");
- clickReset();
- AssertRendered(TABLE_ID);
- assertRowsCount(DEFAULT_ROWS_COUNT, TABLE_ID);
-
- for (int i = 0; i < DEFAULT_ROWS_COUNT; i++) {
- String LinkId = getFullTableElementId(i, LINK_ID);
- assertOutputText(i, RERENDERED_COUNTER_ID, "0");
- assertOutputText(i, NOT_RERENDERED_COUNTER_ID, "0");
- writeStatus("click link...");
- clickAjaxCommandAndWait(LinkId);
- assertOutputText(i, RERENDERED_COUNTER_ID, "1");
- assertOutputText(i, NOT_RERENDERED_COUNTER_ID, "0");
- }
- }
-
private void clickReset() {
String buttonId = getParentId() + FORM2_ID + RESET_BUTTON_ID;
writeStatus("Click reset button");