Author: konstantin.mishin
Date: 2009-01-14 08:34:15 -0500 (Wed, 14 Jan 2009)
New Revision: 12272
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeNodesAdaptorTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/treeNodesAdaptor/treeNodesAdaptor.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TreeNodesAdaptorTest.java
Log:
RF-5582
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeNodesAdaptorTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeNodesAdaptorTestBean.java 2009-01-14
12:14:51 UTC (rev 12271)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeNodesAdaptorTestBean.java 2009-01-14
13:34:15 UTC (rev 12272)
@@ -1,23 +1,87 @@
package org.ajax4jsf.bean.tree;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
public class TreeNodesAdaptorTestBean {
+
+ public static class Node {
+
+
+ private String id;
- private String[] nodes = {"1", "2", "3"};
- private String[] roots = {"A", "B", "C"};
+ private List<Node> children;
- public void setNodes(String[] nodes) {
- this.nodes = nodes;
+ public Node() {
+ children = new ArrayList<Node>(3);
+ }
+
+ public Node(String id) {
+ this();
+ this.id = id;
+ }
+
+ public void addChild(Node child) {
+ children.add(child);
+ }
+
+ public void setChildren(List<Node> children) {
+ this.children = children;
+ }
+
+ public List<Node> getChildren() {
+ return children;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
}
- public String[] getNodes() {
- return nodes;
+ private List<Node> nodes;
+ private String trace;
+
+ public TreeNodesAdaptorTestBean() {
+ init();
}
+
+ public void init() {
+ trace = "";
+ nodes = new ArrayList<Node>(3);
+ for (int i = 1; i <= 3; i++) {
+ Node node = new Node(Integer.toString(i));
+ nodes.add(node);
+ for (int j = 1; j <= 3; j++) {
+ node.addChild(new Node(Integer.toString(i * 10 + j)));
+ }
+ }
+ }
- public void setRoots(String[] roots) {
- this.roots = roots;
+ public void submit(ActionEvent event) {
+ trace = event.getComponent().getClientId(FacesContext.getCurrentInstance());
}
+
+ public void setTrace(String trace) {
+ this.trace = trace;
+ }
- public String[] getRoots() {
- return roots;
+ public String getTrace() {
+ return trace;
}
+
+ public void setNodes(List<Node> nodes) {
+ this.nodes = nodes;
+ }
+
+ public List<Node> getNodes() {
+ return nodes;
+ }
}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/treeNodesAdaptor/treeNodesAdaptor.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/treeNodesAdaptor/treeNodesAdaptor.xhtml 2009-01-14
12:14:51 UTC (rev 12271)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/treeNodesAdaptor/treeNodesAdaptor.xhtml 2009-01-14
13:34:15 UTC (rev 12272)
@@ -10,18 +10,27 @@
<ui:define name="component">
<h:form id="mainForm">
<rich:tree id="tree">
- <rich:treeNodesAdaptor nodes="#{treeNodesAdaptor.roots}"
var="root">
+ <rich:treeNodesAdaptor nodes="#{treeNodesAdaptor.nodes}"
var="node">
<rich:treeNode>
- <h:outputText value="#{root}"></h:outputText>
+ <h:outputText value="#{node.id}"></h:outputText>
+ <h:commandButton id="submit" value="submit"
actionListener="#{treeNodesAdaptor.submit}"></h:commandButton>
+ <a4j:commandButton id="ajaxSubmit" value="ajaxSubmit"
reRender="outputText, dataTable"
actionListener="#{treeNodesAdaptor.submit}"></a4j:commandButton>
+ <a4j:commandButton id="ajaxSingleSubmit"
value="ajaxSingleSubmit" reRender="outputText, dataTable"
actionListener="#{treeNodesAdaptor.submit}"
ajaxSingle="true"></a4j:commandButton>
</rich:treeNode>
- <rich:treeNodesAdaptor nodes="#{treeNodesAdaptor.nodes}"
var="node">
+ <rich:treeNodesAdaptor nodes="#{node.children}"
var="child">
<rich:treeNode>
- <h:outputText value="#{root}#{node}"></h:outputText>
+ <h:inputText value="#{child.id}"></h:inputText>
</rich:treeNode>
</rich:treeNodesAdaptor>
</rich:treeNodesAdaptor>
</rich:tree>
</h:form>
+ <h:outputText id="outputText"
value="#{treeNodesAdaptor.trace}"></h:outputText>
+ <h:dataTable id="dataTable"
value="#{treeNodesAdaptor.nodes[1].children}" var="child">
+ <h:column>
+ <h:outputText value="#{child.id}"></h:outputText>
+ </h:column>
+ </h:dataTable>
</ui:define>
</ui:composition>
</html>
\ No newline at end of file
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TreeNodesAdaptorTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TreeNodesAdaptorTest.java 2009-01-14
12:14:51 UTC (rev 12271)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TreeNodesAdaptorTest.java 2009-01-14
13:34:15 UTC (rev 12272)
@@ -20,6 +20,10 @@
*/
package org.richfaces.testng;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.ajax4jsf.bean.tree.TreeNodesAdaptorTestBean.Node;
import org.ajax4jsf.template.Template;
import org.richfaces.SeleniumTestBase;
import org.testng.Assert;
@@ -28,15 +32,26 @@
public class TreeNodesAdaptorTest extends SeleniumTestBase {
- private String[] nodes = {"1", "2", "3"};
- private String[] roots = {"A", "B", "C"};
+ private List<Node> nodes;
private String tree;
+ private String outputText;
+ private String dataTable;
private void init(Template template) {
- renderPage(template);
+ renderPage(null, template, "#{treeNodesAdaptor.init}");
+ nodes = new ArrayList<Node>(3);
+ for (int i = 1; i <= 3; i++) {
+ Node node = new Node(Integer.toString(i));
+ nodes.add(node);
+ for (int j = 1; j <= 3; j++) {
+ node.addChild(new Node(Integer.toString(i * 10 + j)));
+ }
+ }
String mainForm = getParentId() + "mainForm";
tree = mainForm + ":tree";
+ outputText = getParentId() + "outputText";
+ dataTable = getParentId() + "dataTable";
}
/**
@@ -47,17 +62,54 @@
public void testTreeStructure(Template template) {
init(template);
String locator = "xpath=id('"+ tree + "')/div";
- for (int i = 0; i < roots.length; i++) {
+ for (int i = 0; i < nodes.size(); i++) {
+ Node node = nodes.get(i);
String rootLocator = locator + "/table[" + (i + 1) +
"]/tbody/tr";
- Assert.assertEquals(selenium.getText(rootLocator), roots[i]);
+ Assert.assertEquals(selenium.getText(rootLocator), node.getId());
clickAjaxCommandAndWait(rootLocator + "/td[1]/div/a");
String nodesLocator = locator + "/div[" + (i + 1) + "]";
- for (int j = 0; j < nodes.length; j++) {
- Assert.assertEquals(selenium.getText(nodesLocator + "/table[" + (j + 1) +
"]/tbody/tr"), roots[i] + nodes[j]);
+ List<Node> children = node.getChildren();
+ for (int j = 0; j < children.size(); j++) {
+ Assert.assertEquals(selenium.getValue(nodesLocator + "/table[" + (j + 1) +
"]/tbody/tr/td[3]/input"), children.get(j).getId());
}
}
}
+ private void checkModel(String nodesLocator) {
+ String dataTableLocator = "xpath=id('"+ dataTable +
"')/tbody/tr[";
+ for (int j = 1; j <= 3; j++) {
+ Assert.assertEquals(selenium.getValue(nodesLocator + "/table[" + j +
"]/tbody/tr/td[3]/input"), selenium.getText(dataTableLocator + j +
"]"));
+ }
+ }
+
+ /**
+ * check input and command components processing
+ */
+ @Test
+ public void testComponentsProcessing(Template template) {
+ init(template);
+ String locator = "xpath=id('"+ tree + "')/div";
+ String titleLocator = locator + "/table[2]/tbody/tr";
+ clickAjaxCommandAndWait(titleLocator + "/td[1]/div/a");
+ String nodesLocator = locator + "/div[2]";
+ checkModel(nodesLocator);
+ for (int j = 1; j <= 3; j++) {
+ selenium.type(nodesLocator + "/table[" + j +
"]/tbody/tr/td[3]/input", "abc" + j);
+ }
+ String buttonLocator = titleLocator + "/td[3]/input[";
+ Assert.assertEquals(selenium.getText(outputText), "");
+ selenium.click(buttonLocator + "1]");
+ waitForPageToLoad();
+ checkModel(nodesLocator);
+ Assert.assertTrue(selenium.getText(outputText).endsWith("1::submit"));
+ selenium.click(buttonLocator + "2]");
+ waitForAjaxCompletion();
+ Assert.assertTrue(selenium.getText(outputText).endsWith("1::ajaxSubmit"));
+ selenium.click(buttonLocator + "3]");
+ waitForAjaxCompletion();
+ Assert.assertTrue(selenium.getText(outputText).endsWith("1::ajaxSingleSubmit"));
+ }
+
@Override
public String getTestUrl() {
return "pages/treeNodesAdaptor/treeNodesAdaptor.xhtml";
Show replies by date