Author: andrei_exadel
Date: 2009-02-12 12:48:48 -0500 (Thu, 12 Feb 2009)
New Revision: 12645
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ColumnsBean.java
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/columnsTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ColumnsTest.java
Log:
RF-6097
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ColumnsBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ColumnsBean.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ColumnsBean.java 2009-02-12
17:48:48 UTC (rev 12645)
@@ -0,0 +1,125 @@
+package org.ajax4jsf.bean;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.event.ActionEvent;
+
+public class ColumnsBean {
+
+ static final String ROW_PREFIX = "Row";
+
+ static final String CELL_PREFIX = "Cell";
+
+ String status;
+
+ public class Column {
+ String header;
+
+ public Column(String header) {
+ super();
+ this.header = header;
+ }
+
+ public void listener(ActionEvent event) {
+ setStatus(getStatus() + "ActionListener" + columns.indexOf(this));
+ }
+
+ public String getHeader() {
+ return header;
+ }
+ public void setHeader(String header) {
+ this.header = header;
+ }
+ }
+
+ public class Row {
+ String input;
+
+ public String getInput() {
+ return input;
+ }
+
+ public void setInput(String input) {
+ this.input = input;
+ }
+
+ }
+
+ private int rows = 2;
+
+ private int cols = 3;
+
+ private List<Row []> model;
+
+ private List<Column> columns;
+
+ public ColumnsBean() {
+ init();
+ }
+
+ private void init () {
+ columns = new ArrayList<Column>();
+ for (int i = 0; i < cols; i++) {
+ columns.add(new Column("Header" + i));
+ }
+
+ model = new ArrayList<Row[]>();
+ for (int i = 0; i < rows; i++) {
+ Row[] rows = new Row [cols];
+ for (int j=0; j<cols; j++) {
+ rows[j] = new Row();
+ }
+ model.add(rows);
+ }
+ }
+
+ public void reset() {
+ init();
+ status = null;
+ }
+
+ public List<Row[]> getModel() {
+ return model;
+ }
+
+ public void setModel(List<Row[]> model) {
+ this.model = model;
+ }
+
+ public List<Column> getColumns() {
+ return columns;
+ }
+
+ public void setColumns(List<Column> columns) {
+ this.columns = columns;
+ }
+
+ public boolean getCheckInputs() {
+ Iterator<Row[]> it = model.iterator();
+ int row = 0;
+ boolean f = true;
+ while (it.hasNext()) {
+ Row[] r = it.next();
+ for (int i = 0; i < cols; i++) {
+ String e = ROW_PREFIX + row + CELL_PREFIX + i;
+ if (!e.equals(r[i].input)) {
+ f = false;
+ }
+ }
+ row++;
+ }
+ return f;
+ }
+
+ public String getStatus() {
+ return (status != null) ? status : "";
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+
+}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2009-02-12
17:23:26 UTC (rev 12644)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2009-02-12
17:48:48 UTC (rev 12645)
@@ -332,6 +332,11 @@
<managed-bean-name>controlBean</managed-bean-name>
<managed-bean-class>org.ajax4jsf.bean.ComponentControlBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>columnsBean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.bean.ColumnsBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/pages/ajaxInclude/step1.xhtml</from-view-id>
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/columnsTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ColumnsTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ColumnsTest.java 2009-02-12
17:23:26 UTC (rev 12644)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ColumnsTest.java 2009-02-12
17:48:48 UTC (rev 12645)
@@ -22,9 +22,12 @@
import org.ajax4jsf.template.Template;
import org.richfaces.SeleniumTestBase;
+import org.testng.Assert;
import org.testng.annotations.Test;
public class ColumnsTest extends SeleniumTestBase {
+
+ static final String RESET_METHOD = "#{columnsBean.reset}";
private static final String DATA_TABLE = "table";
@@ -41,8 +44,78 @@
private static final String BEGIN_ROW = "begin";
private static final String END_ROW = "end";
+
+
+ @Test
+ public void testOutputAndNestedInputsAndCommands(Template template) {
+ renderPage(template, RESET_METHOD);
+
+ int rows = 2;
+ int cols = 3;
+
+ String parentId = getParentId() + "_form:";
+ String tableId = parentId + "table";
+ String submitId = parentId + "submit";
+ assertRowsCount(rows, tableId);
+ assertColumnsCount(cols, tableId, "Columns count is invalid.");
+
+ // Check headers
+ for (int i=0;i<cols;i++) {
+ String header =
selenium.getText("//*[@id='"+tableId+"']/thead/tr[1]/th["+(i+1)+"]");
+ if (!("Header" + i).equals(header)) {
+ Assert.fail("Header for columns ["+i+"] was not output to
client");
+ }
- @Test
+ }
+
+ for (int i=0; i<rows; i++) {
+ for (int j=0;j<cols;j++) {
+ String inputPath =
"//*[@id='"+tableId+"']/tbody/tr["+(i+1)+"]/td["+(j+1)+"]/input[@type='text']";
+ String submitPath =
"//*[@id='"+tableId+"']/tbody/tr["+(i+1)+"]/td["+(j+1)+"]/input[@type='submit']";
+ if (selenium.getXpathCount(inputPath).intValue() != 1) {
+ Assert.fail("Input for row["+i+"] cell["+j+"] was not
output to client");
+ }
+ if (selenium.getXpathCount(submitPath).intValue() != 1) {
+ Assert.fail("Submit for row["+i+"] cell["+j+"] was not
output to client");
+ }
+ String submitValue = selenium.getValue(submitPath);
+ String expectedValue = ("Submit"+j);
+ if (!expectedValue.equals(submitValue)) {
+ Assert.fail("Submit value for row["+i+"] cell["+j+"] is
incorrect. Should be: " +expectedValue + "But was: " + submitValue);
+ }
+ }
+ }
+
+ setInputs(tableId, rows, cols);
+ clickCommandAndWait(submitId);
+
+ String checkInputs = getTextById(parentId + "checkInputs");
+ if (!Boolean.TRUE.toString().equals(checkInputs)) {
+ Assert.fail("Set inputs values were not applied to data modal as expected.
Nested input dont work");
+ }
+
+ // Click submit button in the first row
+ String submitPath =
"//*[@id='"+tableId+"']/tbody/tr[1]/td[1]/input[@type='submit']";
+ selenium.click(submitPath);
+ selenium.waitForPageToLoad("10000");
+
+ String status = getTextById(parentId + "status");
+ if (!"ActionListener0".equals(status)) {
+ Assert.fail("Nested command dont work.");
+ }
+
+ // Click submit button in the first row
+ submitPath =
"//*[@id='"+tableId+"']/tbody/tr[2]/td[2]/input[@type='submit']";
+ selenium.click(submitPath);
+ selenium.waitForPageToLoad("10000");
+
+ status = getTextById(parentId + "status");
+ if (!"ActionListener0ActionListener1".equals(status)) {
+ Assert.fail("Nested command dont work.");
+ }
+ }
+
+ // @Test
public void testColumnsComponentLayout(Template template) {
renderPage(template);
writeStatus("Testing columns component layout");
@@ -70,7 +143,7 @@
}
- @Test
+ // @Test
public void testColumnsComponentCoreAttributes(Template template) {
renderPage(template);
@@ -100,7 +173,18 @@
reset();
}
+
+ private void setInputs(String tableId, int rows, int cols) {
+ for (int i=0;i<rows; i++) {
+ for (int j=0; j<cols; j++) {
+ String v = "Row"+i+"Cell"+j;
+ String path =
"//*[@id='"+tableId+"']/tbody/tr["+(i+1)+"]/td["+(j+1)+"]/input[@type='text']";
+ selenium.type(path, v);
+ }
+ }
+ }
+
private void adjustTableParams(int rows, int columns, int begin, int end) {
String ctrlForm = getParentId() + CTRL_FORM;
type(ctrlForm + ":rows", String.valueOf(rows));
@@ -113,7 +197,8 @@
private void reset() {
clickAjaxCommandAndWait(getParentId() + CTRL_FORM + ":reset");
}
-
+
+
@Override
public String getTestUrl() {
return "pages/columns/columnsTest.xhtml";
Show replies by date