Author: lfryc(a)redhat.com
Date: 2011-02-05 09:49:51 -0500 (Sat, 05 Feb 2011)
New Revision: 21479
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/PollAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPollInterval.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPollSimple.java
Removed:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/IntervalAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestInterval.java
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JPollBean.java
Log:
a4j:poll - covered all remaining attributes (RFPL-1064)
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JPollBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JPollBean.java 2011-02-05
14:48:44 UTC (rev 21478)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JPollBean.java 2011-02-05
14:49:51 UTC (rev 21479)
@@ -26,10 +26,10 @@
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
-import javax.faces.bean.SessionScoped;
+import javax.faces.bean.ViewScoped;
import javax.faces.event.ActionEvent;
+
import org.richfaces.component.UIPoll;
-
import org.richfaces.tests.metamer.Attributes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,7 +41,7 @@
* @version $Revision$
*/
@ManagedBean(name = "a4jPollBean")
-@SessionScoped
+@ViewScoped
public class A4JPollBean implements Serializable {
private static final long serialVersionUID = 4810889475400649809L;
Deleted:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/IntervalAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/IntervalAttributes.java 2011-02-05
14:48:44 UTC (rev 21478)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/IntervalAttributes.java 2011-02-05
14:49:51 UTC (rev 21479)
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- *******************************************************************************/
-package org.richfaces.tests.metamer.ftest.a4jPoll;
-
-import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
-
-/**
- * Tests the a4j:poll component.
- *
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-public class IntervalAttributes extends AbstractComponentAttributes {
- public void setEnabled(boolean enabled) {
- setProperty("enabled", enabled);
- }
-
- public void setInterval(long interval) {
- setProperty("interval", interval);
- }
-}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/PollAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/PollAttributes.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/PollAttributes.java 2011-02-05
14:49:51 UTC (rev 21479)
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.a4jPoll;
+
+import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
+
+/**
+ * Tests the a4j:poll component.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class PollAttributes extends AbstractComponentAttributes {
+ public void setEnabled(boolean enabled) {
+ setProperty("enabled", enabled);
+ }
+
+ public void setInterval(long interval) {
+ setProperty("interval", interval);
+ }
+
+ public void setAction(String action) {
+ setProperty("action", action);
+ }
+
+ public void setActionListener(String actionListener) {
+ setProperty("actionListener", actionListener);
+ }
+
+ public void setBypassUpdates(Boolean bypassUpdates) {
+ setProperty("bypassUpdates", bypassUpdates);
+ }
+
+ public void setData(String data) {
+ setProperty("data", data);
+ }
+
+ public void setExecute(String execute) {
+ setProperty("execute", execute);
+ }
+
+ public void setImmediate(Boolean immediate) {
+ setProperty("immediate", immediate);
+ }
+
+ public void setInterval(Integer interval) {
+ setProperty("interval", interval);
+ }
+
+ public void setLimitRender(Boolean limitRender) {
+ setProperty("limitRender", limitRender);
+ }
+
+ public void setRender(String render) {
+ setProperty("render", render);
+ }
+
+ public void setRendered(Boolean rendered) {
+ setProperty("rendered", rendered);
+ }
+
+ public void setStatus(String status) {
+ setProperty("status", status);
+ }
+}
Deleted:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestInterval.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestInterval.java 2011-02-05
14:48:44 UTC (rev 21478)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestInterval.java 2011-02-05
14:49:51 UTC (rev 21479)
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- *******************************************************************************/
-package org.richfaces.tests.metamer.ftest.a4jPoll;
-
-import java.io.IOException;
-import java.net.URL;
-
-import org.apache.commons.httpclient.HttpException;
-import org.jboss.test.selenium.locator.Attribute;
-import org.jboss.test.selenium.locator.AttributeLocator;
-import org.jboss.test.selenium.locator.JQueryLocator;
-import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.richfaces.tests.metamer.ftest.annotations.Inject;
-import org.richfaces.tests.metamer.ftest.annotations.Templates;
-import org.richfaces.tests.metamer.ftest.annotations.Use;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
-import static org.testng.Assert.*;
-import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
-import static org.jboss.test.selenium.utils.PrimitiveUtils.*;
-
-/**
- * Tests the a4j:poll component.
- *
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-public class TestInterval extends AbstractMetamerTest {
-
- private static final int ITERATION_COUNT = 5;
-
- @Inject
- int interval;
-
- IntervalAttributes attributes = new IntervalAttributes();
-
- JQueryLocator time = pjq("span[id$=time]");
- AttributeLocator<?> clientTime =
pjq("span[id$=event1:outputTime]").getAttribute(Attribute.TITLE);
-
- long startTime;
-
- long deviationTotal = 0;
- long deviationCount = 0;
-
- @Override
- public URL getTestUrl() {
- return buildUrl(contextPath,
"faces/components/a4jPoll/simple.xhtml?enabled=false");
- }
-
- @BeforeMethod
- public void resetDeviations() {
- deviationTotal = 0;
- deviationCount = 0;
- }
-
- @Test
- @Use(field = "interval", ints = { 1000 })
- public void testClientAllTemplates() throws HttpException, IOException {
- testClient();
- }
-
- @Test
- @Use(field = "interval", ints = { 500, 5000 })
- @Templates(value = "plain")
- public void testClientDifferentIntervals() throws HttpException, IOException {
- testClient();
- }
-
- /**
- * <p>
- * Test the progress of polling for 3 different values from client side.
- * </p>
- *
- * <p>
- * It defines the new interval value first for each iteration and then enable
polling.
- * </p>
- *
- * <p>
- * Then, it waits for first poll event (zero iteration).
- * </p>
- *
- * <p>
- * For 5 following poll events it checks that runtime visible from client (output
from JavaScript's new
- * Date().getTime()) between the events haven't greater deviation from defined
interval than defined
- * {@link #MAX_DEVIATION}.
- * </p>
- *
- * <p>
- * Test also computes average value of deviation and checks that the average value of
all obtained particular
- * deviations isn't greater than {@link #MAX_AVERAGE_DEVIATION}.
- * </p>
- */
- public void testClient() {
- attributes.setEnabled(true);
- attributes.setInterval(interval);
-
- waitForPoll();
- for (int i = 0; i < ITERATION_COUNT; i++) {
- startInterval();
- waitForPoll();
- validateInterval();
- }
-
- validateAverageDeviation();
- }
-
- private void startInterval() {
- startTime = System.currentTimeMillis();
- }
-
- private void waitForPoll() {
- selenium.getPageExtensions().install();
- selenium.getRequestInterceptor().clearRequestTypeDone();
- selenium.getRequestInterceptor().waitForRequestTypeChange();
- }
-
- private void validateInterval() {
- long runTime = getClientTime() - startTime;
- long deviation = Math.abs(interval - runTime);
-
- if (seleniumDebug) {
- System.out.println(format("deviation for interval {0}: {1}",
interval, deviation));
- }
-
- assertTrue(deviation <= (2 * interval),
- format("Deviation ({0}) is greater than two intervals (2 * {1})",
deviation, interval));
-
- deviationTotal += deviation;
- deviationCount += 1;
- }
-
- private void validateAverageDeviation() {
- long maximumAvgDeviation = Math.min(interval / 3, 1000);
- long averageDeviation = deviationTotal / deviationCount;
-
- if (seleniumDebug) {
- System.out.println("averageDeviation: " + averageDeviation);
- }
- assertTrue(
- averageDeviation <= maximumAvgDeviation,
- format("Average deviation for all the intervals ({0}) should not be
greater than defined maximum {1}",
- averageDeviation, maximumAvgDeviation));
- }
-
- /**
- * Returns the time of poll event (the time when arrived the response from server)
- *
- * @return the time of poll event (the time when arrived the response from server)
- */
- private long getClientTime() {
- return asLong(selenium.getAttribute(clientTime));
- }
-}
Copied:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPollInterval.java
(from rev 21478,
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestInterval.java)
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPollInterval.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPollInterval.java 2011-02-05
14:49:51 UTC (rev 21479)
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.a4jPoll;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.commons.httpclient.HttpException;
+import org.jboss.test.selenium.locator.Attribute;
+import org.jboss.test.selenium.locator.AttributeLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.annotations.Inject;
+import org.richfaces.tests.metamer.ftest.annotations.Templates;
+import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.*;
+import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
+import static org.jboss.test.selenium.utils.PrimitiveUtils.*;
+
+/**
+ * Tests the a4j:poll component.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestPollInterval extends AbstractMetamerTest {
+
+ private static final int ITERATION_COUNT = 5;
+
+ @Inject
+ int interval;
+
+ PollAttributes attributes = new PollAttributes();
+
+ JQueryLocator time = pjq("span[id$=time]");
+ AttributeLocator<?> clientTime =
pjq("span[id$=event1:outputTime]").getAttribute(Attribute.TITLE);
+
+ long startTime;
+
+ long deviationTotal = 0;
+ long deviationCount = 0;
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/a4jPoll/simple.xhtml?enabled=false");
+ }
+
+ @BeforeMethod
+ public void resetDeviations() {
+ deviationTotal = 0;
+ deviationCount = 0;
+ }
+
+ @Test
+ @Use(field = "interval", ints = { 1000 })
+ public void testClientAllTemplates() throws HttpException, IOException {
+ testClient();
+ }
+
+ @Test
+ @Use(field = "interval", ints = { 500, 5000 })
+ @Templates(value = "plain")
+ public void testClientDifferentIntervals() throws HttpException, IOException {
+ testClient();
+ }
+
+ /**
+ * <p>
+ * Test the progress of polling for 3 different values from client side.
+ * </p>
+ *
+ * <p>
+ * It defines the new interval value first for each iteration and then enable
polling.
+ * </p>
+ *
+ * <p>
+ * Then, it waits for first poll event (zero iteration).
+ * </p>
+ *
+ * <p>
+ * For 5 following poll events it checks that runtime visible from client (output
from JavaScript's new
+ * Date().getTime()) between the events haven't greater deviation from defined
interval than defined
+ * {@link #MAX_DEVIATION}.
+ * </p>
+ *
+ * <p>
+ * Test also computes average value of deviation and checks that the average value of
all obtained particular
+ * deviations isn't greater than {@link #MAX_AVERAGE_DEVIATION}.
+ * </p>
+ */
+ public void testClient() {
+ attributes.setEnabled(true);
+ attributes.setInterval(interval);
+
+ waitForPoll();
+ for (int i = 0; i < ITERATION_COUNT; i++) {
+ startInterval();
+ waitForPoll();
+ validateInterval();
+ }
+
+ validateAverageDeviation();
+ }
+
+ private void startInterval() {
+ startTime = System.currentTimeMillis();
+ }
+
+ private void waitForPoll() {
+ selenium.getPageExtensions().install();
+ selenium.getRequestInterceptor().clearRequestTypeDone();
+ selenium.getRequestInterceptor().waitForRequestTypeChange();
+ }
+
+ private void validateInterval() {
+ long runTime = getClientTime() - startTime;
+ long deviation = Math.abs(interval - runTime);
+
+ if (seleniumDebug) {
+ System.out.println(format("deviation for interval {0}: {1}",
interval, deviation));
+ }
+
+ assertTrue(deviation <= (2 * interval),
+ format("Deviation ({0}) is greater than two intervals (2 * {1})",
deviation, interval));
+
+ deviationTotal += deviation;
+ deviationCount += 1;
+ }
+
+ private void validateAverageDeviation() {
+ long maximumAvgDeviation = Math.min(interval / 3, 1000);
+ long averageDeviation = deviationTotal / deviationCount;
+
+ if (seleniumDebug) {
+ System.out.println("averageDeviation: " + averageDeviation);
+ }
+ assertTrue(
+ averageDeviation <= maximumAvgDeviation,
+ format("Average deviation for all the intervals ({0}) should not be
greater than defined maximum {1}",
+ averageDeviation, maximumAvgDeviation));
+ }
+
+ /**
+ * Returns the time of poll event (the time when arrived the response from server)
+ *
+ * @return the time of poll event (the time when arrived the response from server)
+ */
+ private long getClientTime() {
+ return asLong(selenium.getAttribute(clientTime));
+ }
+}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPollSimple.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPollSimple.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPollSimple.java 2011-02-05
14:49:51 UTC (rev 21479)
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.a4jPoll;
+
+import static javax.faces.event.PhaseId.ANY_PHASE;
+import static javax.faces.event.PhaseId.APPLY_REQUEST_VALUES;
+import static javax.faces.event.PhaseId.INVOKE_APPLICATION;
+import static javax.faces.event.PhaseId.PROCESS_VALIDATIONS;
+import static javax.faces.event.PhaseId.RENDER_RESPONSE;
+import static javax.faces.event.PhaseId.RESTORE_VIEW;
+import static javax.faces.event.PhaseId.UPDATE_MODEL_VALUES;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.annotations.Inject;
+import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestPollSimple extends AbstractMetamerTest {
+
+ PollAttributes attributes = new PollAttributes();
+
+ JQueryLocator outputCounter = pjq("span[id$=outputCounter]");
+
+ @Inject
+ @Use(empty = true)
+ String event;
+ String[] events = new String[] { "timer", "begin",
"beforedomupdate", "complete" };
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/a4jPoll/simple.xhtml");
+ }
+
+ @BeforeMethod
+ public void enablePoll() {
+ attributes.setInterval(2500);
+ attributes.setEnabled(true);
+
+ }
+
+ @Test
+ public void testAction() {
+ waitForTwoSubsequentRequests();
+ phaseInfo.assertListener(INVOKE_APPLICATION, "action invoked");
+ phaseInfo.assertPhases(ANY_PHASE);
+ }
+
+ @Test
+ public void testActionListener() {
+ waitForTwoSubsequentRequests();
+ phaseInfo.assertListener(INVOKE_APPLICATION, "action listener
invoked");
+ phaseInfo.assertPhases(ANY_PHASE);
+ }
+
+ @Test
+ public void testBypassUpdates() {
+ attributes.setBypassUpdates(true);
+ waitForTwoSubsequentRequests();
+ phaseInfo.assertListener(PROCESS_VALIDATIONS, "action invoked");
+ phaseInfo.assertPhases(RESTORE_VIEW, APPLY_REQUEST_VALUES, PROCESS_VALIDATIONS,
RENDER_RESPONSE);
+ }
+
+ @Test
+ public void testData() {
+ attributes.setData("RichFaces 4");
+ attributes.setOncomplete("data = event.data");
+
+ retrieveRequestTime.initializeValue();
+ waitGui.waitForChange(retrieveRequestTime);
+
+ assertEquals(retrieveWindowData.retrieve(), "RichFaces 4");
+ }
+
+ @Test
+ public void testImmediate() {
+ attributes.setImmediate(true);
+ waitForTwoSubsequentRequests();
+ phaseInfo.assertListener(APPLY_REQUEST_VALUES, "action invoked");
+ phaseInfo.assertPhases(RESTORE_VIEW, APPLY_REQUEST_VALUES, RENDER_RESPONSE);
+ }
+
+ @Test
+ @Use(field = "event", value = "events")
+ public void testClientSideEvent() {
+ testClientSideEventHandlers(event);
+ }
+
+ @Test
+ public void testClientSideEventsOrder() {
+ testClientSideEventHandlers(events);
+ }
+
+ @Test
+ public void testRendered() {
+ attributes.setEnabled(true);
+ attributes.setRendered(false);
+
+ retrieveRequestTime.initializeValue();
+ waitModel.timeout(5000).interval(1000).waitForTimeout();
+ assertFalse(retrieveRequestTime.isValueChanged());
+
+ attributes.setRendered(true);
+ waitForTwoSubsequentRequests();
+ }
+
+ @Test
+ public void testExecute() {
+ attributes.setExecute("executeChecker");
+
+ waitForTwoSubsequentRequests();
+
+ phaseInfo.assertListener(UPDATE_MODEL_VALUES, "executeChecker");
+ }
+
+ @Test
+ public void testEnabled() {
+ attributes.setEnabled(false);
+
+ retrieveRequestTime.initializeValue();
+ waitModel.timeout(5000).interval(1000).waitForTimeout();
+ assertFalse(retrieveRequestTime.isValueChanged());
+
+ attributes.setEnabled(true);
+ waitForTwoSubsequentRequests();
+ }
+
+ @Test
+ public void testRender() {
+ attributes.setRender("renderChecker");
+ retrieveRenderChecker.initializeValue();
+ retrieveRequestTime.initializeValue();
+ waitAjax.waitForChange(retrieveRenderChecker);
+ assertTrue(retrieveRequestTime.isValueChanged());
+ }
+
+ @Test
+ public void testLimitRender() {
+ attributes.setLimitRender(true);
+ attributes.setRender("renderChecker");
+ retrieveRenderChecker.initializeValue();
+ retrieveRequestTime.initializeValue();
+ waitGui.waitForChange(retrieveRenderChecker);
+ assertFalse(retrieveRequestTime.isValueChanged());
+ }
+
+ private void testClientSideEventHandlers(String... events) {
+ attributes.setEnabled(false);
+ super.testRequestEventsBefore(events);
+ retrieveRequestTime.initializeValue();
+ attributes.setEnabled(true);
+
+ waitAjax.waitForChange(retrieveRequestTime);
+
+ super.testRequestEventsAfter(events);
+ }
+
+ private void waitForTwoSubsequentRequests() {
+ retrieveRequestTime.initializeValue();
+
+ waitAjax.waitForChange(retrieveRequestTime);
+ waitAjax.waitForChange(retrieveRequestTime);
+ }
+}