Author: lfryc(a)redhat.com
Date: 2010-09-14 12:23:00 -0400 (Tue, 14 Sep 2010)
New Revision: 19200
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jAttachQueue/
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jAttachQueue/AttachQueueAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jAttachQueue/TestNestedAttachQueue.java
Removed:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jQueue/QueueLocators.java
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/waiting/WaitFactory.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jQueue/QueueModel.java
Log:
a4j:attachQueue - 4 initial tests for nested.xhtml (RFPL-734)
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/waiting/WaitFactory.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/waiting/WaitFactory.java 2010-09-14
15:38:08 UTC (rev 19199)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/waiting/WaitFactory.java 2010-09-14
16:23:00 UTC (rev 19200)
@@ -32,6 +32,14 @@
import static org.jboss.test.selenium.SystemProperties.SeleniumTimeoutType.MODEL;
import org.jboss.test.selenium.waiting.ajax.AjaxWaiting;
+import org.jboss.test.selenium.waiting.conditions.AlertEquals;
+import org.jboss.test.selenium.waiting.conditions.AlertPresent;
+import org.jboss.test.selenium.waiting.conditions.AttributeEquals;
+import org.jboss.test.selenium.waiting.conditions.AttributePresent;
+import org.jboss.test.selenium.waiting.conditions.CountEquals;
+import org.jboss.test.selenium.waiting.conditions.ElementPresent;
+import org.jboss.test.selenium.waiting.conditions.StyleEquals;
+import org.jboss.test.selenium.waiting.conditions.TextEquals;
import org.jboss.test.selenium.waiting.selenium.SeleniumWaiting;
/**
@@ -52,4 +60,13 @@
*/
public static SeleniumWaiting waitModel =
waitSelenium().interval(WAIT_MODEL_INTERVAL).timeout(
getSeleniumTimeout(MODEL));
+
+ public static ElementPresent elementPresent = ElementPresent.getInstance();
+ public static TextEquals textEquals = TextEquals.getInstance();
+ public static StyleEquals styleEquals = StyleEquals.getInstance();
+ public static AttributePresent attributePresent = AttributePresent.getInstance();
+ public static AttributeEquals attributeEquals = AttributeEquals.getInstance();
+ public static AlertPresent alertPresent = AlertPresent.getInstance();
+ public static AlertEquals alertEquals = AlertEquals.getInstance();
+ public static CountEquals countEquals = CountEquals.getInstance();
}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jAttachQueue/AttachQueueAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jAttachQueue/AttachQueueAttributes.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jAttachQueue/AttachQueueAttributes.java 2010-09-14
16:23:00 UTC (rev 19200)
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * 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.a4jAttachQueue;
+
+import org.jboss.test.selenium.encapsulated.JavaScript;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.locator.ExtendedLocator;
+import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class AttachQueueAttributes extends AbstractComponentAttributes {
+
+ public AttachQueueAttributes() {
+ }
+
+ public AttachQueueAttributes(ExtendedLocator<JQueryLocator> root) {
+ super(root);
+ }
+
+ public void setIgnoreDupResponses(boolean ignoreDupResponses) {
+ setProperty("ignoreDupResponses", ignoreDupResponses);
+ }
+
+ public void setName(String name) {
+ setProperty("name", name);
+ }
+
+ public void setOnRequestDequeue(JavaScript onRequestDequeue) {
+ setProperty("onrequestdequeue", onRequestDequeue);
+ }
+
+ public void setOnRequestQueue(JavaScript onRequestQueue) {
+ setProperty("onrequestqueue", onRequestQueue);
+ }
+
+ public void setQueueId(String queueId) {
+ setProperty("queueId", queueId);
+ }
+
+ public void setRendered(boolean rendered) {
+ setProperty("rendered", rendered);
+ }
+
+ public void setRequestDelay(long requestDelay) {
+ setProperty("requestDelay", requestDelay);
+ }
+
+ public void setRequestGroupingId(String requestGroupingId) {
+ setProperty("rquestGroupingId", requestGroupingId);
+ }
+
+ public void setTimeout(long timeout) {
+ setProperty("timeout", timeout);
+ }
+}
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jAttachQueue/TestNestedAttachQueue.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jAttachQueue/TestNestedAttachQueue.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jAttachQueue/TestNestedAttachQueue.java 2010-09-14
16:23:00 UTC (rev 19200)
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * 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.a4jAttachQueue;
+
+import static org.jboss.test.selenium.dom.Event.KEYPRESS;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URL;
+
+import org.jboss.cheiron.halt.XHRHalter;
+import org.jboss.cheiron.halt.XHRState;
+import org.jboss.test.selenium.waiting.retrievers.Retriever;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.a4jQueue.QueueAttributes;
+import org.richfaces.tests.metamer.ftest.a4jQueue.QueueModel;
+import org.richfaces.tests.metamer.ftest.a4jQueue.QueueModel.Input;
+import org.richfaces.tests.metamer.ftest.annotations.Inject;
+import org.richfaces.tests.metamer.ftest.annotations.IssueTracking;
+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 TestNestedAttachQueue extends AbstractMetamerTest {
+
+ static final Long GLOBAL_DELAY = 10000L;
+ static final Long DELAY_A = 3000L;
+ static final Long DELAY_B = 5000L;
+
+ QueueModel queue = new QueueModel();
+
+ AttachQueueAttributes attributesAttachQueue1 = new
AttachQueueAttributes(pjq("table.attributes[id$=attributes1]"));
+ AttachQueueAttributes attributesAttachQueue2 = new
AttachQueueAttributes(pjq("table.attributes[id$=attributes2]"));
+ QueueAttributes attributesQueue1 = new
QueueAttributes(pjq("table.attributes[id$=queueAttributes]"));
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/a4jAttachQueue/nested.xhtml");
+ }
+
+ @BeforeMethod
+ public void setupDelays() {
+ attributesAttachQueue1.setRequestDelay(DELAY_A);
+ attributesAttachQueue2.setRequestDelay(DELAY_B);
+ attributesQueue1.setRequestDelay(GLOBAL_DELAY);
+ }
+
+ @Test
+ public void testDelay() {
+ queue.initializeTimes();
+
+ queue.fireEvent(Input.FIRST, 1);
+
+ queue.checkTimes(Input.FIRST, DELAY_A);
+ }
+
+ @Test
+ public void testNoDelay() {
+ attributesAttachQueue1.setRequestDelay(0);
+
+ queue.initializeCounts();
+
+ XHRHalter.enable();
+
+ queue.fireEvent(Input.FIRST, 4);
+ queue.checkCounts(4, 0, 1, 0);
+
+ XHRHalter halter = XHRHalter.getHandleBlocking();
+ queue.checkCounts(4, 0, 1, 0);
+
+ halter.complete();
+ queue.checkCounts(4, 0, 2, 1);
+
+ halter.waitForOpen();
+ queue.checkCounts(4, 0, 2, 1);
+
+ halter.complete();
+ queue.checkCounts(4, 0, 2, 2);
+ }
+
+ @Test
+ public void testTimingOneQueueTwoEvents() {
+ queue.initializeTimes();
+
+ XHRHalter.enable();
+
+ queue.fireEvent(Input.FIRST, 3);
+ queue.fireEvent(Input.SECOND, 1);
+
+ XHRHalter halter = XHRHalter.getHandleBlocking();
+ halter.complete();
+ halter.waitForOpen();
+ halter.complete();
+
+ queue.checkTimes(Input.SECOND, DELAY_A);
+ queue.checkNoDelayBetweenEvents();
+ }
+
+ @Test
+ @IssueTracking("https://jira.jboss.org/browse/RF-9328")
+ public void testRendered() {
+ attributesAttachQueue1.setRequestDelay(1500);
+ attributesAttachQueue1.setRendered(false);
+
+ queue.initializeTimes();
+ queue.fireEvent(1);
+
+ // check that no requestDelay is applied while renderer=false
+ queue.checkTimes(0);
+ // TODO should check that no attributes is applied with renderes=false
+ }
+}
\ No newline at end of file
Deleted:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jQueue/QueueLocators.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jQueue/QueueLocators.java 2010-09-14
15:38:08 UTC (rev 19199)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jQueue/QueueLocators.java 2010-09-14
16:23:00 UTC (rev 19200)
@@ -1,93 +0,0 @@
-package org.richfaces.tests.metamer.ftest.a4jQueue;
-
-import static org.jboss.cheiron.retriever.RetrieverAdapter.integerAdapter;
-import static org.jboss.cheiron.retriever.RetrieverAdapter.longAdapter;
-import static org.jboss.test.selenium.locator.Attribute.TITLE;
-import static org.jboss.test.selenium.locator.reference.ReferencedLocator.ref;
-import static
org.jboss.test.selenium.waiting.retrievers.RetrieverFactory.RETRIEVE_ATTRIBUTE;
-import static org.jboss.test.selenium.waiting.retrievers.RetrieverFactory.RETRIEVE_TEXT;
-import static org.richfaces.tests.metamer.ftest.AbstractMetamerTest.pjq;
-
-import org.jboss.test.selenium.locator.AttributeLocator;
-import org.jboss.test.selenium.locator.ElementLocator;
-import org.jboss.test.selenium.locator.ExtendedLocator;
-import org.jboss.test.selenium.locator.JQueryLocator;
-import org.jboss.test.selenium.locator.reference.LocatorReference;
-import org.jboss.test.selenium.locator.reference.ReferencedLocator;
-import org.jboss.test.selenium.waiting.retrievers.Retriever;
-
-public class QueueLocators {
-
- LocatorReference<JQueryLocator> form = new
LocatorReference<JQueryLocator>(null);
- LocatorReference<JQueryLocator> attributesPanel = new
LocatorReference<JQueryLocator>(null);
-
- ReferencedLocator<JQueryLocator> input1 = ref(form,
"input:text[id$=input1]");
- ReferencedLocator<JQueryLocator> input2 = ref(form,
"input:text[id$=input2]");
- ReferencedLocator<JQueryLocator> attributesTable = ref(attributesPanel,
"table.attributes");
-
- QueueAttributes attributes = new QueueAttributes(attributesTable);
-
- ElementLocator<?> events1 = ref(form, "span[id$=events1]");
- ElementLocator<?> events2 = ref(form, "span[id$=events2]");
- ElementLocator<?> requests = ref(form, "span[id$=requests]");
- ElementLocator<?> updates = ref(form, "span[id$=updates]");
-
- AttributeLocator<?> event1Time = ref(form,
"span[id$=eventTime1\\:outputTime]").getAttribute(TITLE);
- AttributeLocator<?> event2Time = ref(form,
"span[id$=eventTime2\\:outputTime]").getAttribute(TITLE);
- AttributeLocator<?> beginTime = ref(form,
"span[id$=beginTime\\:outputTime]").getAttribute(TITLE);
- AttributeLocator<?> completeTime = ref(form,
"span[id$=completeTime\\:outputTime]").getAttribute(TITLE);
-
- Retriever<Integer> retrieveEvent1Count =
integerAdapter(RETRIEVE_TEXT.locator(events1));
- Retriever<Integer> retrieveEvent2Count =
integerAdapter(RETRIEVE_TEXT.locator(events2));
- Retriever<Integer> retrieveRequestCount =
integerAdapter(RETRIEVE_TEXT.locator(requests));
- Retriever<Integer> retrieveDOMUpdateCount =
integerAdapter(RETRIEVE_TEXT.locator(updates));
-
- Retriever<Long> retrieveEvent1Time =
longAdapter(RETRIEVE_ATTRIBUTE.attributeLocator(event1Time));
- Retriever<Long> retrieveEvent2Time =
longAdapter(RETRIEVE_ATTRIBUTE.attributeLocator(event2Time));
- Retriever<Long> retrieveBeginTime =
longAdapter(RETRIEVE_ATTRIBUTE.attributeLocator(beginTime));
- Retriever<Long> retrieveCompleteTime =
longAdapter(RETRIEVE_ATTRIBUTE.attributeLocator(completeTime));
-
- private String identifier;
-
- public QueueLocators(String identifier, JQueryLocator queueRoot, JQueryLocator
queueAttributesPanel) {
- this.identifier = identifier;
-
- form.setLocator(queueRoot);
- attributesPanel.setLocator(queueAttributesPanel);
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((identifier == null) ? 0 : identifier.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- QueueLocators other = (QueueLocators) obj;
- if (identifier == null) {
- if (other.identifier != null) {
- return false;
- }
- } else if (!identifier.equals(other.identifier)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return "FormQueueLocators [identifier=" + identifier + "]";
- }
-}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jQueue/QueueModel.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jQueue/QueueModel.java 2010-09-14
15:38:08 UTC (rev 19199)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jQueue/QueueModel.java 2010-09-14
16:23:00 UTC (rev 19200)
@@ -13,6 +13,7 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.jboss.test.selenium.waiting.WaitFactory.waitAjax;
+import static org.jboss.test.selenium.waiting.WaitFactory.textEquals;
import org.jboss.test.selenium.framework.AjaxSelenium;
import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
@@ -139,19 +140,29 @@
long deviation = Math.abs(actualDelay - requestDelay);
long maxDeviation = Math.max(100, requestDelay);
- if (isSeleniumDebug()) {
- System.out.println(format("deviation for requestDelay {0}: {1}",
requestDelay, deviation));
- }
+ checkDeviation(deviation, maxDeviation);
- assertTrue(
- deviation <= maxDeviation,
- format("Deviation ({0}) is greater than maxDeviation ({1}) for
requestDelay {2}", deviation, maxDeviation,
- requestDelay));
-
deviationTotal += deviation;
deviationCount += 1;
}
+ public void checkNoDelayBetweenEvents() {
+ long event1Time = retrieveEvent1Time.retrieve();
+ long event2Time = retrieveEvent2Time.retrieve();
+ long actualDelay = Math.abs(event1Time - event2Time);
+
+ checkDeviation(actualDelay, 50);
+ }
+
+ public void checkDeviation(long deviation, long maxDeviation) {
+ if (isSeleniumDebug()) {
+ System.out.println(format("deviation: {0}", deviation));
+ }
+
+ assertTrue(deviation <= maxDeviation,
+ format("Deviation ({0}) is greater than maxDeviation ({1})",
deviation, maxDeviation));
+ }
+
public void checkAvgDeviation(long requestDelay) {
long maximumAvgDeviation = Math.max(25, Math.min(50, requestDelay / 4));
long averageDeviation = deviationTotal / deviationCount;