Author: dsvyatobatsko
Date: 2009-01-13 13:45:49 -0500 (Tue, 13 Jan 2009)
New Revision: 12259
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tabPanel/tabPanelAutoTest.xhtml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TabPanelTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5561
https://jira.jboss.org/jira/browse/RF-5562
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java 2009-01-13
18:21:41 UTC (rev 12258)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java 2009-01-13
18:45:49 UTC (rev 12259)
@@ -27,237 +27,241 @@
import javax.faces.event.ActionEvent;
public class RichPanelTestBean {
- private String value;
+ private String value;
- private int value2;
+ private int value2;
- private Object panelValue;
+ private Object panelValue;
- private Object panelValue2;
+ private Object panelValue2;
- private String itemAction;
+ private String itemAction;
- private boolean rendered;
+ private boolean rendered;
- private String content;
+ private String content;
- private String switchType = "server";
+ private String switchType = "server";
- private String selectedTab = "tab1";
+ private String selectedTab = "tab1";
- private Map<String, String> inputs = new HashMap<String, String>();
+ private Map<String, String> inputs = new HashMap<String, String>();
- public RichPanelTestBean() {
- value = "";
- value2 = 0;
- rendered = true;
- content = "content";
- }
+ public RichPanelTestBean() {
+ value = "";
+ value2 = 0;
+ rendered = true;
+ content = "content";
+ }
- public void reset() {
- value = "";
- value2 = 0;
- rendered = true;
- content = "content";
- selectedTab = "tab1";
- }
+ public void reset() {
+ value = "";
+ value2 = 0;
+ rendered = true;
+ content = "content";
+ selectedTab = "tab1";
+ }
- public void reset(ActionEvent event) {
- reset();
- }
+ public void initAjaxCoreTest() {
+ selectedTab = "tab1";
+ }
- /**
- * Gets value of switchType field.
- *
- * @return value of switchType field
- */
- public String getSwitchType() {
- return switchType;
- }
+ public void reset(ActionEvent event) {
+ reset();
+ }
- /**
- * Set a new value for switchType field.
- *
- * @param switchType
- * a new value for switchType field
- */
- public void setSwitchType(String switchType) {
- this.switchType = switchType;
- }
+ /**
+ * Gets value of switchType field.
+ *
+ * @return value of switchType field
+ */
+ public String getSwitchType() {
+ return switchType;
+ }
- public String getValue() {
- return value;
- }
+ /**
+ * Set a new value for switchType field.
+ *
+ * @param switchType
+ * a new value for switchType field
+ */
+ public void setSwitchType(String switchType) {
+ this.switchType = switchType;
+ }
- public void setValue(String value) {
- this.value = value;
- }
+ public String getValue() {
+ return value;
+ }
- public int getValue2() {
- return value2;
- }
+ public void setValue(String value) {
+ this.value = value;
+ }
- public void setValue2(int value2) {
- this.value2 = value2;
- }
+ public int getValue2() {
+ return value2;
+ }
- public Object getPanelValue() {
- return panelValue;
- }
+ public void setValue2(int value2) {
+ this.value2 = value2;
+ }
- public void setPanelValue(Object panelValue) {
- this.panelValue = panelValue;
- }
+ public Object getPanelValue() {
+ return panelValue;
+ }
- public Object getPanelValue2() {
- return panelValue2;
- }
+ public void setPanelValue(Object panelValue) {
+ this.panelValue = panelValue;
+ }
- public void setPanelValue2(Object panelValue2) {
- this.panelValue2 = panelValue2;
- }
+ public Object getPanelValue2() {
+ return panelValue2;
+ }
- /**
- * Gets value of content field.
- *
- * @return value of content field
- */
- public String getContent() {
- return content;
- }
+ public void setPanelValue2(Object panelValue2) {
+ this.panelValue2 = panelValue2;
+ }
- /**
- * Set a new value for content field.
- *
- * @param content
- * a new value for content field
- */
- public void setContent(String content) {
- this.content = content;
- }
+ /**
+ * Gets value of content field.
+ *
+ * @return value of content field
+ */
+ public String getContent() {
+ return content;
+ }
- /**
- * Gets value of itemAction field.
- *
- * @return value of itemAction field
- */
- public String getItemAction() {
- return itemAction;
- }
+ /**
+ * Set a new value for content field.
+ *
+ * @param content
+ * a new value for content field
+ */
+ public void setContent(String content) {
+ this.content = content;
+ }
- /**
- * Set a new value for itemAction field.
- *
- * @param itemAction
- * a new value for itemAction field
- */
- public void setItemAction(String itemAction) {
- this.itemAction = itemAction;
- }
+ /**
+ * Gets value of itemAction field.
+ *
+ * @return value of itemAction field
+ */
+ public String getItemAction() {
+ return itemAction;
+ }
- /**
- * Gets value of rendered field.
- *
- * @return value of rendered field
- */
- public boolean isRendered() {
- return rendered;
- }
+ /**
+ * Set a new value for itemAction field.
+ *
+ * @param itemAction
+ * a new value for itemAction field
+ */
+ public void setItemAction(String itemAction) {
+ this.itemAction = itemAction;
+ }
- /**
- * Set a new value for rendered field.
- *
- * @param rendered
- * a new value for rendered field
- */
- public void setRendered(boolean rendered) {
- this.rendered = rendered;
- }
+ /**
+ * Gets value of rendered field.
+ *
+ * @return value of rendered field
+ */
+ public boolean isRendered() {
+ return rendered;
+ }
- public void actionListener(ActionEvent event) {
- this.value = event.getComponent().getId();
- }
+ /**
+ * Set a new value for rendered field.
+ *
+ * @param rendered
+ * a new value for rendered field
+ */
+ public void setRendered(boolean rendered) {
+ this.rendered = rendered;
+ }
- public void itemActionServer() {
- setItemAction("server");
- }
+ public void actionListener(ActionEvent event) {
+ this.value = event.getComponent().getId();
+ }
- public void itemActionAjax() {
- setItemAction("ajax");
- }
+ public void itemActionServer() {
+ setItemAction("server");
+ }
- public void itemActionNone() {
- setItemAction("NOT none");
- }
+ public void itemActionAjax() {
+ setItemAction("ajax");
+ }
- public String increment() {
- if (4 == this.value2) {
- this.value2 = 0;
- }
- this.value2++;
- return null;
- }
+ public void itemActionNone() {
+ setItemAction("NOT none");
+ }
- public void hide() {
- rendered = false;
- }
+ public String increment() {
+ if (4 == this.value2) {
+ this.value2 = 0;
+ }
+ this.value2++;
+ return null;
+ }
- public void reset2Server() {
- cleanValues();
- content = "";
- switchType = "server";
- }
+ public void hide() {
+ rendered = false;
+ }
- public void reset2Ajax() {
- cleanValues();
- content = "";
- switchType = "ajax";
- }
+ public void reset2Server() {
+ cleanValues();
+ content = "";
+ switchType = "server";
+ }
- public void reset2Client() {
- cleanValues();
- content = "";
- switchType = "client";
- }
+ public void reset2Ajax() {
+ cleanValues();
+ content = "";
+ switchType = "ajax";
+ }
- public void cleanValues() {
- value = "";
- value2 = 0;
- panelValue = null;
- panelValue2 = null;
- itemAction = "";
- rendered = true;
- content = "content";
- }
+ public void reset2Client() {
+ cleanValues();
+ content = "";
+ switchType = "client";
+ }
- /**
- * @return the selectedTab
- */
- public String getSelectedTab() {
- return selectedTab;
- }
+ public void cleanValues() {
+ value = "";
+ value2 = 0;
+ panelValue = null;
+ panelValue2 = null;
+ itemAction = "";
+ rendered = true;
+ content = "content";
+ }
- /**
- * @param selectedTab
- * the selectedTab to set
- */
- public void setSelectedTab(String selectedTab) {
- this.selectedTab = selectedTab;
- }
+ /**
+ * @return the selectedTab
+ */
+ public String getSelectedTab() {
+ return selectedTab;
+ }
- /**
- * @return the inputs
- */
- public Map<String, String> getInputs() {
- return inputs;
- }
+ /**
+ * @param selectedTab
+ * the selectedTab to set
+ */
+ public void setSelectedTab(String selectedTab) {
+ this.selectedTab = selectedTab;
+ }
- /**
- * @param inputs
- * the inputs to set
- */
- public void setInputs(Map<String, String> inputs) {
- this.inputs = inputs;
- }
+ /**
+ * @return the inputs
+ */
+ public Map<String, String> getInputs() {
+ return inputs;
+ }
+ /**
+ * @param inputs
+ * the inputs to set
+ */
+ public void setInputs(Map<String, String> inputs) {
+ this.inputs = inputs;
+ }
+
}
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tabPanel/tabPanelAutoTest.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tabPanel/tabPanelAutoTest.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TabPanelTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TabPanelTest.java 2009-01-13
18:21:41 UTC (rev 12258)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TabPanelTest.java 2009-01-13
18:45:49 UTC (rev 12259)
@@ -20,158 +20,195 @@
*/
package org.richfaces.testng;
+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;
-import com.thoughtworks.selenium.SeleniumException;
-
public class TabPanelTest extends SeleniumTestBase {
- static final String FORM_ID = "_form:";
-
- static final String RESET_METHOD = "#{panelBean.reset}";
+ private static final String FORM_ID = "_form:";
- @Test
- public void testRichTabPanelComponent(Template template) {
- renderPage(template, RESET_METHOD);
- String parentId = getParentId() + FORM_ID;
- String linkId = parentId + "tab2_lbl";
- String tabId1 = parentId + "tab1";
- String tabId2 = parentId + "tab2";
- String tabId4 = parentId + "tab4";
+ private static final String RESET_METHOD = "#{panelBean.reset}";
- writeStatus("Click on tab2");
- clickById(linkId);
- waitForAjaxCompletion();
- AssertTextEquals(tabId2, "Tab two");
- AssertVisible(tabId2);
- AssertNotVisible(tabId4);
+ private final static String INIT_AJAX_CORE_TEST =
"#{panelBean.initAjaxCoreTest}";
- writeStatus("Click on tab1");
- linkId = parentId + "tab1_lbl";
- clickCommandAndWait(linkId);
- AssertTextEquals(tabId1, "Tab one");
- AssertVisible(tabId1);
- AssertNotVisible(tabId4);
+ private static Map<String, String> params = new HashMap<String,
String>();
- writeStatus("Click on tab3");
- linkId = parentId + "tab3_lbl";
- clickById(linkId);
- AssertVisible(tabId1);
+ static {
+ params.put("parameter1", "value1");
+ params.put("parameter2", "value2");
+ params.put("parameter3", "value3");
+ }
- writeStatus("Click on tab4");
- linkId = parentId + "tab4_lbl";
- clickById(linkId);
- AssertVisible(tabId4);
- AssertNotVisible(tabId1);
- }
+ @Test
+ public void testRichTabPanelComponent(Template template) {
+ renderPage(template, RESET_METHOD);
+ String parentId = getParentId() + FORM_ID;
+ String linkId = parentId + "tab2_lbl";
+ String tabId1 = parentId + "tab1";
+ String tabId2 = parentId + "tab2";
+ String tabId4 = parentId + "tab4";
- @Test
- public void testSubmissionModesAndListeners(Template template) {
- renderPage(template, RESET_METHOD);
+ writeStatus("Click on tab2");
+ clickById(linkId);
+ waitForAjaxCompletion();
+ AssertTextEquals(tabId2, "Tab two");
+ AssertVisible(tabId2);
+ AssertNotVisible(tabId4);
- String parentId = getParentId();
+ writeStatus("Click on tab1");
+ linkId = parentId + "tab1_lbl";
+ clickCommandAndWait(linkId);
+ AssertTextEquals(tabId1, "Tab one");
+ AssertVisible(tabId1);
+ AssertNotVisible(tabId4);
- testListener(parentId);
- testSubmissionModes(parentId);
-
- }
-
- private void testListener (String parentId) {
-
- String linkId = parentId + FORM_ID + "tab2_lbl";
- String inputId = parentId + FORM_ID + "_value";
-
- writeStatus("Click on tab2");
- clickById(linkId);
- waitForAjaxCompletion();
- AssertTextEquals(inputId, "tab2", "Listener for the second tab [ajax
mode] has not been called");
+ writeStatus("Click on tab3");
+ linkId = parentId + "tab3_lbl";
+ clickById(linkId);
+ AssertVisible(tabId1);
- writeStatus("Click on tab1");
- linkId = parentId + FORM_ID + "tab1_lbl";
- clickCommandAndWait(linkId);
- AssertTextEquals(inputId, "tab1", "Listener for the first tab [server
mode] has not been called");
- }
-
-
- private void testSubmissionModes(String parentId) {
- String tabId1 = parentId + FORM_ID + "tab1";
- String tabId2 = parentId + FORM_ID + "tab2";
- String tabId4 = parentId + FORM_ID + "tab4";
-
- reset(parentId);
-
- // Set input for the first tab
- setValueById(tabId1 + "_input", "text1");
- clickById(tabId2 + "_lbl");
- waitForAjaxCompletion();
- checkDecodes(parentId, "text1", "", "");
-
-
- // Set input for the second and 4th tabs
- setValueById(tabId2 + "_input", "text2");
- setValueById(tabId4 + "_input", "text4");
- clickById(tabId1 + "_lbl");
- waitForPageToLoad();
- checkDecodes(parentId, "text1", "text2", "text4");
-
- // Reset model. Swtich to tyhe first tab
- reset(parentId);
-
- // Switch to 4th tab
- clickById(tabId4 + "_lbl");
- setValueById(tabId4 + "_input", "text");
- submit(parentId);
- AssertVisible(tabId4, "Tab4 (client) should be kept as active after form
submition");
- checkDecodes(parentId, "", "", "text");
-
-
- // Switch to 2nd tab
- clickById(tabId2 + "_lbl");
- waitForAjaxCompletion();
- setValueById(tabId4 + "_input", "text4");
- setValueById(tabId2 + "_input", "text2");
- ajaxSubmit(parentId);
- checkDecodes(parentId, "", "text2", "text4");
-
+ writeStatus("Click on tab4");
+ linkId = parentId + "tab4_lbl";
+ clickById(linkId);
+ AssertVisible(tabId4);
+ AssertNotVisible(tabId1);
+ }
- }
-
- private void checkDecodes(String parentId, String input1, String input2, String input4)
{
- String inputsId = parentId + FORM_ID + "_inputs";
- String inputs = getTextById(inputsId);
-
- if (!inputs.contains("tab1=" + input1)) {
- Assert.fail("Decode or update model for the first tab processed incorrect. The
model should contain ['"+input1+"'] value submitted from the
tab");
- }
- if (!inputs.contains("tab2=" + input2)) {
- Assert.fail("Decode or update model for the second tab processed incorrect. The
model should contain ['"+input2+"'] value submitted from the
tab");
- }
- if (!inputs.contains("tab4=" + input4)) {
- Assert.fail("Decode or update model for the 4th tab processed incorrect. The
model should contain ['"+input4+"'] value submitted from the
tab");
- }
- }
-
- private void submit(String parentId) {
- String commandId = parentId + FORM_ID + "submit";
- clickCommandAndWait(commandId);
- }
-
- private void ajaxSubmit(String parentId) {
- String commandId = parentId + FORM_ID + "ajaxSubmit";
- clickAjaxCommandAndWait(commandId);
- }
-
- private void reset(String parentId) {
- String commandId = parentId + "controls:reset";
- clickCommandAndWait(commandId);
- }
+ @Test
+ public void testNestedParams(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, INIT_AJAX_CORE_TEST);
+ writeStatus("Test component encodes nested f:param tags and their values are
present as request parameters");
+ tester.testRequestParameters(params);
+ }
- @Override
- public String getTestUrl() {
- return "pages/tabPanel/tabPanelTest.xhtml";
- }
+ @Test
+ public void testReRenderAttribute(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, INIT_AJAX_CORE_TEST);
+ writeStatus("Test component re-renders another components");
+ tester.testReRender();
+ }
+ @Test
+ public void testSubmissionModesAndListeners(Template template) {
+ renderPage(template, RESET_METHOD);
+
+ String parentId = getParentId();
+
+ testListener(parentId);
+ testSubmissionModes(parentId);
+
+ }
+
+ private void testListener(String parentId) {
+
+ String linkId = parentId + FORM_ID + "tab2_lbl";
+ String inputId = parentId + FORM_ID + "_value";
+
+ writeStatus("Click on tab2");
+ clickById(linkId);
+ waitForAjaxCompletion();
+ AssertTextEquals(inputId, "tab2", "Listener for the second tab
[ajax mode] has not been called");
+
+ writeStatus("Click on tab1");
+ linkId = parentId + FORM_ID + "tab1_lbl";
+ clickCommandAndWait(linkId);
+ AssertTextEquals(inputId, "tab1", "Listener for the first tab
[server mode] has not been called");
+ }
+
+ private void testSubmissionModes(String parentId) {
+ String tabId1 = parentId + FORM_ID + "tab1";
+ String tabId2 = parentId + FORM_ID + "tab2";
+ String tabId4 = parentId + FORM_ID + "tab4";
+
+ reset(parentId);
+
+ // Set input for the first tab
+ setValueById(tabId1 + "_input", "text1");
+ clickById(tabId2 + "_lbl");
+ waitForAjaxCompletion();
+ checkDecodes(parentId, "text1", "", "");
+
+ // Set input for the second and 4th tabs
+ setValueById(tabId2 + "_input", "text2");
+ setValueById(tabId4 + "_input", "text4");
+ clickById(tabId1 + "_lbl");
+ waitForPageToLoad();
+ checkDecodes(parentId, "text1", "text2", "text4");
+
+ // Reset model. Swtich to tyhe first tab
+ reset(parentId);
+
+ // Switch to 4th tab
+ clickById(tabId4 + "_lbl");
+ setValueById(tabId4 + "_input", "text");
+ submit(parentId);
+ AssertVisible(tabId4, "Tab4 (client) should be kept as active after form
submition");
+ checkDecodes(parentId, "", "", "text");
+
+ // Switch to 2nd tab
+ clickById(tabId2 + "_lbl");
+ waitForAjaxCompletion();
+ setValueById(tabId4 + "_input", "text4");
+ setValueById(tabId2 + "_input", "text2");
+ ajaxSubmit(parentId);
+ checkDecodes(parentId, "", "text2", "text4");
+
+ }
+
+ private void checkDecodes(String parentId, String input1, String input2, String
input4) {
+ String inputsId = parentId + FORM_ID + "_inputs";
+ String inputs = getTextById(inputsId);
+
+ if (!inputs.contains("tab1=" + input1)) {
+ Assert.fail("Decode or update model for the first tab processed
incorrect. The model should contain ['"
+ + input1 + "'] value submitted from the tab");
+ }
+ if (!inputs.contains("tab2=" + input2)) {
+ Assert.fail("Decode or update model for the second tab processed
incorrect. The model should contain ['"
+ + input2 + "'] value submitted from the tab");
+ }
+ if (!inputs.contains("tab4=" + input4)) {
+ Assert.fail("Decode or update model for the 4th tab processed incorrect.
The model should contain ['"
+ + input4 + "'] value submitted from the tab");
+ }
+ }
+
+ private void submit(String parentId) {
+ String commandId = parentId + FORM_ID + "submit";
+ clickCommandAndWait(commandId);
+ }
+
+ private void ajaxSubmit(String parentId) {
+ String commandId = parentId + FORM_ID + "ajaxSubmit";
+ clickAjaxCommandAndWait(commandId);
+ }
+
+ private void reset(String parentId) {
+ String commandId = parentId + "controls:reset";
+ clickCommandAndWait(commandId);
+ }
+
+ @Override
+ public void sendAjax() {
+ clickAjaxCommandAndWait(getAutoTester(this).getClientId("") +
"tab2_lbl");
+ }
+
+ @Override
+ public String getAutoTestUrl() {
+ return "pages/tabPanel/tabPanelAutoTest.xhtml";
+ }
+
+ @Override
+ public String getTestUrl() {
+ return "pages/tabPanel/tabPanelTest.xhtml";
+ }
+
}