Author: andrei_exadel
Date: 2008-05-22 08:18:22 -0400 (Thu, 22 May 2008)
New Revision: 8691
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/DataTableBean.java
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/model/Column.java
trunk/test-applications/seleniumTest/src/main/webapp/pages/dataTable/dataTableTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/DataTableTest.java
Log:
update dataTable Test
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/DataTableBean.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/DataTableBean.java 2008-05-22
12:02:24 UTC (rev 8690)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/DataTableBean.java 2008-05-22
12:18:22 UTC (rev 8691)
@@ -15,6 +15,10 @@
private int rows = 20;
private int column = 3;
+
+ private int begin = 1;
+
+ private int end = 10;
private List model;
@@ -46,7 +50,7 @@
columns = new ArrayList();
for (int i = 0; i < column; i++) {
- columns.add(new Column("Header_" + i,"Footer_" + i));
+ columns.add(new Column("header","footer", i));
}
}
@@ -124,4 +128,32 @@
this.ordering = ordering;
}
+ /**
+ * @return the begin
+ */
+ public int getBegin() {
+ return begin;
+ }
+
+ /**
+ * @param begin the begin to set
+ */
+ public void setBegin(int begin) {
+ this.begin = begin;
+ }
+
+ /**
+ * @return the end
+ */
+ public int getEnd() {
+ return end;
+ }
+
+ /**
+ * @param end the end to set
+ */
+ public void setEnd(int end) {
+ this.end = end;
+ }
+
}
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/model/Column.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/model/Column.java 2008-05-22
12:02:24 UTC (rev 8690)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/model/Column.java 2008-05-22
12:18:22 UTC (rev 8691)
@@ -4,6 +4,8 @@
public class Column {
+ private int i;
+
private String header;
private String footer;
@@ -15,8 +17,9 @@
* @param header
* @param footer
*/
- public Column(String header, String footer) {
+ public Column(String header, String footer, int i) {
super();
+ this.i = i;
this.header = header;
this.footer = footer;
}
@@ -25,7 +28,7 @@
* @return the header
*/
public String getHeader() {
- return header;
+ return header + i;
}
/**
@@ -39,7 +42,7 @@
* @return the footer
*/
public String getFooter() {
- return footer;
+ return footer + i;
}
/**
@@ -62,6 +65,20 @@
public void setOrdering(Ordering ordering) {
this.ordering = ordering;
}
+
+ /**
+ * @return the i
+ */
+ public int getI() {
+ return i;
+ }
+
+ /**
+ * @param i the i to set
+ */
+ public void setI(int i) {
+ this.i = i;
+ }
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/pages/dataTable/dataTableTest.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/dataTable/dataTableTest.xhtml 2008-05-22
12:02:24 UTC (rev 8690)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/dataTable/dataTableTest.xhtml 2008-05-22
12:18:22 UTC (rev 8691)
@@ -26,22 +26,42 @@
<h:inputText id="column"
value="#{dataTableBean.column}"></h:inputText>
</td>
</tr>
+ <tr>
+ <td>
+ Begin:
+ </td>
+ <td>
+ <h:inputText id="begin"
value="#{dataTableBean.begin}"></h:inputText>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ End:
+ </td>
+ <td>
+ <h:inputText id="end"
value="#{dataTableBean.end}"></h:inputText>
+ </td>
+ </tr>
</table>
<a4j:commandLink value="Apply" id="apply"
actionListener="#{dataTableBean.init}" reRender="table,
date"></a4j:commandLink>
</h:form>
<h:form id="_form">
- <h:outputText id="date"
value="#{dataTableBean.date}"></h:outputText>
+ <h:outputText id="date"
value="#{dataTableBean.date}"></h:outputText>
<rich:dataTable value="#{dataTableBean.model}" id="table"
var="var">
- <rich:columns value="#{dataTableBean.columns}" var="col"
index="i" sortBy="#{var[i]}"
sortOrder="#{col.ordering}">
+ <rich:columns
+ end="#{dataTableBean.end}"
+ begin="#{dataTableBean.begin}"
+ value="#{dataTableBean.columns}"
+ var="col" index="i" sortBy="#{var[i]}"
sortOrder="#{col.ordering}">
<f:facet name="header">
- <h:outputText value="header"></h:outputText>
+ <h:outputText value="#{col.header}"></h:outputText>
</f:facet>
<f:facet name="footer">
- <h:outputText value="footer"></h:outputText>
+ <h:outputText value="#{col.footer}"></h:outputText>
</f:facet>
<h:inputText value="#{var[i]}"></h:inputText>
- <h:outputText value="#{var[i]}"></h:outputText>
+ <h:outputText value="#{col.i}"></h:outputText>
</rich:columns>
</rich:dataTable>
<br/>
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/DataTableTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/DataTableTest.java 2008-05-22
12:02:24 UTC (rev 8690)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/DataTableTest.java 2008-05-22
12:18:22 UTC (rev 8691)
@@ -52,116 +52,144 @@
writeStatus("Check rows count equals to 22 ");
assertRowsCount(22, dataTableId);
+ String columnsId = getColumnId(dataTableId, 0);
+
writeStatus("Check inputs' values ");
- assertInputValue(dataTableId, 0, "j_id13", "0");
- assertInputValue(dataTableId, 5, "j_id13", "5");
- assertInputValue(dataTableId, 19, "j_id13", "19");
+ assertInputValue(dataTableId, 0, columnsId, "0");
+ assertInputValue(dataTableId, 5, columnsId, "5");
+ assertInputValue(dataTableId, 19, columnsId, "19");
- assertInputValue(dataTableId, 0, "j_id18", "1");
- assertInputValue(dataTableId, 7, "j_id18", "8");
- assertInputValue(dataTableId, 19, "j_id18", "20");
+ columnsId = getColumnId(dataTableId, 1);
- assertInputValue(dataTableId, 0, "j_id23", "2");
- assertInputValue(dataTableId, 11, "j_id23", "13");
- assertInputValue(dataTableId, 19, "j_id23", "21");
+ assertInputValue(dataTableId, 0, columnsId, "1");
+ assertInputValue(dataTableId, 7, columnsId, "8");
+ assertInputValue(dataTableId, 19, columnsId, "20");
+ columnsId = getColumnId(dataTableId, 2);
+
+ assertInputValue(dataTableId, 0, columnsId, "2");
+ assertInputValue(dataTableId, 11, columnsId, "13");
+ assertInputValue(dataTableId, 19, columnsId, "21");
+
writeStatus("Insert some values ");
- insertInputValue(dataTableId, 0, "j_id13", "000");
- insertInputValue(dataTableId, 19, "j_id23", "777");
+ insertInputValue(dataTableId, 0, getColumnId(dataTableId, 0), "000");
+ insertInputValue(dataTableId, 19, getColumnId(dataTableId, 2), "777");
writeStatus("Rerender table");
clickById("_form:submit");
waitForAjaxCompletion();
writeStatus("Check values entered ");
- assertInputValue(dataTableId, 0, "j_id13", "000");
- assertInputValue(dataTableId, 19, "j_id23", "777");
+ assertInputValue(dataTableId, 0, getColumnId(dataTableId, 0), "000");
+ assertInputValue(dataTableId, 19, getColumnId(dataTableId, 2), "777");
+ columnsId = getColumnId(dataTableId, 0);
+
writeStatus("Sort ASC by 1'st column ");
- sortColumn(dataTableId, "j_id13");
+ sortColumn(dataTableId, columnsId);
writeStatus("Check ordering");
- assertInputValue(dataTableId, 0, "j_id13", "000");
- assertInputValue(dataTableId, 1, "j_id13", "1");
- assertInputValue(dataTableId, 18, "j_id13", "8");
- assertInputValue(dataTableId, 19, "j_id13", "9");
+ assertInputValue(dataTableId, 0, columnsId, "000");
+ assertInputValue(dataTableId, 1, columnsId, "1");
+ assertInputValue(dataTableId, 18, columnsId, "8");
+ assertInputValue(dataTableId, 19, columnsId, "9");
writeStatus("Sort DESC by 1'st column ");
- sortColumn(dataTableId, "j_id13");
+ sortColumn(dataTableId, columnsId);
writeStatus("Check ordering");
- assertInputValue(dataTableId, 0, "j_id13", "9");
- assertInputValue(dataTableId, 1, "j_id13", "8");
- assertInputValue(dataTableId, 18, "j_id13", "1");
- assertInputValue(dataTableId, 19, "j_id13", "000");
+ assertInputValue(dataTableId, 0, columnsId, "9");
+ assertInputValue(dataTableId, 1, columnsId, "8");
+ assertInputValue(dataTableId, 18, columnsId, "1");
+ assertInputValue(dataTableId, 19, columnsId, "000");
- writeStatus("Sort ASC by 1'st column ");
- sortColumn(dataTableId, "j_id23");
+ columnsId = getColumnId(dataTableId, 2);
+
+ writeStatus("Sort ASC by 3'st column ");
+ sortColumn(dataTableId, columnsId);
writeStatus("Check ordering");
- assertInputValue(dataTableId, 0, "j_id23", "10");
- assertInputValue(dataTableId, 1, "j_id23", "11");
- assertInputValue(dataTableId, 18, "j_id23", "8");
- assertInputValue(dataTableId, 19, "j_id23", "9");
+ assertInputValue(dataTableId, 0, columnsId, "10");
+ assertInputValue(dataTableId, 1, columnsId, "11");
+ assertInputValue(dataTableId, 18, columnsId, "8");
+ assertInputValue(dataTableId, 19, columnsId, "9");
writeStatus("Set columns count == 5, rows count == 10");
- changeColumnCount(10, 5);
+ changeColumnCount(10, 5, 0 ,100);
- String lastColumnId = getLastColumnId(dataTableId, 5);
-
+
writeStatus("Check columns count equals to 5 ");
assertColumnsCount(5, dataTableId);
writeStatus("Check rows count equals to 12 ");
assertRowsCount(12, dataTableId);
+ columnsId = getColumnId(dataTableId, 0);
+
writeStatus("Check inputs' values ");
- assertInputValue(dataTableId, 0, "j_id13", "0");
- assertInputValue(dataTableId, 5, "j_id13", "5");
- assertInputValue(dataTableId, 9, "j_id13", "9");
+ assertInputValue(dataTableId, 0, columnsId, "0");
+ assertInputValue(dataTableId, 5, columnsId, "5");
+ assertInputValue(dataTableId, 9, columnsId, "9");
- assertInputValue(dataTableId, 0, "j_id18", "1");
- assertInputValue(dataTableId, 7, "j_id18", "8");
- assertInputValue(dataTableId, 9, "j_id18", "10");
+ columnsId = getColumnId(dataTableId, 1);
- assertInputValue(dataTableId, 0, lastColumnId, "4");
- assertInputValue(dataTableId, 2, lastColumnId, "6");
- assertInputValue(dataTableId, 9, lastColumnId, "13");
+ assertInputValue(dataTableId, 0, columnsId, "1");
+ assertInputValue(dataTableId, 7, columnsId, "8");
+ assertInputValue(dataTableId, 9, columnsId, "10");
+ columnsId = getColumnId(dataTableId, 4);
+
+ assertInputValue(dataTableId, 0, columnsId, "4");
+ assertInputValue(dataTableId, 2, columnsId, "6");
+ assertInputValue(dataTableId, 9, columnsId, "13");
+
writeStatus("Sort ASC by the last column ");
- sortColumn(dataTableId, lastColumnId);
+ sortColumn(dataTableId, columnsId);
writeStatus("Check ordering");
- assertInputValue(dataTableId, 0, lastColumnId, "10");
- assertInputValue(dataTableId, 2, lastColumnId, "12");
- assertInputValue(dataTableId, 9, lastColumnId, "9");
+ assertInputValue(dataTableId, 0, columnsId, "10");
+ assertInputValue(dataTableId, 2, columnsId, "12");
+ assertInputValue(dataTableId, 9, columnsId, "9");
writeStatus("Sort DESC by the last column ");
- sortColumn(dataTableId, lastColumnId);
+ sortColumn(dataTableId, columnsId);
writeStatus("Check ordering");
- assertInputValue(dataTableId, 0, lastColumnId, "9");
- assertInputValue(dataTableId, 2, lastColumnId, "7");
- assertInputValue(dataTableId, 9, lastColumnId, "10");
+ assertInputValue(dataTableId, 0, columnsId, "9");
+ assertInputValue(dataTableId, 2, columnsId, "7");
+ assertInputValue(dataTableId, 9, columnsId, "10");
+ columnsId = getColumnId(dataTableId, 2);
writeStatus("Sort ASC by the 3d column ");
- sortColumn(dataTableId, "j_id23");
+ sortColumn(dataTableId, columnsId);
writeStatus("Check ordering");
- assertInputValue(dataTableId, 0, "j_id23", "10");
- assertInputValue(dataTableId, 2, "j_id23", "2");
- assertInputValue(dataTableId, 9, "j_id23", "9");
+ assertInputValue(dataTableId, 0, columnsId, "10");
+ assertInputValue(dataTableId, 2, columnsId, "2");
+ assertInputValue(dataTableId, 9, columnsId, "9");
+ changeColumnCount(2, 5, 2 ,2);
+ assertColumnsCount(1, dataTableId);
+ assertRowsCount(4, dataTableId);
+ changeColumnCount(10, 5, 10 ,0);
+ assertRowsCount(0, dataTableId);
+
+
+
}
- private String getLastColumnId (String tableId, int columnsCount) {
- String script =
"$('"+tableId+"').rows[0].cells["+String.valueOf(columnsCount
- 1)+"].id";
+ private String getColumnId (String tableId, int i) {
+ String script =
"$('"+tableId+"').rows[0].cells["+String.valueOf(i)+"].id";
String id = runScript(script);
id = id.replace(tableId + ":", "");
id = id.replace("header", "");
return id;
}
- private void changeColumnCount(int rows, int columns) {
+ private void changeColumnCount(int rows, int columns, int begin, int end) {
String script = "$('_controls:rows').value='" +
String.valueOf(rows) + "';";
runScript(script);
script = "$('_controls:column').value='" +
String.valueOf(columns) + "';";
runScript(script);
+ script = "$('_controls:begin').value='" + String.valueOf(begin) +
"';";
+ runScript(script);
+ script = "$('_controls:end').value='" + String.valueOf(end) +
"';";
+ runScript(script);
clickById("_controls:apply");
waitForAjaxCompletion();
}
@@ -185,6 +213,7 @@
Assert.assertEquals(runScript(script), value);
}
+
private void assertColumnsCount(int i, String tableId) {
StringBuffer script = new StringBuffer("$('");
script.append(tableId);