Author: andrei_exadel
Date: 2009-02-19 12:08:56 -0500 (Thu, 19 Feb 2009)
New Revision: 12693
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/columnsAutoTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/testColumnsFiltering.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/testValueAttribute.xhtml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ColumnsBean.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ColumnsTest.java
Log:
Columns tests
Modified:
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 2009-02-19
15:31:37 UTC (rev 12692)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ColumnsBean.java 2009-02-19
17:08:56 UTC (rev 12693)
@@ -20,6 +20,7 @@
public class Column {
String header;
Ordering ordering;
+ Object filterValue;
public Column(String header) {
super();
@@ -29,6 +30,12 @@
public void listener(ActionEvent event) {
setStatus(getStatus() + "ActionListener" + columns.indexOf(this));
}
+
+ public boolean filterMethod(Object o) {
+ Row [] rows = (Row[])o;
+ int i = columns.indexOf(this);
+ return rows[i].value == i;
+ }
public String getHeader() {
return header;
@@ -44,6 +51,15 @@
public void setOrdering(Ordering ordering) {
this.ordering = ordering;
}
+
+ public Object getFilterValue() {
+ return filterValue;
+ }
+
+ public void setFilterValue(Object filterValue) {
+ this.filterValue = filterValue;
+ }
+
}
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/columnsAutoTest.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/columnsAutoTest.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/columnsAutoTest.xhtml 2009-02-19
17:08:56 UTC (rev 12693)
@@ -0,0 +1,34 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition template="#{templateBean.autoTestTemplate}">
+ <ui:define name="component">
+ <rich:dataTable id="table" value="#{columnsBean.model}"
var="row" width="750">
+ <rich:columns value="#{columnsBean.columns}"
var="column"
+ onclick="EventQueue.fire('onclick')"
+ onmouseover="EventQueue.fire('onmouseover')"
+ onmouseout="EventQueue.fire('onmouseout')"
+ onmousedown="EventQueue.fire('onmousedown')"
+ onmousemove="EventQueue.fire('onmousemove')"
+ onmouseup="EventQueue.fire('onmouseup')"
+ onkeypress="EventQueue.fire('onkeypress')"
+ onkeydown="EventQueue.fire('onkeydown')"
+ onkeyup="EventQueue.fire('onkeyup')"
+ title="title"
+ style="color: green"
+ styleClass="columnClass"
+ index="index">
+ <f:facet name="header">
+ <h:outputText value="#{column.header}"></h:outputText>
+ </f:facet>
+ <h:outputText value="#{row[index].value}"></h:outputText>
+ </rich:columns>
+ </rich:dataTable>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/testColumnsFiltering.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/testColumnsFiltering.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/testColumnsFiltering.xhtml 2009-02-19
17:08:56 UTC (rev 12693)
@@ -0,0 +1,51 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition template="#{templateBean.template}">
+ <ui:define name="component">
+ <h:form id="_form">
+ <br/><br/>
+ <rich:dataTable id="table" value="#{columnsBean.model}"
var="row">
+ <rich:columns id="c#{index}"
value="#{columnsBean.columns}" var="column"
+ index="index" filterBy="#{row[index].value}"
filterValue="#{column.filterValue}">
+ <f:facet name="header" filterEvent="onkeyup">
+ <h:outputText value="#{column.filterValue}"></h:outputText>
+ </f:facet>
+ <h:outputText value="#{row[index].value}" />
+ </rich:columns>
+ </rich:dataTable><br/>
+
+ <rich:dataTable id="table2" value="#{columnsBean.model}"
var="row">
+ <f:facet name="header">
+ <rich:column colspan="2">
+ <h:outputText value="Test Filter
Method"></h:outputText>
+ </rich:column>
+ </f:facet>
+ <rich:columns id="c#{index}"
value="#{columnsBean.columns}" var="column"
+ index="index"
filterMethod="#{column.filterMethod}">
+ <h:outputText value="#{row[index].value}" />
+ </rich:columns>
+ </rich:dataTable><br/>
+
+ <rich:dataTable id="table3" value="#{columnsBean.model}"
var="row">
+ <f:facet name="header">
+ <rich:column colspan="2">
+ <h:outputText value="Test Filter
Expression"></h:outputText>
+ </rich:column>
+ </f:facet>
+ <rich:columns id="c#{index}"
value="#{columnsBean.columns}" var="column"
+ index="index" filterExpression="#{(row[index].value-1) ==
index}">
+ <h:outputText value="#{row[index].value}" />
+ </rich:columns>
+ </rich:dataTable><br/>
+
+ <h:commandButton id="submit"
value="Submit"></h:commandButton>
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/testValueAttribute.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/testValueAttribute.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/columns/testValueAttribute.xhtml 2009-02-19
17:08:56 UTC (rev 12693)
@@ -0,0 +1,25 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition template="#{templateBean.template}">
+ <ui:define name="component">
+ <h:form id="_form">
+ <br/><br/>
+ <rich:dataTable id="table" value="#{columnsBean.model}"
var="row">
+ <rich:columns id="c#{index}"
value="Header0,Header1,Header2" var="column"
+ index="index">
+ <f:facet name="header">
+ <h:outputText value="#{column}"></h:outputText>
+ </f:facet>
+ <h:outputText value="#{row[index].value}" />
+ </rich:columns>
+ </rich:dataTable><br/>
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
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-19
15:31:37 UTC (rev 12692)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ColumnsTest.java 2009-02-19
17:08:56 UTC (rev 12693)
@@ -23,6 +23,8 @@
import java.util.Arrays;
import org.ajax4jsf.template.Template;
+import org.richfaces.AutoTester;
+import org.richfaces.SeleniumEvent;
import org.richfaces.SeleniumTestBase;
import org.richfaces.model.Ordering;
import org.testng.Assert;
@@ -33,6 +35,46 @@
static final String RESET_METHOD = "#{columnsBean.reset}";
static final String SORTING_TEST_URL =
"pages/columns/testColumnsSorting.xhtml";
+ static final String FILTERING_TEST_URL =
"pages/columns/testColumnsFiltering.xhtml";
+ static final String VALUE_ATTRIBUTE_TEST_URL =
"pages/columns/testValueAttribute.xhtml";
+
+ enum FEATURE {
+ SORTING,
+ FILTERING
+ }
+
+ static final String [] COLUMNS_CLASSSES = new String [] {"dr-table-cell",
"rich-table-cell", "columnClass"};
+
+ @Test
+ public void testStylesClassesAndStandardHTMLAttributes(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, RESET_METHOD);
+
+ String tableId = tester.getClientId("table");
+ String columnPath =
"//table[@id='"+tableId+"']/tbody/tr/td[1]";
+
+ assertEvents(columnPath, SeleniumEvent.STANDARD_HTML_EVENTS);
+ assertAttributeContains(columnPath, "class", "columnClass",
"StyleClass attribute was not output to client");
+ assertClassNames(columnPath, COLUMNS_CLASSSES, "Columns have unexpected css
classes", false);
+ assertStyleAttributeContains(columnPath, "color: green", "Style
attribute was not output to client");
+ assertAttributeContains(columnPath, "title", "title", "Title
attribute was not output to client");
+ }
+
+ @Test
+ public void testValueAttribute(Template template) {
+ renderPage(VALUE_ATTRIBUTE_TEST_URL, template, RESET_METHOD);
+
+ final int columnsCount = 3;
+
+ String tableId = getParentId() + "_form:table";
+ assertColumnsCount(columnsCount, tableId, "Strign value attribute was not applied
properly. Table should have 3 columns");
+
+ for (int i = 0; i < columnsCount; i++) {
+ AssertTextEquals("//table[@id='"+tableId+"']/thead/tr/th["+(i+1)+"]",
"Header" + i, "Var was not initialized properly");
+ checkColumnsData(tableId, i, new String[] {String.valueOf(i), String.valueOf(i+1)},
null, "");
+ }
+
+ }
@Test
@@ -49,8 +91,56 @@
}
-
-
+ @Test
+ public void testFilteringFeature(Template template) {
+ renderPage(FILTERING_TEST_URL, template, RESET_METHOD);
+
+ // Check filterBy attribute ----------->>>>>>
+
+ String tableId = getParentId() + "_form:table";
+ String filterInputPath =
"//table[@id='"+tableId+"']/thead/tr/th[1]/*/input";
+ final int columnsCount = 3;
+
+ // Filter by the first column with '0' filter value
+ selenium.type(filterInputPath, "0");
+ waitForAjaxCompletion();
+
+ for (int i = 0; i < columnsCount; i++) {
+ checkColumnsData(tableId, i, new String [] {String.valueOf(i)}, FEATURE.FILTERING,
"Filterby does snot work.");
+ }
+ AssertTextEquals("//table[@id='"+tableId+"']/thead/tr/th[1]",
"0", "Filter value attribute does not work. Binding value was not
changed.");
+
+ // Filter by the third column with '3' filter value
+ selenium.type(filterInputPath, "");
+ waitForAjaxCompletion();
+
+ filterInputPath =
"//table[@id='"+tableId+"']/thead/tr/th[3]/*/input";
+ selenium.type(filterInputPath, "3");
+ waitForAjaxCompletion();
+
+ for (int i = 0; i < columnsCount; i++) {
+ checkColumnsData(tableId, i, new String [] {String.valueOf(i + 1)},
FEATURE.FILTERING, "Filterby does snot work.");
+ }
+ AssertTextEquals("//table[@id='"+tableId+"']/thead/tr/th[3]",
"3", "Filter value attribute does not work. Binding value was not
changed.");
+
+ //<<<----------------
+
+ // Test filter method attribute
+
+ tableId = getParentId() + "_form:table2";
+ for (int i = 0; i < columnsCount; i++) {
+ checkColumnsData(tableId, i, new String [] {String.valueOf(i)}, FEATURE.FILTERING,
"FilterMethod does not work.");
+ }
+
+ // Test filter expression attribute
+ tableId = getParentId() + "_form:table3";
+ for (int i = 0; i < columnsCount; i++) {
+ checkColumnsData(tableId, i, new String [] {String.valueOf(i + 1)},
FEATURE.FILTERING, "FilterExpression does not work.");
+ }
+
+ }
+
+
@Test
public void testOutputAndNestedInputsAndCommands(Template template) {
renderPage(template, RESET_METHOD);
@@ -131,7 +221,7 @@
}
}
- private void checkSorting (String tableId, int col, String [] expected) {
+ private void checkColumnsData (String tableId, int col, String [] expected, FEATURE
feature, String message) {
int l = expected.length;
String [] values = new String [l];
for (int i = 0; i < l; i++) {
@@ -140,7 +230,7 @@
for (int i = 0; i < l; i++) {
if (!expected[i].equals(values[i])) {
- Assert.fail("Column number [" + col + "] was sorted unexpected.
Column's value should be: " + Arrays.toString(expected) + ". But was: "
+ Arrays.toString(values));
+ Assert.fail(message + "Column number [" + col + "] was
"+(feature != null ? ((feature == FEATURE.SORTING) ? "sorted" :
"filtered") : "")+" unexpectedly. Column's value should be:
" + Arrays.toString(expected) + ". But was: " + Arrays.toString(values));
}
}
}
@@ -158,19 +248,20 @@
}
private void testOrdering(String tableId, int cols) {
+ final String message = "SortBy does not work.";
for (int i=0; i<cols; i++) {
clickSort(tableId, i);
- checkSorting(tableId, 0, new String [] {"0", "1"});
- checkSorting(tableId, 1, new String [] {"1", "2"});
- checkSorting(tableId, 2, new String [] {"2", "3"});
+ checkColumnsData(tableId, 0, new String [] {"0", "1"},
FEATURE.SORTING, message);
+ checkColumnsData(tableId, 1, new String [] {"1", "2"},
FEATURE.SORTING, message);
+ checkColumnsData(tableId, 2, new String [] {"2", "3"},
FEATURE.SORTING, message);
checkSortOrderAttribute(tableId, i, Ordering.ASCENDING);
clickSort(tableId, i);
- checkSorting(tableId, 0, new String [] {"1", "0"});
- checkSorting(tableId, 1, new String [] {"2", "1"});
- checkSorting(tableId, 2, new String [] {"3", "2"});
+ checkColumnsData(tableId, 0, new String [] {"1", "0"},
FEATURE.SORTING, message);
+ checkColumnsData(tableId, 1, new String [] {"2", "1"},
FEATURE.SORTING, message);
+ checkColumnsData(tableId, 2, new String [] {"3", "2"},
FEATURE.SORTING, message);
checkSortOrderAttribute(tableId, i, Ordering.DESCENDING);
}
@@ -181,5 +272,10 @@
public String getTestUrl() {
return "pages/columns/columnsTest.xhtml";
}
+
+ @Override
+ public String getAutoTestUrl() {
+ return "pages/columns/columnsAutoTest.xhtml";
+ }
}