Author: andrei_exadel
Date: 2008-10-10 08:14:12 -0400 (Fri, 10 Oct 2008)
New Revision: 10712
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScrollerListeners.xhtml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataScrollerBean.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataScrollerTest.java
Log:
DataScroller: listeners test
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataScrollerBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataScrollerBean.java 2008-10-10
11:20:37 UTC (rev 10711)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataScrollerBean.java 2008-10-10
12:14:12 UTC (rev 10712)
@@ -12,6 +12,8 @@
import javax.faces.event.ActionEvent;
+import org.ajax4jsf.context.AjaxContext;
+
/**
* Bean class for dataScroller component testing
* @author Andrey Markavtsov
@@ -42,6 +44,12 @@
private Boolean bypassUpdates = false;
+ private Boolean immediate;
+
+ private Boolean ajaxSingle;
+
+ private String status;
+
public DataScrollerBean() {
init();
}
@@ -79,6 +87,33 @@
return null;
}
+ public String testImmediate() {
+ page = null;
+ status = null;
+ immediate = true;
+ return null;
+ }
+
+ public String testFalidationFailure() {
+ page = null;
+ status = null;
+ return null;
+ }
+
+ public String testAjaxSingle() {
+ page = null;
+ status = null;
+ ajaxSingle = true;
+ return null;
+ }
+
+ public void actionListener(ActionEvent event) {
+ if (status == null) {
+ status = "";
+ }
+ status = status + "ActionListener";
+ }
+
private void init() {
data = new ArrayList();
for (int i = 0; i < totalRows; i++) {
@@ -98,6 +133,9 @@
limitToList = false;
onComplete = null;
bypassUpdates = false;
+ ajaxSingle = false;
+ immediate = false;
+ status = null;
}
public void apply(ActionEvent event) {
@@ -216,6 +254,11 @@
}
public void setInput(String input) {
+ if (status == null) {
+ status = "";
+ }
+ if (input.equals("Text"))
+ status = status + "UpdateModel ";
this.input = input;
}
@@ -234,4 +277,29 @@
public void setBypassUpdates(Boolean bypassUpdates) {
this.bypassUpdates = bypassUpdates;
}
+
+ public Boolean getImmediate() {
+ return immediate;
+ }
+
+ public void setImmediate(Boolean immediate) {
+ this.immediate = immediate;
+ }
+
+ public Boolean getAjaxSingle() {
+ return ajaxSingle;
+ }
+
+ public void setAjaxSingle(Boolean ajaxSingle) {
+ this.ajaxSingle = ajaxSingle;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
}
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScrollerListeners.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScrollerListeners.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScrollerListeners.xhtml 2008-10-10
12:14:12 UTC (rev 10712)
@@ -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">
+ <script>
+ </script>
+ <h:form id="_controls">
+ <h:commandButton id="fValidation"
action="#{dataScrollerBean.testFalidationFailure}" value="Test validation
failure"></h:commandButton>
+ <h:commandButton id="ajaxSingle"
action="#{dataScrollerBean.testAjaxSingle}" value="Test Ajax
Single"></h:commandButton>
+ <h:commandButton id="immediate"
action="#{dataScrollerBean.testImmediate}" value="Test
Immediate"></h:commandButton>
+ </h:form>
+ <br/>
+ <h:form id="_data">
+ <h:outputText id="status"
value="#{dataScrollerBean.status}"></h:outputText>
+ <rich:datascroller id="scroller"
+ for="tbl"
+ align="left"
+ maxPages="#{dataScrollerBean.maxPages}"
+ page="#{dataScrollerBean.page}"
+ actionListener="#{dataScrollerBean.actionListener}"
+ immediate="#{dataScrollerBean.immediate}"
+ ajaxSingle="#{dataScrollerBean.ajaxSingle}"
+ reRender="status"
+ />
+ <br/>
+ <rich:dataTable id="tbl" value="#{dataScrollerBean.data}"
rows="#{dataScrollerBean.tableRows}" var="var">
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText value="#" />
+ </f:facet>
+ <h:outputText value="#{var[0]}" />
+ </rich:column>
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText value="Data" />
+ </f:facet>
+ <h:outputText value="#{var[1]}" />
+ </rich:column>
+ </rich:dataTable>
+ <h:inputHidden id="input" value="#{dataScrollerBean.input}"
required="true"></h:inputHidden>
+ </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/DataScrollerTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataScrollerTest.java 2008-10-10
11:20:37 UTC (rev 10711)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataScrollerTest.java 2008-10-10
12:14:12 UTC (rev 10712)
@@ -7,7 +7,6 @@
package org.richfaces.testng;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import org.ajax4jsf.template.Template;
@@ -22,6 +21,10 @@
*/
public class DataScrollerTest extends SeleniumTestBase {
+ static String TEST__URL = "pages/dataScroller/dataScroller.xhtml";
+
+ static final String TEST_AJAX_URL =
"pages/dataScroller/dataScrollerListeners.xhtml";
+
static final String RESET_METHOD_ME = "#{dataScrollerBean.reset}";
String dataScrollerId;
@@ -50,6 +53,73 @@
};
@Test
+ public void testAjaxAttributes(Template template) {
+ TEST__URL = TEST_AJAX_URL;
+ final String UPDATE_MODEL = "UpdateModel";
+ final String LISTENER = "ActionListener";
+ renderPage(template, RESET_METHOD_ME);
+ initIDs(getParentId(), template);
+
+ String statusId = getParentId() + "_data:status";
+ String status = null;
+ String commandId = null;
+
+ // Test actionListener & model Update
+ setValidation(true, getParentId());
+ clickControl(4);
+ status = getTextById(statusId);
+ if (status.indexOf(UPDATE_MODEL) == -1) {
+ writeStatus("Update model phase has been skipped", true);
+ Assert.fail("Update model phase has been skipped");
+ }else if (status.indexOf(LISTENER) == -1) {
+ writeStatus("Invoke application phase has been skipped", true);
+ Assert.fail("Invoke application phase has been skipped");
+ }
+
+ // Test actionListener & model Update if validation failure
+ commandId = getParentId() + "_controls:fValidation";
+ clickCommandAndWait(commandId);
+ setValidation(false, getParentId());
+ clickControl(4);
+ status = getTextById(statusId);
+ if (status.indexOf(UPDATE_MODEL) != -1) {
+ writeStatus("Update model should be skipped in case of failed validation",
true);
+ Assert.fail("Update model should be skipped in case of failed validation");
+ }else if (status.indexOf(LISTENER) != -1) {
+ writeStatus("Invoke application phase should be skipped in case of failed
validation", true);
+ Assert.fail("Invoke application phase should be skipped in case of failed
validation");
+ }
+
+ // Test actionListener & model Update if ajaxSingle
+ commandId = getParentId() + "_controls:ajaxSingle";
+ clickCommandAndWait(commandId);
+ setValidation(true, getParentId());
+ clickControl(4);
+ status = getTextById(statusId);
+ if (status.indexOf(UPDATE_MODEL) != -1) {
+ writeStatus("Update model should be skipped in case of ajaxSingle", true);
+ Assert.fail("Update model should be skipped in case of ajaxSingle");
+ }else if (status.indexOf(LISTENER) == -1) {
+ writeStatus("Invoke application phase has been skipped for ajaxSingle",
true);
+ Assert.fail("Invoke application phase has been skipped for ajaxSingle");
+ }
+
+ // Test actionListener & model Update if immediate
+ commandId = getParentId() + "_controls:immediate";
+ clickCommandAndWait(commandId);
+ setValidation(false, getParentId());
+ clickControl(4);
+ status = getTextById(statusId);
+ if (status.indexOf(UPDATE_MODEL) != -1) {
+ writeStatus("Update model should be skipped in case of immediate", true);
+ Assert.fail("Update model should be skipped in case of immediate");
+ }else if (status.indexOf(LISTENER) == -1) {
+ writeStatus("Invoke application phase has been skipped for immediate",
true);
+ Assert.fail("Invoke application phase has been skipped for immediate");
+ }
+ }
+
+ @Test
public void testBypassUpdates(Template template) {
renderPage(template, RESET_METHOD_ME);
initIDs(getParentId(), template);
@@ -252,6 +322,15 @@
}
+ private void setValidation(boolean validationPassed, String parentId) {
+ String inputId = getParentId() + "_data:input";
+ if (validationPassed) {
+ setValueById(inputId, "Text");
+ } else {
+ setValueById(inputId, "");
+ }
+ }
+
private void initIDs(String parentId, Template template) {
dataScrollerId = parentId + "_data:scroller";
dataScrollerTableId = parentId + "_data:scroller_table";
@@ -372,7 +451,8 @@
*/
@Override
public String getTestUrl() {
- return "pages/dataScroller/dataScroller.xhtml";
+ return TEST__URL;
}
}
+