Author: vmolotkov
Date: 2008-10-10 16:14:24 -0400 (Fri, 10 Oct 2008)
New Revision: 10724
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/includes/
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/includes/testBody.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testAjaxSingleAttribute1.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testAjaxSingleAttribute2.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testDefaultBehaviour.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testEnabledAttribute.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testImmediateAttribute1.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testImmediateAttribute2.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testRerenderFunctionality.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testValidationFailed.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/caseTemplate.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/CommonUtils.java
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/A4JSupport.java
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TemplateBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/listener/AjaxSupportActionListener.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/ajaxSupport.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxSupportTest.java
Log:
a4j support tests
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/A4JSupport.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/A4JSupport.java 2008-10-10
16:37:00 UTC (rev 10723)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/A4JSupport.java 2008-10-10
20:14:24 UTC (rev 10724)
@@ -19,15 +19,17 @@
public static final String NO_DATA = "nodata";
+ public static final String TEST_PASSED = "test passed";
+
public static final String VALID_MESSAGE = "field is required";
}
public void linkListener (ActionEvent event) {
- data = Messages.FOR_LINK;
+ data = Messages.TEST_PASSED;
}
public void checkBoxListener (ActionEvent event) {
- data = Messages.FOR_CHECKBOX;
+ data = Messages.TEST_PASSED;
}
public void commandListener (ActionEvent event) {
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-10
16:37:00 UTC (rev 10723)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TemplateBean.java 2008-10-10
20:14:24 UTC (rev 10724)
@@ -42,6 +42,8 @@
private Template template = Template.SIMPLE;
+ private Template templatePath = Template.SIMPLE;
+
private String methodName;
@@ -63,6 +65,13 @@
public String getTemplate() {
return "../../template/" + template.getName() + ".xhtml";
}
+
+ /**
+ * @return the template
+ */
+ public String getTemplatePath() {
+ return template.getName() + ".xhtml";
+ }
/**
* @param template
@@ -71,6 +80,10 @@
public void setTemplate(Template template) {
this.template = template;
}
+
+ public void setTemplatePath(Template templatePath) {
+ this.templatePath = templatePath;
+ }
public List<SelectItem> getAvailableTemplates() {
List<SelectItem> retVal = new ArrayList<SelectItem>();
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/listener/AjaxSupportActionListener.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/listener/AjaxSupportActionListener.java 2008-10-10
16:37:00 UTC (rev 10723)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/listener/AjaxSupportActionListener.java 2008-10-10
20:14:24 UTC (rev 10724)
@@ -12,11 +12,11 @@
public class AjaxSupportActionListener implements ActionListener, ValueChangeListener {
public void processAction(ActionEvent e) {
- process(Messages.FOR_LINK);
+ process(Messages.TEST_PASSED);
}
public void processValueChange(ValueChangeEvent ce) {
- process(Messages.FOR_CHECKBOX);
+ process(Messages.TEST_PASSED);
}
private void process(String str) {
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/ajaxSupport.xhtml
===================================================================
(Binary files differ)
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/includes/testBody.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/includes/testBody.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/includes/testBody.xhtml 2008-10-10
20:14:24 UTC (rev 10724)
@@ -0,0 +1,56 @@
+<ui:composition
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">
+ <h:form id="_form">
+ <h:inputText id="validManager" required="true"
value="1" requiredMessage="field is required"/> 
+ <table cellpadding="5" >
+ <tr>
+ <td>1.1</td>
+ <td>
+ <h:outputLink id="link_#{test_prefix}" style="text-decoration:
none; color: blue;" value="#">
+ attribute actionListener
+ <a4j:support event="onclick" reRender="data1_#{test_prefix}"
actionListener="#{ajaxSupport.linkListener}" immediate="#{immediate}"
ajaxSingle="#{ajaxSingle}"
enabled="#{enabled}"></a4j:support>
+ </h:outputLink>
+ </td>
+ <td><div><h:outputText style="font-weight: bold; border: 1px solid
green" value="#{ajaxSupport.data}"
id="data1_#{test_prefix}"></h:outputText></div></td>
+ </tr>
+ <tr>
+ <td>1.2</td>
+ <td>
+ <h:outputLink id="linkAL_#{test_prefix}" style="text-decoration:
none; color: blue;" value="#">
+ tag actionListener
+ <a4j:support event="onclick"
reRender="data1AL_#{test_prefix}" immediate="#{immediate}"
ajaxSingle="#{ajaxSingle}" enabled="#{enabled}">
+ <f:actionListener
type="org.ajax4jsf.listener.AjaxSupportActionListener" />
+ </a4j:support>
+ </h:outputLink>
+ </td>
+ <td><h:outputText style="font-weight: bold; border: 1px solid
green" value="#{ajaxSupport.data}"
id="data1AL_#{test_prefix}"></h:outputText></td>
+ </tr>
+ <tr>
+ <td>2.1</td>
+ <td>
+ <h:selectBooleanCheckbox id="checkbox_#{test_prefix}">
+ <a4j:support event="onchange" reRender="data2_#{test_prefix}"
actionListener="#{ajaxSupport.checkBoxListener}"
immediate="#{immediate}" ajaxSingle="#{ajaxSingle}"
enabled="#{enabled}"></a4j:support>
+ </h:selectBooleanCheckbox>
+ attribute actionListener
+ </td>
+ <td><h:outputText style="font-weight: bold; border: 1px solid
green" value="#{ajaxSupport.data}"
id="data2_#{test_prefix}"></h:outputText></td>
+ </tr>
+ <tr>
+ <td>2.2</td>
+ <td>
+ <h:selectBooleanCheckbox id="checkboxAL_#{test_prefix}">
+ <a4j:support event="onchange"
reRender="data2AL_#{test_prefix}" immediate="#{immediate}"
ajaxSingle="#{ajaxSingle}" enabled="#{enabled}">
+ <f:actionListener
type="org.ajax4jsf.listener.AjaxSupportActionListener" />
+ </a4j:support>
+ </h:selectBooleanCheckbox>
+ tag actionListener
+ </td>
+ <td><h:outputText style="font-weight: bold; border: 1px solid
green" value="#{ajaxSupport.data}"
id="data2AL_#{test_prefix}"></h:outputText></td>
+ </tr>
+ </table>
+ </h:form>
+</ui:composition>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testAjaxSingleAttribute1.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testAjaxSingleAttribute1.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testAjaxSingleAttribute1.xhtml 2008-10-10
20:14:24 UTC (rev 10724)
@@ -0,0 +1,19 @@
+<!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="../../template/caseTemplate.xhtml">
+ <ui:define name="caseName">testAjaxSingleAttribute1</ui:define>
+ <ui:define name="caseBody">
+ <ui:include src="includes/testBody.xhtml">
+ <ui:param name="test_prefix" value="asa1"/>
+ <ui:param name="immediate" value="false"/>
+ <ui:param name="ajaxSingle" value="true"/>
+ <ui:param name="enabled" value="true"/>
+ </ui:include>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testAjaxSingleAttribute2.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testAjaxSingleAttribute2.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testAjaxSingleAttribute2.xhtml 2008-10-10
20:14:24 UTC (rev 10724)
@@ -0,0 +1,19 @@
+<!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="../../template/caseTemplate.xhtml">
+ <ui:define name="caseName">testAjaxSingleAttribute2</ui:define>
+ <ui:define name="caseBody">
+ <ui:include src="includes/testBody.xhtml">
+ <ui:param name="test_prefix" value="asa2"/>
+ <ui:param name="immediate" value="false"/>
+ <ui:param name="ajaxSingle" value="true"/>
+ <ui:param name="enabled" value="true"/>
+ </ui:include>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testDefaultBehaviour.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testDefaultBehaviour.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testDefaultBehaviour.xhtml 2008-10-10
20:14:24 UTC (rev 10724)
@@ -0,0 +1,19 @@
+<!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="../../template/caseTemplate.xhtml">
+ <ui:define name="caseName">testDefaultBehaviour</ui:define>
+ <ui:define name="caseBody">
+ <ui:include src="includes/testBody.xhtml">
+ <ui:param name="test_prefix" value="db"/>
+ <ui:param name="immediate" value="false"/>
+ <ui:param name="ajaxSingle" value="false"/>
+ <ui:param name="enabled" value="true"/>
+ </ui:include>
+ </ui:define>
+</ui:composition>
+</html>
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testEnabledAttribute.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testEnabledAttribute.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testEnabledAttribute.xhtml 2008-10-10
20:14:24 UTC (rev 10724)
@@ -0,0 +1,19 @@
+<!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="../../template/caseTemplate.xhtml">
+ <ui:define name="caseName">testDefaultBehaviour</ui:define>
+ <ui:define name="caseBody">
+ <ui:include src="includes/testBody.xhtml">
+ <ui:param name="test_prefix" value="ea"/>
+ <ui:param name="immediate" value="false"/>
+ <ui:param name="ajaxSingle" value="false"/>
+ <ui:param name="enabled" value="false"/>
+ </ui:include>
+ </ui:define>
+</ui:composition>
+</html>
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testImmediateAttribute1.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testImmediateAttribute1.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testImmediateAttribute1.xhtml 2008-10-10
20:14:24 UTC (rev 10724)
@@ -0,0 +1,19 @@
+<!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="../../template/caseTemplate.xhtml">
+ <ui:define name="caseName">testImmediateAttribute1</ui:define>
+ <ui:define name="caseBody">
+ <ui:include src="includes/testBody.xhtml">
+ <ui:param name="test_prefix" value="ia1"/>
+ <ui:param name="immediate" value="true"/>
+ <ui:param name="ajaxSingle" value="false"/>
+ <ui:param name="enabled" value="true"/>
+ </ui:include>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testImmediateAttribute2.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testImmediateAttribute2.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testImmediateAttribute2.xhtml 2008-10-10
20:14:24 UTC (rev 10724)
@@ -0,0 +1,19 @@
+<!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="../../template/caseTemplate.xhtml">
+ <ui:define name="caseName">testImmediateAttribute2</ui:define>
+ <ui:define name="caseBody">
+ <ui:include src="includes/testBody.xhtml">
+ <ui:param name="test_prefix" value="ia2"/>
+ <ui:param name="immediate" value="true"/>
+ <ui:param name="ajaxSingle" value="false"/>
+ <ui:param name="enabled" value="true"/>
+ </ui:include>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testRerenderFunctionality.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testRerenderFunctionality.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testRerenderFunctionality.xhtml 2008-10-10
20:14:24 UTC (rev 10724)
@@ -0,0 +1,19 @@
+<!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="../../template/caseTemplate.xhtml">
+ <ui:define name="caseName">testRerenderFunctionality</ui:define>
+ <ui:define name="caseBody">
+ <ui:include src="includes/testBody.xhtml">
+ <ui:param name="test_prefix" value="ra"/>
+ <ui:param name="immediate" value="false"/>
+ <ui:param name="ajaxSingle" value="false"/>
+ <ui:param name="enabled" value="true"/>
+ </ui:include>
+ </ui:define>
+</ui:composition>
+</html>
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testValidationFailed.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testValidationFailed.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testValidationFailed.xhtml 2008-10-10
20:14:24 UTC (rev 10724)
@@ -0,0 +1,19 @@
+<!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="../../template/caseTemplate.xhtml">
+ <ui:define name="caseName">testValidationFailed</ui:define>
+ <ui:define name="caseBody">
+ <ui:include src="includes/testBody.xhtml">
+ <ui:param name="test_prefix" value="vf"/>
+ <ui:param name="immediate" value="false"/>
+ <ui:param name="ajaxSingle" value="false"/>
+ <ui:param name="enabled" value="true"/>
+ </ui:include>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/caseTemplate.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/caseTemplate.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/caseTemplate.xhtml 2008-10-10
20:14:24 UTC (rev 10724)
@@ -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.templatePath}">
+ <ui:define name="component">
+ <table width="100%">
+ <colgroup>
+ <col width="30%"/>
+ <col width="70%"/>
+ </colgroup>
+ <tr>
+ <td><ui:insert name="caseName"/></td>
+ <td>
+ <ui:insert name="caseBody"/>
+ </td>
+ </tr>
+ </table>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxSupportTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxSupportTest.java 2008-10-10
16:37:00 UTC (rev 10723)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxSupportTest.java 2008-10-10
20:14:24 UTC (rev 10724)
@@ -6,6 +6,7 @@
import org.ajax4jsf.bean.A4JSupport;
import org.ajax4jsf.template.Template;
import org.richfaces.SeleniumTestBase;
+import org.richfaces.testng.util.CommonUtils;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -14,134 +15,267 @@
*
*/
public class AjaxSupportTest extends SeleniumTestBase {
+
+ private static final String COMMON_ALISTENER_PREFIX = "AL";
- private static final String ALISTENER_PREFIX = "AL";
+ private static final String DEFAULT_BEHAVIOUR_PAGE =
"testDefaultBehaviour.xhtml";
+ private static final String VALIDATION_FAILED_PAGE =
"testValidationFailed.xhtml";
+
+ private static final String IMMEDIATE_ATTRIBUTE1_PAGE =
"testImmediateAttribute1.xhtml";
+
+ private static final String IMMEDIATE_ATTRIBUTE2_PAGE =
"testImmediateAttribute2.xhtml";
+
+ private static final String AJAXSINGLE_ATTRIBUTE1_PAGE =
"testAjaxSingleAttribute1.xhtml";
+
+ private static final String AJAXSINGLE_ATTRIBUTE2_PAGE =
"testAjaxSingleAttribute2.xhtml";
+
+ private static final String RERENDER_ATTRIBUTE_PAGE =
"testRerenderFunctionality.xhtml";
+
+ private static final String ENABLED_ATTRIBUTE_PAGE =
"testEnabledAttribute.xhtml";
+
+ private static final String DEFAULT_BEHAVIOUR_ID_PREFIX = "_db";
+
+ private static final String VALIDATION_FAILED_ID_PREFIX = "_vf";
+
+ private static final String IMMEDIATE_ATTRIBUTE1_ID_PREFIX = "_ia1";
+
+ private static final String IMMEDIATE_ATTRIBUTE2_ID_PREFIX = "_ia2";
+
+ private static final String AJAXSINGLE_ATTRIBUTE1_ID_PREFIX = "_asa1";
+
+ private static final String AJAXSINGLE_ATTRIBUTE2_ID_PREFIX = "_asa2";
+
+ private static final String RERENDER_ATTRIBUTE_ID_PREFIX = "_ra";
+
+ private static final String ENABLED_ATTRIBUTE_ID_PREFIX = "_ea";
+
+ private String testUrl;
+
private String parentFormId;
private String linkId;
+ private String checkboxId;
+
+ private String commandId;
+
private String validManagerId;
- private String messageId;
+ private String dataId1;
- private String dataId;
+ private String dataId2;
/**
- * 1.action and actionListener defined as component attributes and actionListener
+ * action and actionListener defined as component attributes and actionListener
* defined as nested tag are invoked on the server after event of attached
* to component occurs, navigation occurs
*/
@Test
- public void testAjaxSupportComponent(Template template) {
- checkBasicFunctionality(template);
+ public void testDefaultBehaviour(Template template) {
+ setTestUrl(DEFAULT_BEHAVIOUR_PAGE);
+ init(template);
+ passExternalValidation();
+ checkBasicFunctionality(template, DEFAULT_BEHAVIOUR_ID_PREFIX, true);
}
+ /** component re-renders another component (h:outputText) */
+ @Test
+ public void testRerenderFunctionality(Template template) {
+ setTestUrl(RERENDER_ATTRIBUTE_PAGE);
+ init(template);
+ passExternalValidation();
+ checkBasicFunctionality(template, RERENDER_ATTRIBUTE_ID_PREFIX, true);
+ }
+
/**
- * @see #testAjaxSupportComponent(Template template)
+ * @see #testDefaultBehaviour(Template template)
*
* the same for the case of external validation
* failure - listeners and navigation do not work
*/
@Test
public void testValidationFailed(Template template) {
+ setTestUrl(VALIDATION_FAILED_PAGE);
init(template);
-
- setValueById(validManagerId, "");
-
- clickById(linkId);
- waitForAjaxCompletion();
- String data = getTextById(dataId);
- if (!A4JSupport.Messages.NO_DATA.equals(data)) {
- Assert.fail();
- }
-
- clickById(linkId + ALISTENER_PREFIX);
- waitForAjaxCompletion();
- data = getTextById(dataId);
- if (!A4JSupport.Messages.NO_DATA.equals(data)) {
- Assert.fail();
- }
+ breakExternalValidation();
+ checkBasicFunctionality(template, VALIDATION_FAILED_ID_PREFIX, false);
}
+ /**
+ * @see #testDefaultBehaviour(Template template)
+ *
+ * the same for immediate = true component
+ */
+ @Test
+ public void testImmediateAttribute1(Template template) {
+ setTestUrl(IMMEDIATE_ATTRIBUTE1_PAGE);
+ init(template);
+ passExternalValidation();
+ checkBasicFunctionality(template, IMMEDIATE_ATTRIBUTE1_ID_PREFIX, true);
+ }
- private void checkBasicFunctionality(Template template) {
+ /**
+ * @see #testDefaultBehaviour(Template template)
+ *
+ * the same for immediate = true component for
+ * the case of external validation failure
+ */
+ @Test
+ public void testImmediateAttribute2(Template template) {
+ setTestUrl(IMMEDIATE_ATTRIBUTE2_PAGE);
init(template);
-
- String data = checkInputComponent();
- checkRequestDelayAttribute(data);
- checkCommandComponent();
+ breakExternalValidation();
+ checkBasicFunctionality(template, IMMEDIATE_ATTRIBUTE2_ID_PREFIX, true);
}
- private void checkCommandComponent() {
- setValueById(validManagerId, "1");
+ /**
+ * @see #testDefaultBehaviour()
+ *
+ * the same for ajaxSingle = true component
+ */
+ @Test
+ public void testAjaxSingleAttribute1(Template template) {
+ setTestUrl(AJAXSINGLE_ATTRIBUTE1_PAGE);
+ init(template);
+ passExternalValidation();
+ checkBasicFunctionality(template, AJAXSINGLE_ATTRIBUTE1_ID_PREFIX, true);
+ }
+
+ /**
+ * @see #testDefaultBehaviour()
+ *
+ * the same for ajaxSingle = true component for the case
+ * of external validation failure
+ */
+ @Test
+ public void testAjaxSingleAttribute2(Template template) {
+ setTestUrl(AJAXSINGLE_ATTRIBUTE2_PAGE);
+ init(template);
+ breakExternalValidation();
+ checkBasicFunctionality(template, AJAXSINGLE_ATTRIBUTE2_ID_PREFIX, true);
+ }
+
+// /**
+// * component encodes nested f:param tags and their values are present as request
parameters
+// */
+// @Test
+// public void testFParamTag() {
+//
+// }
+//
+// /** component with bypassUpdates = true skips update model values phase */
+// @Test
+// public void testByPassAttribute() {
+//
+// }
+//
+//
+//
+// /** component with limitToList = true skips ajaxRendered areas update */
+// @Test
+// public void testLimitToListAttribute() {
+//
+// }
+//
+// /** component with rendered = false is not present on the page */
+// @Test
+// public void testRenderedAttribute() {
+//
+// }
+//
+// /**
+// * onsubmit event fires on component activation then
+// * oncomplete with proper request data
+// */
+// @Test
+// public void testOnSubmitEvent1() {
+//
+// }
+// /** component with enabled = false do not fire ajax requests */
+// @Test
+// public void testEnabledAttribute(Template template) {
+// setTestUrl(ENABLED_ATTRIBUTE_PAGE);
+// init(template);
+// passExternalValidation();
+// checkBasicFunctionality(template, ENABLED_ATTRIBUTE_ID_PREFIX, false);
+// }
+
+// /**
+// * @see #testAjaxSupportComponent()
+// *
+// * the same for ajaxSingle = true component for the case
+// * of external validation failure + process for validation failed
+// * field - listeners and navigation do not work
+// */
+// @Test
+// public void testAjaxSingleAttribute3() {
+//
+// }
+
+ private void checkBasicFunctionality(Template template, String casePrefix, boolean
isDataAvailable) {
+ processingElement(linkId + casePrefix, dataId1 + casePrefix, isDataAvailable);
+ processingElement(linkId + COMMON_ALISTENER_PREFIX + casePrefix, dataId1 +
COMMON_ALISTENER_PREFIX + casePrefix, isDataAvailable);
+
+ processingElement(checkboxId + casePrefix, dataId2 + casePrefix, isDataAvailable);
+ processingElement(checkboxId + COMMON_ALISTENER_PREFIX + casePrefix, dataId2 +
COMMON_ALISTENER_PREFIX + casePrefix, isDataAvailable);
+ }
+
+ private void processingElement(String linkId, String dataId,
+ boolean isValidationFailed) {
clickById(linkId);
waitForAjaxCompletion();
String data = getTextById(dataId);
- checkMessage(data, A4JSupport.Messages.FOR_LINK,
- "'onclick' ajax support for link[id='_form:link'] failed.",
- A4JSupport.Messages.FOR_LINK + " successful");
-
- clickById(linkId + ALISTENER_PREFIX);
- waitForAjaxCompletion();
- data = getTextById(dataId);
- checkMessage(data, A4JSupport.Messages.FOR_LINK,
- "'onclick' ajax support for link[id='_form:linkAL']
failed.",
- A4JSupport.Messages.FOR_LINK + " successful");
+ checkMessage(data, A4JSupport.Messages.TEST_PASSED,
+ CommonUtils.getFailedTestMessage(linkId),
+ CommonUtils.getSuccessfulTestMessage(linkId),
+ isValidationFailed);
}
- private String checkInputComponent() {
+ private void breakExternalValidation() {
+ setValueById(validManagerId, "");
+ }
+
+ private void passExternalValidation() {
setValueById(validManagerId, "1");
- String checkBoxId = parentFormId + "checkbox";
-
- clickById(checkBoxId);
- waitForAjaxCompletion();
- String data = getTextById(dataId);
- checkMessage(data, A4JSupport.Messages.FOR_CHECKBOX,
- "'onchange' ajax support for
checkbox[id='_form:checkbox'] failed.", A4JSupport.Messages.FOR_CHECKBOX
- + " successful");
-
- clickById(checkBoxId + ALISTENER_PREFIX);
- waitForAjaxCompletion();
- data = getTextById(dataId);
- checkMessage(data, A4JSupport.Messages.FOR_CHECKBOX,
- "'onchange' ajax support for
checkbox[id='_form:checkboxAL'] failed.", A4JSupport.Messages.FOR_CHECKBOX
- + " successful");
- return data;
}
- private void checkRequestDelayAttribute(String data) {
- setValueById(validManagerId, "1");
- String command = parentFormId + "command";
-
- clickById(command);
- pause(1000, command);
- if (!data.equals(getTextById(dataId))) {
- writeStatus("<a4j:support failed. 'requestDelay' attribute
does not work.");
- Assert.fail("<a4j:support failed. 'requestDelay' attribute
does not work.");
- }
+ /*private void checkRequestDelayAttribute(String data, String casePrefix) {
+ String comId = commandId + casePrefix;
+ clickById(comId);
+ pause(1000, comId);
+
+// if (!data.equals(getTextById(dataId))) {
+// writeStatus("<a4j:support failed. 'requestDelay' attribute
does not work.");
+// Assert.fail("<a4j:support failed. 'requestDelay' attribute
does not work.");
+// }
waitForAjaxCompletion();
data = getTextById(dataId);
checkMessage(data, A4JSupport.Messages.FOR_COMMAND,
- "'onclick' ajax support for command
link[id='_form:command'] failed.", A4JSupport.Messages.FOR_COMMAND
- + " successful");
+ CommonUtils.getFailedTestMessage(comId),
CommonUtils.getSuccessfulTestMessage(comId));
if (A4JSupport.Messages.FOR_SUBMIT.equals(data)) {
writeStatus("<a4j:support failed. 'disableDefault' attribute
does not work");
Assert.fail("<a4j:support failed. 'disableDefault' attribute
does not work.");
}
- }
+ }*/
- private void checkMessage(String data, String message, String errorMessage, String
okMessage) {
- if (message.equals(data)) {
- writeStatus(okMessage);
- } else if (A4JSupport.Messages.NO_DATA.equals(data)) {
- writeStatus(errorMessage + " Caused by: action listener for
<a4j:support> skipped", true);
- Assert.fail(errorMessage + " Caused by: action listener for
<a4j:support> skipped");
- } else if ("".equals(data)) {
- writeStatus(errorMessage + "Caused by: no ajax request has been
sent.", true);
- Assert.fail(errorMessage + "Caused by: no ajax request has been
sent.");
- }
+ private void checkMessage(String data, String message, String errorMessage, String
okMessage, boolean isDataAvailable) {
+ if (!isDataAvailable) {
+ if (!A4JSupport.Messages.NO_DATA.equals(data)) {
+ writeStatus(errorMessage, true);
+ Assert.fail(errorMessage);
+ } else {
+ writeStatus(okMessage);
+ }
+ } else {
+ if (message.equals(data)) {
+ writeStatus(okMessage);
+ } else {
+ writeStatus(errorMessage, true);
+ Assert.fail(errorMessage);
+ }
+ }
}
private void init(Template template) {
@@ -152,14 +286,20 @@
private void initIds() {
parentFormId = getParentId() + "_form:";
linkId = parentFormId + "link";
+ checkboxId = parentFormId + "checkbox";
+ commandId = parentFormId + "command";
validManagerId = parentFormId + "validManager";
- messageId = getParentId() + "message";
- dataId = parentFormId + "data";
+ dataId1 = parentFormId + "data1";
+ dataId2 = parentFormId + "data2";
}
@Override
public String getTestUrl() {
- return "pages/ajaxSupport/ajaxSupport.xhtml";
+ return testUrl;
}
+
+ public void setTestUrl(String testUrl) {
+ this.testUrl = "pages/ajaxSupport/" + testUrl;
+ }
}
Added:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/CommonUtils.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/CommonUtils.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/CommonUtils.java 2008-10-10
20:14:24 UTC (rev 10724)
@@ -0,0 +1,16 @@
+package org.richfaces.testng.util;
+
+public class CommonUtils {
+
+ public static String getFailedTestMessage(String targetId) {
+ return getFinishedTestMessage(targetId) + "failed.";
+ }
+
+ public static String getSuccessfulTestMessage(String targetId) {
+ return getFinishedTestMessage(targetId) + "successful.";
+ }
+
+ private static String getFinishedTestMessage(String targetId) {
+ return "test for element [id= " + targetId + "] ";
+ }
+}