Author: andrei_exadel
Date: 2008-10-13 08:47:22 -0400 (Mon, 13 Oct 2008)
New Revision: 10727
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/AutoTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestControls.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestHiddens.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScrollerAjax.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/dataTable.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/modalPanel.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/simple.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java
Removed:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScrollerListeners.xhtml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TemplateBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScroller.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataScrollerTest.java
Log:
DataScoller refactoring
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/AutoTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/AutoTestBean.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/AutoTestBean.java 2008-10-13
12:47:22 UTC (rev 10727)
@@ -0,0 +1,241 @@
+/*
+ * AutoTestBean.java Date created: 13.10.2008
+ * Last modified by: $Author$
+ * $Revision$ $Date$
+ */
+
+package org.ajax4jsf.bean;
+
+import java.util.Date;
+
+import javax.faces.event.ActionEvent;
+
+/**
+ * Bean for auto test
+ * @author Andrey Markavtsov
+ *
+ */
+public class AutoTestBean {
+
+ public static final String INPUT_TEXT = "Text";
+
+ public static final String UPDATE_MODEL_STATUS = "UpdateModel";
+
+ public static final String ACTION_LISTENER_STATUS = "Listener";
+
+ private static final String TIME_ID = "_auto_time";
+
+ private static final String STATUS_ID = "_auto_status";
+
+ private String input = null;
+
+ private String reRender = STATUS_ID;
+
+ private Boolean limitToList = false;
+
+ private Boolean ajaxSingle = false;
+
+ private Boolean immediate = false;
+
+ private Boolean bypassUpdate= false;
+
+ private Boolean rendered = true;
+
+ private String status = null;
+
+
+
+ public void actionListener(ActionEvent event) {
+ setStatus(getStatus() + ACTION_LISTENER_STATUS);
+ }
+
+ public String testRendered() {
+ reset();
+ rendered = false;
+ return null;
+ }
+
+ public String testReRender() {
+ reset();
+ reRender = TIME_ID + "," + STATUS_ID ;
+ return null;
+ }
+
+ public String testListeners() {
+ reset();
+ return null;
+ }
+
+ public String testFalidation() {
+ reset();
+ return null;
+ }
+
+ public String testAjaxSingle() {
+ reset();
+ ajaxSingle = true;
+ return null;
+ }
+
+ public String testImmdediate() {
+ reset();
+ immediate = true;
+ return null;
+ }
+
+ public String testBypassUpdate() {
+ reset();
+ bypassUpdate = true;
+ return null;
+ }
+
+ public String testLimitToList1() {
+ reset();
+ limitToList = true;
+ return null;
+ }
+
+ public String testLimitToList2() {
+ reset();
+ limitToList = true;
+ reRender = TIME_ID + "," + STATUS_ID;
+ return null;
+ }
+
+ private void reset() {
+ input = null;
+ reRender = STATUS_ID;
+ ajaxSingle = false;
+ immediate = false;
+ limitToList = false;
+ bypassUpdate = false;
+ status = null;
+ rendered = true;
+
+ }
+
+ public String getText() {
+ return String.valueOf(new Date().getTime());
+ }
+
+ /**
+ * @return the input
+ */
+ public String getInput() {
+ return input;
+ }
+
+ /**
+ * @param input the input to set
+ */
+ public void setInput(String input) {
+ if (input != null && input.equals(INPUT_TEXT)) {
+ setStatus(getStatus() + UPDATE_MODEL_STATUS);
+ }
+ this.input = input;
+ }
+
+ /**
+ * @return the reRender
+ */
+ public String getReRender() {
+ return reRender;
+ }
+
+ /**
+ * @param reRender the reRender to set
+ */
+ public void setReRender(String reRender) {
+ this.reRender = reRender;
+ }
+
+ /**
+ * @return the limitToList
+ */
+ public Boolean getLimitToList() {
+ return limitToList;
+ }
+
+ /**
+ * @param limitToList the limitToList to set
+ */
+ public void setLimitToList(Boolean limitToList) {
+ this.limitToList = limitToList;
+ }
+
+ /**
+ * @return the ajaxSingle
+ */
+ public Boolean getAjaxSingle() {
+ return ajaxSingle;
+ }
+
+ /**
+ * @param ajaxSingle the ajaxSingle to set
+ */
+ public void setAjaxSingle(Boolean ajaxSingle) {
+ this.ajaxSingle = ajaxSingle;
+ }
+
+ /**
+ * @return the immediate
+ */
+ public Boolean getImmediate() {
+ return immediate;
+ }
+
+ /**
+ * @param immediate the immediate to set
+ */
+ public void setImmediate(Boolean immediate) {
+ this.immediate = immediate;
+ }
+
+ /**
+ * @return the bypassUpdate
+ */
+ public Boolean getBypassUpdate() {
+ return bypassUpdate;
+ }
+
+ /**
+ * @param bypassUpdate the bypassUpdate to set
+ */
+ public void setBypassUpdate(Boolean bypassUpdate) {
+ this.bypassUpdate = bypassUpdate;
+ }
+
+ /**
+ * @return the status
+ */
+ public String getStatus() {
+ if (status == null) {
+ status = "";
+ }
+ return status;
+ }
+
+ /**
+ * @param status the status to set
+ */
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ /**
+ * @return the rendered
+ */
+ public Boolean getRendered() {
+ return rendered;
+ }
+
+ /**
+ * @param rendered the rendered to set
+ */
+ public void setRendered(Boolean rendered) {
+ this.rendered = rendered;
+ }
+
+
+
+}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TemplateBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TemplateBean.java 2008-10-12
19:53:49 UTC (rev 10726)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TemplateBean.java 2008-10-13
12:47:22 UTC (rev 10727)
@@ -69,6 +69,13 @@
/**
* @return the template
*/
+ public String getAutoTestTemplate() {
+ return "../../template/autotest/" + template.getName() +
".xhtml";
+ }
+
+ /**
+ * @return the template
+ */
public String getTemplatePath() {
return template.getName() + ".xhtml";
}
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 2008-10-12
19:53:49 UTC (rev 10726)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2008-10-13
12:47:22 UTC (rev 10727)
@@ -235,6 +235,11 @@
<managed-bean-name>dataScrollerBean</managed-bean-name>
<managed-bean-class>org.ajax4jsf.bean.DataScrollerBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>autoTestBean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.bean.AutoTestBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/pages/ajaxInclude/step1.xhtml</from-view-id>
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestControls.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestControls.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestControls.xhtml 2008-10-13
12:47:22 UTC (rev 10727)
@@ -0,0 +1,20 @@
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+ <h:form id="autoTestControlForm">
+ <div>
+ <h:commandButton id="testRendered"
actionListener="#{templateBean.reset}"
action="#{autoTestBean.testRendered}"
value="testRendered"></h:commandButton>
+ <h:commandButton id="testReRender"
actionListener="#{templateBean.reset}"
action="#{autoTestBean.testReRender}"
value="testReRender"></h:commandButton>
+ <h:commandButton id="testListeners"
actionListener="#{templateBean.reset}"
action="#{autoTestBean.testListeners}"
value="testListeners"></h:commandButton>
+ <h:commandButton id="testFalidation"
actionListener="#{templateBean.reset}"
action="#{autoTestBean.testFalidation}"
value="testFalidation"></h:commandButton>
+ <h:commandButton id="testAjaxSingle"
actionListener="#{templateBean.reset}"
action="#{autoTestBean.testAjaxSingle}"
value="testAjaxSingle"></h:commandButton>
+ <h:commandButton id="testImmdediate"
actionListener="#{templateBean.reset}"
action="#{autoTestBean.testImmdediate}"
value="testImmdediate"></h:commandButton>
+ <h:commandButton id="testBypassUpdate"
actionListener="#{templateBean.reset}"
action="#{autoTestBean.testBypassUpdate}"
value="testBypassUpdate"></h:commandButton>
+ <h:commandButton id="testLimitToList1"
actionListener="#{templateBean.reset}"
action="#{autoTestBean.testLimitToList1}"
value="testLimitToList1"></h:commandButton>
+ <h:commandButton id="testLimitToList2"
actionListener="#{templateBean.reset}"
action="#{autoTestBean.testLimitToList2}"
value="testLimitToList2"></h:commandButton>
+ </div>
+ </h:form>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestHiddens.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestHiddens.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestHiddens.xhtml 2008-10-13
12:47:22 UTC (rev 10727)
@@ -0,0 +1,10 @@
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+ <h:inputHidden id="_auto_input" value="#{autoTestBean.input}"
required="true"></h:inputHidden>
+ <h:outputText id="_auto_status" style="display: none;"
value="#{autoTestBean.status}"></h:outputText>
+ <h:outputText id="_auto_time"
value="#{autoTestBean.text}"></h:outputText>
+</html>
\ No newline at end of file
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScroller.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScroller.xhtml 2008-10-12
19:53:49 UTC (rev 10726)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScroller.xhtml 2008-10-13
12:47:22 UTC (rev 10727)
@@ -19,11 +19,6 @@
</table>
<h:commandButton id="apply"
actionListener="#{dataScrollerBean.apply}" value="apply"/>
<h:commandButton id="maxP"
action="#{dataScrollerBean.maxPages}" value="Test maxPages" />
- <h:commandButton id="rendered"
action="#{dataScrollerBean.rendered}" value="Test rendered" />
- <h:commandButton id="rerender"
action="#{dataScrollerBean.testReRender}" value="Test reRender" />
- <h:commandButton id="limit2list1"
action="#{dataScrollerBean.testLimitToList1}" value="Test Limit2List1"
/>
- <h:commandButton id="limit2list2"
action="#{dataScrollerBean.testLimitToList2}" value="Test Limit2List2"
/>
- <h:commandButton id="bypassUpdates"
action="#{dataScrollerBean.testByPassUpdates}" value="Test
bypassUpdates" />
</h:form>
<br/>
<h:form id="_data">
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScrollerAjax.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScrollerAjax.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScrollerAjax.xhtml 2008-10-13
12:47:22 UTC (rev 10727)
@@ -0,0 +1,43 @@
+<!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:datascroller id="componentId"
+ for="tbl"
+ align="left"
+ maxPages="#{dataScrollerBean.maxPages}"
+ page="#{dataScrollerBean.page}"
+ actionListener="#{autoTestBean.actionListener}"
+ immediate="#{autoTestBean.immediate}"
+ ajaxSingle="#{autoTestBean.ajaxSingle}"
+ reRender="#{autoTestBean.reRender}"
+ limitToList="#{autoTestBean.limitToList}"
+ bypassUpdates="#{autoTestBean.bypassUpdate}"
+ rendered="#{autoTestBean.rendered}"
+ oncomplete="window._ajaxOncomplete = true;"
+ />
+ <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>
+
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Deleted:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScrollerListeners.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScrollerListeners.xhtml 2008-10-12
19:53:49 UTC (rev 10726)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataScroller/dataScrollerListeners.xhtml 2008-10-13
12:47:22 UTC (rev 10727)
@@ -1,50 +0,0 @@
-<!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
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/dataTable.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/dataTable.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/dataTable.xhtml 2008-10-13
12:47:22 UTC (rev 10727)
@@ -0,0 +1,24 @@
+<!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:h="http://java.sun.com/jsf/html"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+<ui:composition template="../dataTable.xhtml">
+ <ui:define name="template">
+ <rich:dataTable value="1" id="_Selenium_Test_DataTable">
+ <rich:column>
+ <f:facet name="header">
+ <h:outputText value="Data Table" />
+ </f:facet>
+ <ui:include src="../../layout/autotest/autoTestControls.xhtml" />
+ <h:form id="autoTestForm">
+ <ui:include src="../../layout/autotest/autoTestHiddens.xhtml" />
+ <ui:insert name="component" />
+ </h:form>
+ </rich:column>
+ </rich:dataTable>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/modalPanel.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/modalPanel.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/modalPanel.xhtml 2008-10-13
12:47:22 UTC (rev 10727)
@@ -0,0 +1,27 @@
+<!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:h="http://java.sun.com/jsf/html"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+<ui:composition template="../modalPanel.xhtml">
+ <ui:define name="template">
+ <rich:modalPanel id="_Selenium_Test_ModalPanel"
showWhenRendered="true" width="600" height="600">
+ <f:facet name="header" >
+ <h:outputText value="Modal Panel" />
+ </f:facet>
+ <f:facet name="controls" >
+ <a onclick="Richfaces.hideModalPanel('_Selenium_Test_ModalPanel');
return false;"
+ href="#" >Hide the panel</a>
+ </f:facet>
+ <ui:include src="../../layout/autotest/autoTestControls.xhtml" />
+ <h:form id="autoTestForm">
+ <ui:include src="../../layout/autotest/autoTestHiddens.xhtml" />
+ <ui:insert name="component" />
+ </h:form>
+ <ui:include src="../../layout/controlLayout.xhtml" />
+ </rich:modalPanel>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/simple.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/simple.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/autotest/simple.xhtml 2008-10-13
12:47:22 UTC (rev 10727)
@@ -0,0 +1,17 @@
+<!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:h="http://java.sun.com/jsf/html"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+<ui:composition template="../simple.xhtml">
+ <ui:define name="template">
+ <ui:include src="../../layout/autotest/autoTestControls.xhtml" />
+ <h:form id="autoTestForm">
+ <ui:include src="../../layout/autotest/autoTestHiddens.xhtml" />
+ <ui:insert name="component" />
+ </h:form>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java 2008-10-13
12:47:22 UTC (rev 10727)
@@ -0,0 +1,217 @@
+/*
+ * AutoTester.java Date created: 13.10.2008
+ * Last modified by: $Author$
+ * $Revision$ $Date$
+ */
+
+package org.richfaces;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.ajax4jsf.bean.AutoTestBean;
+import org.ajax4jsf.template.Template;
+import org.testng.Assert;
+
+/**
+ * Class provides scope of mehods for automatic test of standard ajax attrs
+ * @author Andrey Markavtsov
+ *
+ */
+public class AutoTester {
+
+ private static final String AUTOTEST_CONTROLS_FORM_ID =
"autoTestControlForm:";
+
+ private static final String AUTOTEST_FORM_ID = "autoTestForm:";
+
+ private static final String INPUT_ID = "_auto_input";
+
+ private static final String STATUS_ID = "_auto_status";
+
+ private static final String TIME_ID = "_auto_time";
+
+ public static final String COMPONENT_ID = "componentId";
+
+// /private String componentName;
+
+
+ SeleniumTestBase base;
+
+ public AutoTester(SeleniumTestBase base) {
+ this.base = base;
+ }
+
+ public void renderPage(Template template, String resetMethodName) {
+ base.renderAutoTestPage(template, resetMethodName);
+ }
+
+ public void testAllAjaxAttributes() {
+ testRendered();
+ testReRender();
+ testActionListener();
+ testAjaxSingle();
+ testImmediate();
+ testBypassUpdate();
+ testFalidationFailure();
+ testLimitToList();
+ }
+
+ public void testRendered() {
+ String commandId = base.getParentId() + AUTOTEST_CONTROLS_FORM_ID +
"testRendered";
+ base.clickCommandAndWait(commandId);
+ base.AssertNotPresent(getClientId(COMPONENT_ID), "Rendered attribute does not
work");
+ }
+
+ public void testReRender() {
+ String commandId = base.getParentId() + AUTOTEST_CONTROLS_FORM_ID +
"testReRender";
+ base.clickCommandAndWait(commandId);
+ setValidation(true);
+
+ String text = base.getTextById(base.getParentId() + AUTOTEST_FORM_ID + TIME_ID);
+
+ base.sendAjax();
+ base.AssertTextNotEquals(base.getParentId() + AUTOTEST_FORM_ID + TIME_ID, text,
"ReRender attribute does not work");
+
+ String oncomplete = base.runScript("window._ajaxOncomplete");
+ Assert.assertEquals("true", oncomplete, "Oncomplete attribute does not
work.");
+ }
+
+ public void testActionListener() {
+ String commandId = base.getParentId() + AUTOTEST_CONTROLS_FORM_ID +
"testListeners";
+ base.clickCommandAndWait(commandId);
+ setValidation(true);
+
+ base.sendAjax();
+
+ checkListener(true);
+ checkUpdateModel(true);
+ }
+
+ public void testFalidationFailure() {
+ String commandId = base.getParentId() + AUTOTEST_CONTROLS_FORM_ID +
"testFalidation";
+ base.clickCommandAndWait(commandId);
+ setValidation(false);
+
+ base.sendAjax();
+
+ checkListener(false);
+ checkUpdateModel(false);
+ }
+
+ public void testAjaxSingle() {
+ String commandId = base.getParentId() + AUTOTEST_CONTROLS_FORM_ID +
"testAjaxSingle";
+ base.clickCommandAndWait(commandId);
+ setValidation(false);
+
+ base.sendAjax();
+
+ checkListener(true);
+ checkUpdateModel(false);
+
+ }
+
+ public void testImmediate() {
+ String commandId = base.getParentId() + AUTOTEST_CONTROLS_FORM_ID +
"testImmdediate";
+ base.clickCommandAndWait(commandId);
+ setValidation(true);
+
+ base.sendAjax();
+
+ checkListener(true);
+ checkUpdateModel(false);
+
+ }
+
+ public void testBypassUpdate() {
+ String commandId = base.getParentId() + AUTOTEST_CONTROLS_FORM_ID +
"testBypassUpdate";
+ base.clickCommandAndWait(commandId);
+ setValidation(true);
+
+ base.sendAjax();
+
+ checkListener(true);
+ checkUpdateModel(false);
+ }
+
+ public void testLimitToList() {
+ String commandId = base.getParentId() + AUTOTEST_CONTROLS_FORM_ID +
"testLimitToList1";
+ base.clickCommandAndWait(commandId);
+ setValidation(true);
+
+ checkComponentReRendered();
+
+ commandId = base.getParentId() + AUTOTEST_CONTROLS_FORM_ID +
"testLimitToList2";
+ base.clickCommandAndWait(commandId);
+ setValidation(true);
+
+ String text = base.getTextById(base.getParentId() + AUTOTEST_FORM_ID + TIME_ID);
+
+ checkComponentReRendered();
+
+ base.AssertTextNotEquals(base.getParentId() + AUTOTEST_FORM_ID + TIME_ID, text,
"" +
+ "LimitToList = true does not work. Component in reRender list was not
rerendered");
+
+ }
+
+ private void checkComponentReRendered() {
+ List<String> htmlBefore = new ArrayList<String>();
+ List<String> htmlAfter = new ArrayList<String>();
+
+ for (String id : base.getReRendersId()) {
+ htmlBefore.add(base.getHTMLById(getClientId(id)));
+ }
+
+ base.sendAjax();
+
+ for (String id : base.getReRendersId()) {
+ htmlAfter.add(base.getHTMLById(getClientId(id)));
+ }
+
+ int i = 0;
+ for (String html : htmlBefore) {
+ Assert
+ .assertEquals(
+ html,
+ htmlAfter.get(i),
+ "LimitToList does not work. Component should not be reRendered if
limitToList=true");
+
+ i++;
+ }
+ }
+
+ public String getClientId(String id) {
+ return (base.getParentId()!= null ? base.getParentId() : "")+
AUTOTEST_FORM_ID + id;
+ }
+
+ public String getClientId(String id, Template template) {
+ return template.getPrefix() + AUTOTEST_FORM_ID + id;
+ }
+
+
+ private void setValidation(boolean passed) {
+ base.setValueById(base.getParentId() + AUTOTEST_FORM_ID + INPUT_ID, (passed) ?
AutoTestBean.INPUT_TEXT : "");
+ }
+
+
+ private void checkListener(boolean passed) {
+ String status = getStatus();
+ if (passed && status != null &&
status.indexOf(AutoTestBean.ACTION_LISTENER_STATUS) == -1) {
+ Assert.fail("ActionListener has been skipped");
+ }else if (!passed && status != null &&
status.indexOf(AutoTestBean.ACTION_LISTENER_STATUS) != -1) {
+ Assert.fail("ActionListener should be skipped");
+ }
+ }
+
+ private void checkUpdateModel(boolean passed) {
+ String status = getStatus();
+ if (passed && status != null &&
status.indexOf(AutoTestBean.UPDATE_MODEL_STATUS) == -1) {
+ Assert.fail("Update Model phase has been skipped");
+ }else if (!passed && status != null &&
status.indexOf(AutoTestBean.UPDATE_MODEL_STATUS) != -1) {
+ Assert.fail("Update Model phase should be skipped");
+ }
+ }
+
+ private String getStatus() {
+ return base.getTextById(base.getParentId() + AUTOTEST_FORM_ID + STATUS_ID);
+ }
+}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2008-10-12
19:53:49 UTC (rev 10726)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2008-10-13
12:47:22 UTC (rev 10727)
@@ -79,6 +79,15 @@
private SeleniumServer seleniumServer;
private Object[][] data;
+
+ private Template template;
+
+ /**
+ * Returns current template
+ * */
+ public Template getTemplate() {
+ return template;
+ }
/** Defines the name of current j2ee application name */
public static final String APPLICATION_NAME = "richfaces";
@@ -204,9 +213,36 @@
checkPageRendering(); // Check all again
checkJSError();
+
+ this.template = template;
}
+
/**
+ * Renders page
+ */
+ protected void renderAutoTestPage(Template template, String resetMethodName) {
+ selenium.open(protocol + "://" + host + ":" + port +
"/" + APPLICATION_NAME + filterPrefix + getAutoTestUrl());
+ selenium.waitForPageToLoad(String.valueOf(pageRenderTime));
+
+ setParentId(template.getPrefix());
+ runScript("loadTemplate('" + template + "');",
false);
+ waitForPageToLoad();
+
+ checkPageRendering(); // At the first we check if page has been
+ // rendered
+ checkJSError(); // At the second we check if JS errors occurred
+
+ reRenderForm(resetMethodName); // ReRender component
+
+ checkPageRendering(); // Check all again
+ checkJSError();
+
+ this.template = template;
+
+ }
+
+ /**
* Writes status message on client side
*
* @param message
@@ -946,6 +982,30 @@
public abstract String getTestUrl();
/**
+ * Returns the url to auto test page to be opened by selenium
+ *
+ * @return
+ */
+ public String getAutoTestUrl() {
+ return null;
+ }
+
+ /**
+ * Control action that should force ajax request from the component.
+ * This method should be overridden for auto test
+ */
+ public void sendAjax() {
+ }
+
+ /**
+ * Returns the array of components' ids that are rerendering after ajax request
from the component.
+ * This method should be overridden for auto test
+ */
+ public String [] getReRendersId() {
+ return null;
+ }
+
+ /**
* Simulates mouse event for element
* @param id - Element ID
* @param eventName - Mouse event Name
@@ -1065,4 +1125,8 @@
b.append("').onclick");
return runScript(b.toString());
}
+
+ public String getHTMLById(String id) {
+ return runScript(getElementById(id) + ".innerHTML");
+ }
}
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-12
19:53:49 UTC (rev 10726)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataScrollerTest.java 2008-10-13
12:47:22 UTC (rev 10727)
@@ -10,6 +10,7 @@
import java.util.List;
import org.ajax4jsf.template.Template;
+import org.richfaces.AutoTester;
import org.richfaces.SeleniumTestBase;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -23,8 +24,6 @@
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;
@@ -53,143 +52,33 @@
};
@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);
+ public void testAutoAjaxAttributes(Template template) {
+ AutoTester autoTester = new AutoTester(this);
+ dataScrollerTableId = autoTester.getClientId(AutoTester.COMPONENT_ID +
"_table", template);
- String statusId = getParentId() + "_data:status";
- String status = null;
- String commandId = null;
+ autoTester.renderPage(template, RESET_METHOD_ME);
+ autoTester.testAllAjaxAttributes();
- // 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);
-
- String inputId = getParentId() + "_data:input";
- String commandId = getParentId() + "_controls:bypassUpdates";
-
- clickCommandAndWait(commandId);
-
- setValueById(inputId, "bypassUpdates = true");
+ @Override
+ public void sendAjax() {
clickControl(4);
- AssertTextEquals(inputId, "", "BypassUpdates attribute does not
work.");
}
- @Test
- public void testLimitToList(Template template) {
- renderPage(template, RESET_METHOD_ME);
- initIDs(getParentId(), template);
-
- String commandId = getParentId() + "_controls:limit2list1";
- clickCommandAndWait(commandId);
-
- String text = selenium.getTable("id=" + dataTableId +
"."+1+".1");
-
- clickControl(4);
-
- Assert.assertEquals(selenium.getTable("id=" + dataTableId +
"."+1+".1"), text, "LimitToList does not work. Datatable has been
rerendered");
-
- commandId = getParentId() + "_controls:limit2list2";
- clickCommandAndWait(commandId);
-
- text = selenium.getTable("id=" + dataTableId +
"."+1+".1");
- clickControl(5);
- Assert.assertFalse(selenium.getTable("id=" + dataTableId +
"."+1+".1").equals(text), "LimitToList does not work. Datatable
has not been updated");
-
+ @Override
+ public String[] getReRendersId() {
+ return new String [] {AutoTester.COMPONENT_ID,
+ (getTemplate().equals(Template.DATA_TABLE)) ? "tbl:0" : "tbl"};
}
- @Test
- public void testReRender(Template template) {
- renderPage(template, RESET_METHOD_ME);
- initIDs(getParentId(), template);
-
- String commandId = getParentId() + "_controls:rerender";
- clickCommandAndWait(commandId);
-
- String timeId = getParentId() + "_data:time";
- String text = getTextById(timeId);
-
- clickControl(4);
-
- String scr = runScript("window.dataScrollerComplete");
- if (!scr.equals("true")) {
- Assert.fail("Oncomplete attribute does not work");
- }
-
- AssertTextNotEquals(timeId, text, "ReRender attribute does not work");
+ @Override
+ public String getAutoTestUrl() {
+ return "pages/dataScroller/dataScrollerAjax.xhtml";
}
- @Test
- public void testRendered(Template template) {
- renderPage(template, RESET_METHOD_ME);
- initIDs(getParentId(), template);
-
- String commandId = getParentId() + "_controls:rendered";
- clickCommandAndWait(commandId);
-
- AssertNotPresent(dataScrollerId, "Rendered attribute does not work");
- AssertNotPresent(dataScrollerTableId, "Rendered attribute does not work");
- }
+
@Test
@@ -322,15 +211,7 @@
}
- 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";