Author: konstantin.mishin
Date: 2009-02-20 12:55:57 -0500 (Fri, 20 Feb 2009)
New Revision: 12707
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataList/dataOrderedList.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataList/dataOrderedListAutoTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AbstractDataListTest.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataOrderedListTest.java
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataListTest.java
Log:
RF-5694
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataList/dataOrderedList.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataList/dataOrderedList.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataList/dataOrderedList.xhtml 2009-02-20
17:55:57 UTC (rev 12707)
@@ -0,0 +1,50 @@
+<!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="attrForm">
+ <h:outputText value="rows" />
+ <h:inputText id="rows" value="#{dataList.rows}">
+ <a4j:support event="onchange" reRender="panelGroup"/>
+ </h:inputText>
+ </h:form>
+ <h:form id="mainForm">
+ <h:panelGroup id="panelGroup">
+ <rich:dataOrderedList id="dataList" value="#{dataList.model}"
var="rows"
+ rows="#{dataList.rows}" ajaxKeys="#{dataList.ajaxKeys}"
+ stateVar="stateVar" rowKeyVar="rowKeyVar"
+ componentState="#{componentState}"
+ rowKeyConverter="#{dataList.rowKeyConverter}">
+ <h:outputText id="rowKeyVar" value="#{rowKeyVar}
"></h:outputText>
+ <h:outputText id="first" value="#{stateVar.range.firstRow}
"></h:outputText>
+ <h:outputText id="rows" value="#{stateVar.range.rows}
"></h:outputText>
+ <h:outputText id="firstState"
value="#{componentState.range.firstRow} "></h:outputText>
+ <h:outputText id="rowsState" value="#{componentState.range.rows}
"></h:outputText>
+ <h:outputText value="#{rows.cell1}"></h:outputText>
+ <h:inputText id="inputText" value="#{rows.cell2}"
validator="#{dataList.validate}"></h:inputText>
+ <h:outputText value="#{rows.cell3}"></h:outputText>
+ <h:commandButton id="submit" value="submit"
actionListener="#{dataList.submit}"></h:commandButton>
+ <a4j:commandButton id="ajaxSubmit" value="ajaxSubmit"
actionListener="#{dataList.submit}"></a4j:commandButton>
+ <a4j:commandButton id="ajaxSingleSubmit"
value="ajaxSingleSubmit" actionListener="#{dataList.submit}"
ajaxSingle="true"></a4j:commandButton>
+ </rich:dataOrderedList>
+ <a4j:commandButton id="reRender" value="reRender"
reRender="inputText"
actionListener="#{dataList.reRender}"></a4j:commandButton>
+ </h:panelGroup>
+ </h:form>
+ <a4j:outputPanel ajaxRendered="true">
+ <h:outputText id="outputText"
value="#{dataList.trace}"></h:outputText>
+ <h:dataTable id="dataTable" value="#{dataList.model}"
var="row" rows="#{dataList.rows}">
+ <h:column>
+ <h:outputText value="#{row.cell2}"></h:outputText>
+ </h:column>
+ </h:dataTable>
+ </a4j:outputPanel>
+ <rich:messages></rich:messages>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataList/dataOrderedListAutoTest.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataList/dataOrderedListAutoTest.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataList/dataOrderedListAutoTest.xhtml 2009-02-20
17:55:57 UTC (rev 12707)
@@ -0,0 +1,31 @@
+<!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:dataOrderedList id="componentId"
value="#{dataGrid.model}" var="row"
+ rendered="#{autoTestBean.rendered}"
+ style="width: 100%; color: yellow"
+ styleClass="noname"
+ onclick="EventQueue.fire('onclick')"
+ onmousedown="EventQueue.fire('onmousedown')"
+ onmousemove="EventQueue.fire('onmousemove')"
+ onmouseup="EventQueue.fire('onmouseup')"
+ onmouseout="EventQueue.fire('onmouseout')"
+ onmouseover="EventQueue.fire('onmouseover')"
+ onkeydown="EventQueue.fire('onkeydown')"
+ onkeypress="EventQueue.fire('onkeypress')"
+ onkeyup="EventQueue.fire('onkeyup')"
+ >
+ <h:panelGroup>
+ <h:inputText id="inputText"
value="#{row.cell2}"></h:inputText>
+ </h:panelGroup>
+ </rich:dataOrderedList>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AbstractDataListTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AbstractDataListTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AbstractDataListTest.java 2009-02-20
17:55:57 UTC (rev 12707)
@@ -0,0 +1,154 @@
+package org.richfaces.testng;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.ajax4jsf.template.Template;
+import org.richfaces.AutoTester;
+import org.richfaces.SeleniumTestBase;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public abstract class AbstractDataListTest extends SeleniumTestBase {
+
+ private String rows;
+
+ private String dataList;
+
+ private String reRender;
+
+ private String outputText;
+
+ private String dataTable;
+
+ private void init(Template template) {
+ renderPage(null, template, "#{dataList.init}");
+ String attrForm = getParentId() + "attrForm";
+ rows = attrForm + ":rows";
+ String mainForm = getParentId() + "mainForm";
+ dataList = mainForm + ":dataList";
+ reRender = mainForm + ":reRender";
+ outputText = getParentId() + "outputText";
+ dataTable = getParentId() + "dataTable";
+ }
+
+ /**
+ * items from collection defined as value attribute are output to the client;
+ * number of items is limited using elements attribute and not
+ */
+ @Test
+ public void testStructure(Template template) {
+ init(template);
+ chekStructure();
+ selenium.type(rows, "3");
+ waitForAjaxCompletion();
+ Assert.assertEquals(selenium.getXpathCount("id('"+ dataList +
"')/li"), 3);
+ chekStructure();
+ }
+
+ /**
+ * nested input and command components work correctly
+ * for the cases of validation failure or not
+ */
+ @Test
+ public void testComponentsProcessingWithValidation(Template template) {
+ init(template);
+ String liLocator = "xpath=id('"+ dataList + "')/li[";
+ String inputLocator = liLocator + "6]/input[";
+ Assert.assertEquals(selenium.getText(outputText), "");
+ selenium.click(inputLocator + "2]");
+ waitForPageToLoad();
+ Assert.assertTrue(selenium.getText(outputText).endsWith("5:submit"));
+ selenium.click(inputLocator + "3]");
+ waitForAjaxCompletion();
+ Assert.assertTrue(selenium.getText(outputText).endsWith("5:ajaxSubmit"));
+ selenium.click(inputLocator + "4]");
+ waitForAjaxCompletion();
+ Assert.assertTrue(selenium.getText(outputText).endsWith("5:ajaxSingleSubmit"));
+ selenium.type(inputLocator + "1]", "abc5");
+ selenium.click(inputLocator + "3]");
+ waitForAjaxCompletion();
+ chekStructure();
+ selenium.type(inputLocator + "1]", "fail");
+ selenium.type(liLocator + "3]/input[1]", "fail");
+ selenium.click(inputLocator + "3]");
+ waitForAjaxCompletion();
+ chekStructure(3, 6);
+ }
+
+ /**
+ * rows defined by ajaxKeys attribute are re-rendered correctly
+ */
+ @Test
+ public void testAjaxKeys(Template template) {
+ init(template);
+ chekStructure();
+ clickAjaxCommandAndWait(reRender);
+ chekStructure(3, 7);
+ }
+
+ /**
+ * components using rowKeyVar and stateVar variables are correctly output to the
client
+ */
+ @Test
+ public void testVars(Template template) {
+ init(template);
+ Assert.assertEquals(selenium.getText(dataList + ":c_2:first"), "0",
"Attribute 'stateVar' works wrong.");
+ Assert.assertEquals(selenium.getText(dataList + ":c_2:rows"), "0",
"Attribute 'stateVar' works wrong.");
+ int rows = selenium.getXpathCount("id('"+ dataList +
"')/tbody/tr").intValue();
+ for (int i = 0; i < rows; i++) {
+ Assert.assertEquals(selenium.getText(dataList + ":c_" + i +
":rowKeyVar"), Integer.toString(i));
+ }
+ }
+
+ /**
+ * componentState attribute stores nested components state across requests
+ */
+ @Test
+ public void testComponentState(Template template) {
+ init(template);
+ Assert.assertEquals(selenium.getText(dataList + ":c_2:firstState"),
"0", "Attribute 'componentState' works wrong.");
+ Assert.assertEquals(selenium.getText(dataList + ":c_2:rowsState"),
"0", "Attribute 'componentState' works wrong.");
+ }
+
+ /**
+ * component with rendered = false is not present on the page,
+ * style and classes, standard HTML attributes are output to client
+ */
+ @Test
+ public void testStandardAttributes(Template template) {
+ AutoTester autoTester = getAutoTester(this);
+ autoTester.renderPage(template, "#{dataGrid.init}");
+ autoTester.testRendered();
+ Map<String, String> styleAttributes = new HashMap<String, String>();
+ styleAttributes.put("width", "100%");
+ styleAttributes.put("color", "yellow");
+ autoTester.testStyleAndClasses(new String[]{"noname"}, styleAttributes);
+ autoTester.testHTMLEvents();
+ }
+
+ /**
+ * rowKeyConverter outputs correct client ids
+ */
+ @Test
+ public void testRowKeyConverter(Template template) {
+ init(template);
+ Assert.assertTrue(selenium.getAttribute("xpath=id('"+ dataList +
"')/li[3]@id").endsWith(":c_2"), "Attribute
'rowKeyConverter' works wrong.");
+ }
+
+ private void chekStructure(int ... notEqualRows) {
+ String dataTableRowLocator = "id('"+ dataTable + "')/li";
+ int count = selenium.getXpathCount(dataTableRowLocator).intValue();
+ for (int i = 1; i <= count; i++) {
+ if (Arrays.binarySearch(notEqualRows, i) < 0) {
+ Assert.assertEquals(selenium.getValue("xpath=id('"+ dataList +
"')/li[" + i + "]/input"),
+ selenium.getText("xpath=" + dataTableRowLocator + "[" + i +
"]"));
+ } else {
+ Assert.assertFalse(selenium.
+ getValue("xpath=id('"+ dataList + "')/li[" + i +
"]/input").
+ equals(selenium.getText("xpath=" + dataTableRowLocator + "[" +
i + "]")));
+ }
+ }
+ }
+}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataListTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataListTest.java 2009-02-20
16:23:04 UTC (rev 12706)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataListTest.java 2009-02-20
17:55:57 UTC (rev 12707)
@@ -1,157 +1,7 @@
package org.richfaces.testng;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import org.ajax4jsf.template.Template;
-import org.richfaces.AutoTester;
-import org.richfaces.SeleniumTestBase;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-public class DataListTest extends SeleniumTestBase {
-
- private String rows;
-
- private String dataList;
-
- private String reRender;
-
- private String outputText;
-
- private String dataTable;
-
- private void init(Template template) {
- renderPage(null, template, "#{dataList.init}");
- String attrForm = getParentId() + "attrForm";
- rows = attrForm + ":rows";
- String mainForm = getParentId() + "mainForm";
- dataList = mainForm + ":dataList";
- reRender = mainForm + ":reRender";
- outputText = getParentId() + "outputText";
- dataTable = getParentId() + "dataTable";
- }
-
- /**
- * items from collection defined as value attribute are output to the client;
- * number of items is limited using elements attribute and not
- */
- @Test
- public void testStructure(Template template) {
- init(template);
- chekStructure();
- selenium.type(rows, "3");
- waitForAjaxCompletion();
- Assert.assertEquals(selenium.getXpathCount("id('"+ dataList +
"')/li"), 3);
- chekStructure();
- }
-
- /**
- * nested input and command components work correctly
- * for the cases of validation failure or not
- */
- @Test
- public void testComponentsProcessingWithValidation(Template template) {
- init(template);
- String liLocator = "xpath=id('"+ dataList + "')/li[";
- String inputLocator = liLocator + "6]/input[";
- Assert.assertEquals(selenium.getText(outputText), "");
- selenium.click(inputLocator + "2]");
- waitForPageToLoad();
- Assert.assertTrue(selenium.getText(outputText).endsWith("5:submit"));
- selenium.click(inputLocator + "3]");
- waitForAjaxCompletion();
- Assert.assertTrue(selenium.getText(outputText).endsWith("5:ajaxSubmit"));
- selenium.click(inputLocator + "4]");
- waitForAjaxCompletion();
- Assert.assertTrue(selenium.getText(outputText).endsWith("5:ajaxSingleSubmit"));
- selenium.type(inputLocator + "1]", "abc5");
- selenium.click(inputLocator + "3]");
- waitForAjaxCompletion();
- chekStructure();
- selenium.type(inputLocator + "1]", "fail");
- selenium.type(liLocator + "3]/input[1]", "fail");
- selenium.click(inputLocator + "3]");
- waitForAjaxCompletion();
- chekStructure(3, 6);
- }
-
- /**
- * rows defined by ajaxKeys attribute are re-rendered correctly
- */
- @Test
- public void testAjaxKeys(Template template) {
- init(template);
- chekStructure();
- clickAjaxCommandAndWait(reRender);
- chekStructure(3, 7);
- }
-
- /**
- * components using rowKeyVar and stateVar variables are correctly output to the
client
- */
- @Test
- public void testVars(Template template) {
- init(template);
- Assert.assertEquals(selenium.getText(dataList + ":c_2:first"), "0",
"Attribute 'stateVar' works wrong.");
- Assert.assertEquals(selenium.getText(dataList + ":c_2:rows"), "0",
"Attribute 'stateVar' works wrong.");
- int rows = selenium.getXpathCount("id('"+ dataList +
"')/tbody/tr").intValue();
- for (int i = 0; i < rows; i++) {
- Assert.assertEquals(selenium.getText(dataList + ":c_" + i +
":rowKeyVar"), Integer.toString(i));
- }
- }
-
- /**
- * componentState attribute stores nested components state across requests
- */
- @Test
- public void testComponentState(Template template) {
- init(template);
- Assert.assertEquals(selenium.getText(dataList + ":c_2:firstState"),
"0", "Attribute 'componentState' works wrong.");
- Assert.assertEquals(selenium.getText(dataList + ":c_2:rowsState"),
"0", "Attribute 'componentState' works wrong.");
- }
-
- /**
- * component with rendered = false is not present on the page,
- * style and classes, standard HTML attributes are output to client
- */
- @Test
- public void testStandardAttributes(Template template) {
- AutoTester autoTester = getAutoTester(this);
- autoTester.renderPage(template, "#{dataGrid.init}");
- autoTester.testRendered();
- Map<String, String> styleAttributes = new HashMap<String, String>();
- styleAttributes.put("width", "100%");
- styleAttributes.put("color", "yellow");
- autoTester.testStyleAndClasses(new String[]{"noname"}, styleAttributes);
- autoTester.testHTMLEvents();
- }
-
- /**
- * rowKeyConverter outputs correct client ids
- */
- @Test
- public void testRowKeyConverter(Template template) {
- init(template);
- Assert.assertTrue(selenium.getAttribute("xpath=id('"+ dataList +
"')/li[3]@id").endsWith(":c_2"), "Attribute
'rowKeyConverter' works wrong.");
- }
-
- private void chekStructure(int ... notEqualRows) {
- String dataTableRowLocator = "id('"+ dataTable + "')/li";
- int count = selenium.getXpathCount(dataTableRowLocator).intValue();
- for (int i = 1; i <= count; i++) {
- if (Arrays.binarySearch(notEqualRows, i) < 0) {
- Assert.assertEquals(selenium.getValue("xpath=id('"+ dataList +
"')/li[" + i + "]/input"),
- selenium.getText("xpath=" + dataTableRowLocator + "[" + i +
"]"));
- } else {
- Assert.assertFalse(selenium.
- getValue("xpath=id('"+ dataList + "')/li[" + i +
"]/input").
- equals(selenium.getText("xpath=" + dataTableRowLocator + "[" +
i + "]")));
- }
- }
- }
-
+public class DataListTest extends AbstractDataListTest {
@Override
public String getTestUrl() {
return "pages/dataList/dataList.xhtml";
Added:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataOrderedListTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataOrderedListTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataOrderedListTest.java 2009-02-20
17:55:57 UTC (rev 12707)
@@ -0,0 +1,14 @@
+package org.richfaces.testng;
+
+
+public class DataOrderedListTest extends AbstractDataListTest {
+ @Override
+ public String getTestUrl() {
+ return "pages/dataList/dataOrderedList.xhtml";
+ }
+
+ @Override
+ public String getAutoTestUrl() {
+ return "pages/dataList/dataOrderedListAutoTest.xhtml";
+ }
+}