JBoss Rich Faces SVN: r17911 - root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-10 17:13:59 -0400 (Sat, 10 Jul 2010)
New Revision: 17911
Modified:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/AbstractPushTestCase.java
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/IntervalTestCase.java
Log:
testing a4j:poll from client perspective (the client time of observation the event)
Modified: root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/AbstractPushTestCase.java
===================================================================
--- root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/AbstractPushTestCase.java 2010-07-10 21:12:49 UTC (rev 17910)
+++ root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/AbstractPushTestCase.java 2010-07-10 21:13:59 UTC (rev 17911)
@@ -68,7 +68,7 @@
public void initializeHttpClient() {
httpClient = new HttpClient();
URL eventProducerUrl = buildUrl(getTestUrl(), "event-producer.xhtml");
- pushMethod = new GetMethod(eventProducerUrl.toString() + "?pushEnabled=true");
+ pushMethod = new GetMethod(eventProducerUrl.toString());
}
/**
Modified: root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/IntervalTestCase.java
===================================================================
--- root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/IntervalTestCase.java 2010-07-10 21:12:49 UTC (rev 17910)
+++ root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/IntervalTestCase.java 2010-07-10 21:13:59 UTC (rev 17911)
@@ -21,7 +21,7 @@
*******************************************************************************/
package org.richfaces.tests.testapp.a4jPush;
-import static java.lang.System.currentTimeMillis;
+import static org.jboss.test.selenium.utils.PrimitiveUtils.asLong;
import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
@@ -29,6 +29,8 @@
import java.io.IOException;
import org.apache.commons.httpclient.HttpException;
+import org.jboss.test.selenium.locator.Attribute;
+import org.jboss.test.selenium.locator.AttributeLocator;
import org.testng.annotations.Test;
/**
@@ -39,13 +41,16 @@
*/
public class IntervalTestCase extends AbstractPushTestCase {
+ private static final Attribute ATTRIBUTE_TITLE = new Attribute("title");
private static final int[] INTERVAL_VALUES = new int[]{1000, 5000, 500};
- private static final long MAX_DEVIATION = 300;
- private static final long MAX_AVERAGE_DEVIATION = 100;
+ private static final long MAX_DEVIATION = 100;
+ private static final long MAX_AVERAGE_DEVIATION = 75;
private static final int DEFAULT_COUNTER_STEP = 2;
private static final int ITERATION_COUNT = 3;
private static final int MULTIPLE_PUSH_COUNT = 5;
+ AttributeLocator clientTime = pjq("span[id$=clientDate]").getAttribute(ATTRIBUTE_TITLE);
+
private long startTime;
private int counter;
private int counterStep;
@@ -72,7 +77,7 @@
* </p>
*/
@Test
- public void testInterval() throws HttpException, IOException {
+ public void testIntervalFromClientPerspective() throws HttpException, IOException {
for (int interval : INTERVAL_VALUES) {
counterStep = DEFAULT_COUNTER_STEP;
pushAttributes.setInterval(interval);
@@ -96,7 +101,7 @@
* Remembers start of the time frame and current value of counter.
*/
private void startIntervalAndCounter() {
- startTime = currentTimeMillis();
+ startTime = getClientTime();
counter = getCounter();
}
@@ -118,13 +123,13 @@
* </p>
*/
private void validateIntervalAndCounter(int interval) {
- long runTime = currentTimeMillis() - startTime;
+ long runTime = getClientTime() - startTime;
long deviation = Math.abs(interval - runTime);
assertTrue(deviation <= MAX_DEVIATION, format("Deviation ({0}) is greater than defined maximum {1}", deviation,
MAX_DEVIATION));
if (seleniumDebug) {
- System.out.println("deviation: " + deviation);
+ System.out.println(format("deviation for interval {0}: {1}", interval, deviation));
}
deviationTotal += deviation;
@@ -148,4 +153,13 @@
"Average deviation for all the intervals ({0}) should not be greater than defined maximum {1}",
averageDeviation, MAX_AVERAGE_DEVIATION));
}
+
+ /**
+ * Returns the time of push event (the time when arrived the response from server)
+ *
+ * @return the time of push event (the time when arrived the response from server)
+ */
+ private long getClientTime() {
+ return asLong(selenium.getAttribute(clientTime));
+ }
}
14 years, 6 months
JBoss Rich Faces SVN: r17910 - root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPoll.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-10 17:12:49 -0400 (Sat, 10 Jul 2010)
New Revision: 17910
Modified:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPoll/PollTestCase.java
Log:
improved PollTestCase to be more stable - obtaining the run time as time of the arrival of reponse to client
Modified: root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPoll/PollTestCase.java
===================================================================
--- root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPoll/PollTestCase.java 2010-07-10 21:12:23 UTC (rev 17909)
+++ root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPoll/PollTestCase.java 2010-07-10 21:12:49 UTC (rev 17910)
@@ -24,6 +24,8 @@
import java.net.URL;
import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.locator.Attribute;
+import org.jboss.test.selenium.locator.AttributeLocator;
import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.testapp.AbstractTestappTestCase;
@@ -35,6 +37,7 @@
import static org.testng.Assert.*;
import static org.jboss.test.selenium.SystemProperties.isSeleniumDebug;
import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
+import static org.jboss.test.selenium.utils.PrimitiveUtils.*;
/**
* Tests the a4j:poll component.
@@ -44,14 +47,16 @@
*/
public class PollTestCase extends AbstractTestappTestCase {
+ private static final Attribute ATTRIBUTE_TITLE = new Attribute("title");
private static final int[] TEST_INTERVAL_VALUES = new int[]{1000, 5000, 500};
private static final int TEST_INTERVAL_ITERATIONS = 5;
- private static final int MAX_DEVIATION = 250;
- private static final int MAX_AVERAGE_DEVIATION = 100;
+ private static final int MAX_DEVIATION = 100;
+ private static final int MAX_AVERAGE_DEVIATION = 50;
ElementLocator attributeEnabled = id("form:attributes:enabledInput");
ElementLocator attributeInterval = id("form:attributes:intervalInput");
JQueryLocator time = pjq("span[id$=time]");
+ AttributeLocator clientTime = pjq("span[id$=clientDate]").getAttribute(ATTRIBUTE_TITLE);
@Override
public URL getTestUrl() {
@@ -65,7 +70,7 @@
/**
* <p>
- * Test the progress of polling for 3 different values.
+ * Test the progress of polling for 3 different values from client side.
* </p>
*
* <p>
@@ -77,8 +82,9 @@
* </p>
*
* <p>
- * For 5 following poll events it checks that runtime between the events haven't greater deviation from defined
- * interval than defined {@link #MAX_DEVIATION}.
+ * 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>
@@ -87,7 +93,7 @@
* </p>
*/
@Test(dataProvider = "templates", groups = "client-side-perf")
- public void testInterval(String templates) {
+ public void testIntervalFromClientPerspective(String templates) {
long total = 0;
long count = 0;
@@ -101,38 +107,49 @@
selenium.getPageExtensions().install();
+ long currentTime = getClientTime();
+
for (int i = 0; i <= TEST_INTERVAL_ITERATIONS; i++) {
long runtime = System.currentTimeMillis();
selenium.getRequestInterceptor().clearRequestTypeDone();
selenium.getRequestInterceptor().waitForRequestTypeChange();
- runtime -= System.currentTimeMillis();
+ runtime -= getClientTime();
if (i > 0) {
+
+ long deviation = Math.abs(interval - Math.abs(runtime));
if (isSeleniumDebug()) {
- System.out.println(runtime);
+ System.out.println(format("deviation for interval {0}: {1}", interval, deviation));
}
- long deviation = Math.abs(interval - Math.abs(runtime));
assertTrue(deviation <= MAX_DEVIATION, format(
"Particular deviation ({2}) for interval {0} was greater than {1}", interval, MAX_DEVIATION,
deviation));
total += deviation;
count += 1;
}
+ currentTime += runtime;
}
selenium.uncheck(attributeEnabled);
selenium.fireEvent(attributeEnabled, Event.CHANGE);
selenium.waitForPageToLoad();
}
-
+
long averageDeviation = total / count;
if (isSeleniumDebug()) {
- System.out.println(averageDeviation);
+ System.out.println(format("total average deviation: {0}", averageDeviation));
}
-
+
assertTrue(averageDeviation <= MAX_AVERAGE_DEVIATION, format(
"Average deviation ({1}) was greater than given maximum {0}", MAX_AVERAGE_DEVIATION, averageDeviation));
+ }
+ /**
+ * 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));
}
}
14 years, 6 months
JBoss Rich Faces SVN: r17909 - in root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp: a4jCommandLink and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-10 17:12:23 -0400 (Sat, 10 Jul 2010)
New Revision: 17909
Modified:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandButton/A4JCommandButtonTestCase.java
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandLink/A4JCommandLinkTestCase.java
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/hCommandButton/HCommandButtonTestCase.java
Log:
attribute inputs reacts to CHANGE event but tests was firing BLUR event (note that selenium.type fires CHANGE event out-of-the-box)
Modified: root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandButton/A4JCommandButtonTestCase.java
===================================================================
--- root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandButton/A4JCommandButtonTestCase.java 2010-07-10 21:11:53 UTC (rev 17908)
+++ root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandButton/A4JCommandButtonTestCase.java 2010-07-10 21:12:23 UTC (rev 17909)
@@ -228,7 +228,6 @@
ElementLocator renderInput = pjq("input[name$=renderInput]");
selenium.type(renderInput, "output1");
- selenium.fireEvent(renderInput, Event.BLUR);
selenium.waitForPageToLoad(TIMEOUT);
selenium.typeKeys(input, "aaa");
@@ -246,7 +245,6 @@
assertEquals(output, "", "output3 when 'aaa' in input and 'output1' set to be rerendered");
selenium.type(renderInput, "output2 output3");
- selenium.fireEvent(renderInput, Event.BLUR);
selenium.waitForPageToLoad(TIMEOUT);
selenium.typeKeys(input, "bbb");
@@ -302,9 +300,8 @@
final String value = "font-size: 20px;";
selenium.type(styleInput, value);
- selenium.fireEvent(styleInput, Event.BLUR);
-
selenium.waitForPageToLoad(TIMEOUT);
+
assertEquals(selenium.getAttribute(attribute), value, "Style of the button did not change");
}
@@ -315,9 +312,8 @@
final String value = "new label";
selenium.type(valueInput, value);
- selenium.fireEvent(valueInput, Event.BLUR);
-
selenium.waitForPageToLoad(TIMEOUT);
+
assertEquals(selenium.getAttribute(attribute), value, "Value of the button did not change");
}
Modified: root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandLink/A4JCommandLinkTestCase.java
===================================================================
--- root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandLink/A4JCommandLinkTestCase.java 2010-07-10 21:11:53 UTC (rev 17908)
+++ root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandLink/A4JCommandLinkTestCase.java 2010-07-10 21:12:23 UTC (rev 17909)
@@ -231,7 +231,6 @@
ElementLocator renderInput = pjq("input[name$=renderInput]");
selenium.type(renderInput, "output1");
- selenium.fireEvent(renderInput, Event.BLUR);
selenium.waitForPageToLoad(TIMEOUT);
selenium.typeKeys(input, "aaa");
@@ -249,7 +248,6 @@
assertEquals(output, "", "output3 when 'aaa' in input and 'output1' set to be rerendered");
selenium.type(renderInput, "output2 output3");
- selenium.fireEvent(renderInput, Event.BLUR);
selenium.waitForPageToLoad(TIMEOUT);
selenium.typeKeys(input, "bbb");
@@ -305,9 +303,8 @@
final String value = "font-size: 20px;";
selenium.type(styleInput, value);
- selenium.fireEvent(styleInput, Event.BLUR);
-
selenium.waitForPageToLoad(TIMEOUT);
+
assertEquals(selenium.getAttribute(attribute), value, "Style of the button did not change");
}
@@ -317,9 +314,8 @@
final String value = "new label";
selenium.type(valueInput, value);
- selenium.fireEvent(valueInput, Event.BLUR);
-
selenium.waitForPageToLoad(TIMEOUT);
+
assertEquals(selenium.getText(link), value, "Value of the button did not change");
}
Modified: root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/hCommandButton/HCommandButtonTestCase.java
===================================================================
--- root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/hCommandButton/HCommandButtonTestCase.java 2010-07-10 21:11:53 UTC (rev 17908)
+++ root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/hCommandButton/HCommandButtonTestCase.java 2010-07-10 21:12:23 UTC (rev 17909)
@@ -270,9 +270,8 @@
final String value = "font-size: 20px;";
selenium.type(styleInput, value);
- selenium.fireEvent(styleInput, Event.BLUR);
-
selenium.waitForPageToLoad(TIMEOUT);
+
assertEquals(selenium.getAttribute(attribute), value, "Style of the button did not change");
}
@@ -283,9 +282,8 @@
final String value = "new label";
selenium.type(valueInput, value);
- selenium.fireEvent(valueInput, Event.BLUR);
-
selenium.waitForPageToLoad(TIMEOUT);
+
assertEquals(selenium.getAttribute(attribute), value, "Value of the button did not change");
}
14 years, 6 months
JBoss Rich Faces SVN: r17908 - root/tests/metamer/trunk/ftest.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-10 17:11:53 -0400 (Sat, 10 Jul 2010)
New Revision: 17908
Modified:
root/tests/metamer/trunk/ftest/pom.xml
Log:
added functionality for undeploying (post-integration-test) and cleaning the deployment (exploded war, in initialize phase)
Modified: root/tests/metamer/trunk/ftest/pom.xml
===================================================================
--- root/tests/metamer/trunk/ftest/pom.xml 2010-07-10 21:11:41 UTC (rev 17907)
+++ root/tests/metamer/trunk/ftest/pom.xml 2010-07-10 21:11:53 UTC (rev 17908)
@@ -70,6 +70,15 @@
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>undeploy</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>undeploy</goal>
+ </goals>
+ </execution>
+ </executions>
<configuration>
<deployer>
<type>installed</type>
@@ -176,6 +185,42 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>clean-tomcat-exploded-war</id>
+ <activation>
+ <property>
+ <name>containerId</name>
+ <value>tomcat6x</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-clean-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>clean-tomcat-exploded-war</id>
+ <phase>initialize</phase>
+ <goals>
+ <goal>clean</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <excludeDefaultDirectories>true</excludeDefaultDirectories>
+ <filesets>
+ <fileset>
+ <directory>${container.home}/webapps/${context.deploy.path}</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
<profile>
<id>unpack-test-source</id>
14 years, 6 months
JBoss Rich Faces SVN: r17907 - in root/tests/metamer/trunk/ftest/test-source: src/main/java/org/richfaces/tests/testapp and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-10 17:11:41 -0400 (Sat, 10 Jul 2010)
New Revision: 17907
Added:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/AbstractPushTestCase.java
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/IntervalTestCase.java
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/PushAttributes.java
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/SimpleTestCase.java
Modified:
root/tests/metamer/trunk/ftest/test-source/pom.xml
Log:
added 2 test cases and utility classes for testing a4j:push
Modified: root/tests/metamer/trunk/ftest/test-source/pom.xml
===================================================================
--- root/tests/metamer/trunk/ftest/test-source/pom.xml 2010-07-10 21:11:05 UTC (rev 17906)
+++ root/tests/metamer/trunk/ftest/test-source/pom.xml 2010-07-10 21:11:41 UTC (rev 17907)
@@ -18,6 +18,11 @@
<groupId>org.jboss.test</groupId>
<artifactId>richfaces-selenium</artifactId>
</dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ </dependency>
</dependencies>
<build>
Added: root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/AbstractPushTestCase.java
===================================================================
--- root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/AbstractPushTestCase.java (rev 0)
+++ root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/AbstractPushTestCase.java 2010-07-10 21:11:41 UTC (rev 17907)
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * 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.testapp.a4jPush;
+
+import static org.testng.Assert.*;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.jboss.test.selenium.SeleniumGetter.*;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.jboss.test.selenium.SystemProperties;
+import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.request.RequestType;
+import org.richfaces.tests.testapp.AbstractTestappTestCase;
+import org.testng.annotations.BeforeClass;
+
+/**
+ * Abstract test case for testing a4j:push component.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public abstract class AbstractPushTestCase extends AbstractTestappTestCase {
+
+ private static final int STATUS_CODE_OK = 200;
+
+ protected PushAttributes pushAttributes = new PushAttributes();
+
+ private ElementLocator outputCounter = pjq("span[id$=outputCounter]");
+
+ private HttpClient httpClient;
+ private HttpMethod pushMethod;
+
+ @Override
+ public URL getTestUrl() {
+ URL contextPath = SystemProperties.getContextPath();
+ return buildUrl(contextPath, "faces/components/a4jPush/simple.xhtml");
+ }
+
+ /**
+ * Initializes the HttpClient which triggers events in {@link #generatePushEvent()}.
+ */
+ @BeforeClass
+ public void initializeHttpClient() {
+ httpClient = new HttpClient();
+ URL eventProducerUrl = buildUrl(getTestUrl(), "event-producer.xhtml");
+ pushMethod = new GetMethod(eventProducerUrl.toString() + "?pushEnabled=true");
+ }
+
+ /**
+ * Returns the value of counter as pushed value
+ *
+ * @return the value of counter as pushed value
+ */
+ protected int getCounter() {
+ return getText(outputCounter).asInteger();
+ }
+
+ /**
+ * Push the event specified number times and then waits for observation of event by client.
+ *
+ * @param numberOfPushes
+ * the number of events should be generated
+ */
+ protected void pushAndWait(int numberOfPushes) throws HttpException, IOException {
+ selenium.getPageExtensions().install();
+ selenium.getRequestInterceptor().clearRequestTypeDone();
+
+ for (int i = 0; i < numberOfPushes; i++) {
+ generatePushEvent();
+ }
+
+ selenium.getRequestInterceptor().waitForRequestTypeChange();
+ RequestType requestDone = selenium.getRequestInterceptor().getRequestTypeDone();
+
+ assertEquals(requestDone, RequestType.XHR);
+ }
+
+ /**
+ * <p>
+ * Generates the push event for all registered listeners from a4j:push test Simple page.
+ * </p>
+ *
+ * <p>
+ * Internally use HttpClient to ping URL triggering push event in preRenderView phase.
+ * </p>
+ */
+ private void generatePushEvent() throws HttpException, IOException {
+ httpClient.executeMethod(pushMethod);
+ assertEquals(pushMethod.getStatusCode(), STATUS_CODE_OK);
+ }
+}
Added: root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/IntervalTestCase.java
===================================================================
--- root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/IntervalTestCase.java (rev 0)
+++ root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/IntervalTestCase.java 2010-07-10 21:11:41 UTC (rev 17907)
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * 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.testapp.a4jPush;
+
+import static java.lang.System.currentTimeMillis;
+import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.apache.commons.httpclient.HttpException;
+import org.testng.annotations.Test;
+
+/**
+ * Tests the interval attribute for a4j:push
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class IntervalTestCase extends AbstractPushTestCase {
+
+ private static final int[] INTERVAL_VALUES = new int[]{1000, 5000, 500};
+ private static final long MAX_DEVIATION = 300;
+ private static final long MAX_AVERAGE_DEVIATION = 100;
+ private static final int DEFAULT_COUNTER_STEP = 2;
+ private static final int ITERATION_COUNT = 3;
+ private static final int MULTIPLE_PUSH_COUNT = 5;
+
+ private long startTime;
+ private int counter;
+ private int counterStep;
+
+ private long deviationTotal = 0;
+ private long deviationCount = 0;
+
+ /**
+ * <p>
+ * For 3 different intervals, test that the interval between push event triggered and event observered by client
+ * haven't greater deviation than the specified interval.
+ * </p>
+ *
+ * <p>
+ * First set the given interval into the interval attribute.
+ * </p>
+ *
+ * <p>
+ * Then push and wait for result of update triggered by observation of push event.
+ * </p>
+ *
+ * <p>
+ * Then repeat push and wait 6 times with 1 event triggered and 5 events triggered in sequence.
+ * </p>
+ */
+ @Test
+ public void testInterval() throws HttpException, IOException {
+ for (int interval : INTERVAL_VALUES) {
+ counterStep = DEFAULT_COUNTER_STEP;
+ pushAttributes.setInterval(interval);
+
+ pushAndWait(1);
+ for (int i = 0; i < ITERATION_COUNT; i++) {
+ startIntervalAndCounter();
+ pushAndWait(1);
+ validateIntervalAndCounter(interval);
+
+ startIntervalAndCounter();
+ pushAndWait(MULTIPLE_PUSH_COUNT);
+ validateIntervalAndCounter(interval);
+ }
+ }
+
+ validateAverageDeviation();
+ }
+
+ /**
+ * Remembers start of the time frame and current value of counter.
+ */
+ private void startIntervalAndCounter() {
+ startTime = currentTimeMillis();
+ counter = getCounter();
+ }
+
+ /**
+ * <p>
+ * Obtains current value of counter and end of the time frame to compute the run time.
+ * </p>
+ *
+ * <p>
+ * Validates that run time haven't greater deviation from given maximum {@link #MAX_DEVIATION}.
+ * </p>
+ *
+ * <p>
+ * Remembers the deviation as part of total deviation for computing average value.
+ * </p>
+ *
+ * <p>
+ * Validates that counter have been increased by right value.
+ * </p>
+ */
+ private void validateIntervalAndCounter(int interval) {
+ long runTime = currentTimeMillis() - startTime;
+ long deviation = Math.abs(interval - runTime);
+ assertTrue(deviation <= MAX_DEVIATION, format("Deviation ({0}) is greater than defined maximum {1}", deviation,
+ MAX_DEVIATION));
+
+ if (seleniumDebug) {
+ System.out.println("deviation: " + deviation);
+ }
+
+ deviationTotal += deviation;
+ deviationCount += 1;
+
+ int newCounter = getCounter();
+ assertEquals(newCounter, counter + counterStep);
+ counter = newCounter;
+
+ }
+
+ /**
+ * Validates the average deviations from intervals.
+ */
+ private void validateAverageDeviation() {
+ long averageDeviation = deviationTotal / deviationCount;
+ if (seleniumDebug) {
+ System.out.println("averageDeviation: " + averageDeviation);
+ }
+ assertTrue(averageDeviation <= MAX_AVERAGE_DEVIATION, format(
+ "Average deviation for all the intervals ({0}) should not be greater than defined maximum {1}",
+ averageDeviation, MAX_AVERAGE_DEVIATION));
+ }
+}
Added: root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/PushAttributes.java
===================================================================
--- root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/PushAttributes.java (rev 0)
+++ root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/PushAttributes.java 2010-07-10 21:11:41 UTC (rev 17907)
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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.testapp.a4jPush;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.id;
+import static org.jboss.test.selenium.SeleniumGetter.*;
+
+import org.jboss.test.selenium.framework.AjaxSelenium;
+import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
+import org.jboss.test.selenium.locator.ElementLocator;
+
+/**
+ * The control point for setting different attributes for a4j:push test page.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class PushAttributes {
+
+ private AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+
+ private ElementLocator attributeInterval = id("form:attributes:intervalInput");
+
+ public void setInterval(long miliseconds) {
+ selenium.type(attributeInterval, String.valueOf(miliseconds));
+ selenium.waitForPageToLoad();
+ }
+
+ public long getInterval() {
+ return getValue(attributeInterval).asLong();
+ }
+}
Added: root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/SimpleTestCase.java
===================================================================
--- root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/SimpleTestCase.java (rev 0)
+++ root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/SimpleTestCase.java 2010-07-10 21:11:41 UTC (rev 17907)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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.testapp.a4jPush;
+
+import static org.testng.Assert.assertNotSame;
+import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
+
+import java.io.IOException;
+
+import org.apache.commons.httpclient.HttpException;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for simple usage of a4j:push component.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class SimpleTestCase extends AbstractPushTestCase {
+ private static final long SIMPLE_INTERVAL = 2500;
+
+ /**
+ * <p>
+ * Sets the interval to value {@link #SIMPLE_INTERVAL}.
+ * </p>
+ *
+ * <p>
+ * Then try to generate push event, wait for client observation.
+ * </p>
+ *
+ * <p>
+ * Validates that counter is changed between iterations.
+ * </p>
+ */
+ @Test
+ public void testSimple() throws HttpException, IOException {
+ pushAttributes.setInterval(SIMPLE_INTERVAL);
+
+ int beginCounter = getCounter();
+ pushAndWait(1);
+ int endCounter = getCounter();
+
+ assertNotSame(beginCounter < endCounter, format(
+ "The counter before push is greater {0} or equal the end counter {1}", beginCounter, endCounter));
+ }
+}
14 years, 6 months
JBoss Rich Faces SVN: r17906 - root/tests/metamer/trunk/ftest/test-source/src/main/java/org/jboss/test/selenium.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-10 17:11:05 -0400 (Sat, 10 Jul 2010)
New Revision: 17906
Added:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/jboss/test/selenium/SeleniumGetter.java
Log:
added SeleniumGetter - abstract implementation and factory for simplified obtaining values, text and evaluation of scripts
Added: root/tests/metamer/trunk/ftest/test-source/src/main/java/org/jboss/test/selenium/SeleniumGetter.java
===================================================================
--- root/tests/metamer/trunk/ftest/test-source/src/main/java/org/jboss/test/selenium/SeleniumGetter.java (rev 0)
+++ root/tests/metamer/trunk/ftest/test-source/src/main/java/org/jboss/test/selenium/SeleniumGetter.java 2010-07-10 21:11:05 UTC (rev 17906)
@@ -0,0 +1,101 @@
+package org.jboss.test.selenium;
+
+import org.jboss.test.selenium.encapsulated.JavaScript;
+import org.jboss.test.selenium.framework.AjaxSelenium;
+import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
+import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.utils.PrimitiveUtils;
+import org.jboss.test.selenium.waiting.conversion.Convertor;
+
+public abstract class SeleniumGetter<P> {
+ protected AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+ protected P parameter;
+
+ public SeleniumGetter(P parameter) {
+ this.parameter = parameter;
+ }
+
+ protected abstract String obtainValue();
+
+ public Boolean asBoolean() {
+ return PrimitiveUtils.asBoolean(obtainValue());
+ }
+
+ public Integer asInteger() {
+ return PrimitiveUtils.asInteger(obtainValue());
+ }
+
+ public Long asLong() {
+ return PrimitiveUtils.asLong(obtainValue());
+ }
+
+ public Float asFloat() {
+ return PrimitiveUtils.asFloat(obtainValue());
+ }
+
+ public Double asDouble() {
+ return PrimitiveUtils.asDouble(obtainValue());
+ }
+
+ public <C> C convert(Convertor<String, C> converter) {
+ return converter.forwardConversion(obtainValue());
+ }
+
+ public static ValueGetter getValue(ElementLocator elementLocator) {
+ return new ValueGetter(elementLocator);
+ }
+
+ public static TextGetter getText(ElementLocator elementLocator) {
+ return new TextGetter(elementLocator);
+ }
+
+ public static Evaluator getEval(JavaScript script) {
+ return new Evaluator(script);
+ }
+
+ public static class ValueGetter extends SeleniumGetter<ElementLocator> {
+
+ public ValueGetter(ElementLocator parameter) {
+ super(parameter);
+ }
+
+ @Override
+ protected String obtainValue() {
+ return selenium.getValue(parameter);
+ }
+
+ }
+
+ public static class TextGetter extends SeleniumGetter<ElementLocator> {
+
+ public TextGetter(ElementLocator parameter) {
+ super(parameter);
+ }
+
+ @Override
+ protected String obtainValue() {
+ return selenium.getText(parameter);
+ }
+ }
+
+ public static class Evaluator extends SeleniumGetter<JavaScript> {
+
+ public Evaluator(JavaScript parameter) {
+ super(parameter);
+ }
+
+ @Override
+ protected String obtainValue() {
+ String evaluated = selenium.getEval(parameter);
+ evaluated = checkNull(evaluated);
+ return evaluated;
+ }
+ }
+
+ private static String checkNull(String evaluatedResult) {
+ if ("null".equals(evaluatedResult) || "undefined".equals(evaluatedResult)) {
+ return null;
+ }
+ return evaluatedResult;
+ }
+}
14 years, 6 months
JBoss Rich Faces SVN: r17905 - root/tests/metamer/trunk/ftest/test-source.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-10 17:10:38 -0400 (Sat, 10 Jul 2010)
New Revision: 17905
Modified:
root/tests/metamer/trunk/ftest/test-source/pom.xml
Log:
dependency on richfaces-selenium 1.5.0.Final
Modified: root/tests/metamer/trunk/ftest/test-source/pom.xml
===================================================================
--- root/tests/metamer/trunk/ftest/test-source/pom.xml 2010-07-10 21:10:25 UTC (rev 17904)
+++ root/tests/metamer/trunk/ftest/test-source/pom.xml 2010-07-10 21:10:38 UTC (rev 17905)
@@ -5,7 +5,7 @@
<parent>
<artifactId>root</artifactId>
<groupId>org.jboss.test.richfaces-selenium</groupId>
- <version>1.5.0-SNAPSHOT</version>
+ <version>1.5.0.Final</version>
</parent>
<groupId>org.richfaces.tests.testapp</groupId>
14 years, 6 months
JBoss Rich Faces SVN: r17904 - root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-10 17:10:25 -0400 (Sat, 10 Jul 2010)
New Revision: 17904
Modified:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/ScrollerTestCase.java
Log:
refactored ScrollerTestCase for EDT; completed JavaDoc
Modified: root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/ScrollerTestCase.java
===================================================================
--- root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/ScrollerTestCase.java 2010-07-10 21:09:59 UTC (rev 17903)
+++ root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/ScrollerTestCase.java 2010-07-10 21:10:25 UTC (rev 17904)
@@ -22,7 +22,6 @@
package org.richfaces.tests.testapp.richExtendedDataTable;
-import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardHttp;
import static org.jboss.test.selenium.locator.LocatorFactory.*;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
import static org.testng.Assert.assertEquals;
@@ -35,13 +34,17 @@
import org.testng.annotations.Test;
/**
- * Test case for page /faces/components/commandButton/simple.xhtml
+ * Test of DataScroller tied to Extended Data Table
*
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
public class ScrollerTestCase extends AbstractTestappTestCase {
+ private static final int TOTAL_ROW_COUNT = 50;
+ private static final Integer[] ROW_COUNT_VALUES =
+ new Integer[]{null, 10, 1, TOTAL_ROW_COUNT, 13, 9, 17, TOTAL_ROW_COUNT + 1, 2 * TOTAL_ROW_COUNT};
+
DataScroller dataScroller1 = new DataScroller(pjq("span.rf-ds[id$=scroller1]"));
DataScroller dataScroller2 = new DataScroller(pjq("span.rf-ds[id$=scroller2]"));
DataTable table = new DataTable(pjq("table.rf-dt[id$=richEDT]"));
@@ -52,24 +55,56 @@
return buildUrl(contextPath, "faces/components/richExtendedDataTable/scroller.xhtml");
}
- final static int TOTAL_ROW_COUNT = 50;
-
+ /**
+ * Tests row count for scroller in footer of the EDT.
+ *
+ * @see {@link #testRowCount(DataScroller)}
+ */
@Test(dataProvider = "templates", groups = "client-side-perf")
- public void testInternalDataScrollerRowCount(String templates) {
+ public void testRowCountFooterScroller(String templates) {
testRowCount(dataScroller2);
}
+ /**
+ * Tests row count for scroller outside of the EDT.
+ *
+ * @see {@link #testRowCount(DataScroller)}
+ */
@Test(dataProvider = "templates")
- public void testExternalDataScrollerRowCount(String templates) {
+ public void testRowCountOutsideTable(String templates) {
testRowCount(dataScroller1);
}
+ /**
+ * <p>
+ * Test the data scroller functionality for different values of row count
+ * </p>
+ *
+ * <p>
+ * If desired, sets the value of 'rows' first for each iteration.
+ * </p>
+ *
+ * <p>
+ * Then goes to first page and verifies that there is valid number of rows.
+ * </p>
+ *
+ * <p>
+ * Verifies that on the first page is less than total number of rows if the scroller has several pages.
+ * </p>
+ *
+ * <p>
+ * If the scroller has pages enabled, goes to last page and verifies that this is valid number of pages visible in
+ * scroller and the number of rows is valid.
+ * </p>
+ *
+ * <p>
+ */
private void testRowCount(DataScroller dataScroller) {
- for (Integer rowsPerPage : new Integer[]{null, 10, 1, TOTAL_ROW_COUNT, 13, 9, 17, TOTAL_ROW_COUNT + 1,
- 2 * TOTAL_ROW_COUNT}) {
+ for (Integer rowsPerPage : ROW_COUNT_VALUES) {
if (rowsPerPage != null) {
selenium.type(attributeRowsInput, String.valueOf(rowsPerPage));
- guardHttp(selenium).fireEvent(attributeRowsInput, Event.BLUR);
+ selenium.fireEvent(attributeRowsInput, Event.BLUR);
+ selenium.waitForPageToLoad();
}
dataScroller.gotoFirstPage();
@@ -81,27 +116,28 @@
if (dataScroller.hasPages()) {
dataScroller.gotoLastPage();
- int pagesExpected = pageCountActual(rowCountActual);
+ int pagesExpected = pageCountActualExpected(rowCountActual);
int countOfVisiblePages = dataScroller.getCountOfVisiblePages();
if (countOfVisiblePages < pagesExpected) {
int lastVisiblePage = dataScroller.getLastVisiblePage();
- assertEquals(lastVisiblePage, pageCountActual(rowCountActual));
+ assertEquals(lastVisiblePage, pageCountActualExpected(rowCountActual));
} else {
assertEquals(countOfVisiblePages, pagesExpected);
}
+ int rowCountExpected = rowCountLastPageExpected(rowCountPreset);
rowCountActual = table.getCountOfTableRows();
- assertEquals(rowCountActual, rowCountLastPage(rowCountPreset));
+ assertEquals(rowCountActual, rowCountExpected);
}
}
}
- int pageCountActual(int rowCountActual) {
+ private int pageCountActualExpected(int rowCountActual) {
return Double.valueOf(Math.ceil((double) TOTAL_ROW_COUNT / rowCountActual)).intValue();
}
- int rowCountLastPage(int rowCountPreset) {
+ private int rowCountLastPageExpected(int rowCountPreset) {
int result = TOTAL_ROW_COUNT % rowCountPreset;
return (result == 0) ? rowCountPreset : result;
}
14 years, 6 months
JBoss Rich Faces SVN: r17903 - root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPoll.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-10 17:09:59 -0400 (Sat, 10 Jul 2010)
New Revision: 17903
Modified:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPoll/PollTestCase.java
Log:
fixed and refactored PollTestCase
Modified: root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPoll/PollTestCase.java
===================================================================
--- root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPoll/PollTestCase.java 2010-07-10 21:09:34 UTC (rev 17902)
+++ root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPoll/PollTestCase.java 2010-07-10 21:09:59 UTC (rev 17903)
@@ -27,23 +27,27 @@
import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.testapp.AbstractTestappTestCase;
+import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
import static org.jboss.test.selenium.locator.LocatorFactory.*;
import static org.testng.Assert.*;
-import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.*;
import static org.jboss.test.selenium.SystemProperties.isSeleniumDebug;
import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
/**
+ * Tests the a4j:poll component.
+ *
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
public class PollTestCase extends AbstractTestappTestCase {
- private final static int MAX_DEVIATION = 250;
- private final static int MAX_AVERAGE_DEVIATION = 100;
+ private static final int[] TEST_INTERVAL_VALUES = new int[]{1000, 5000, 500};
+ private static final int TEST_INTERVAL_ITERATIONS = 5;
+ private static final int MAX_DEVIATION = 250;
+ private static final int MAX_AVERAGE_DEVIATION = 100;
ElementLocator attributeEnabled = id("form:attributes:enabledInput");
ElementLocator attributeInterval = id("form:attributes:intervalInput");
@@ -54,30 +58,59 @@
return buildUrl(contextPath, "faces/components/a4jPoll/simple.xhtml");
}
+ @AfterMethod(alwaysRun = true)
+ public void clearSession() {
+ invalidateSession();
+ }
+
+ /**
+ * <p>
+ * Test the progress of polling for 3 different values.
+ * </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 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>
+ */
@Test(dataProvider = "templates", groups = "client-side-perf")
- public void testPollInterval(String templates) {
+ public void testInterval(String templates) {
long total = 0;
long count = 0;
- for (int interval : new Integer[]{1000, 5000, 500}) {
+ for (int interval : TEST_INTERVAL_VALUES) {
selenium.type(attributeInterval, String.valueOf(interval));
- waitHttp(selenium).fireEvent(attributeInterval, Event.BLUR);
+ selenium.waitForPageToLoad();
selenium.check(attributeEnabled);
- waitHttp(selenium).fireEvent(attributeEnabled, Event.CHANGE);
+ selenium.fireEvent(attributeEnabled, Event.CHANGE);
+ selenium.waitForPageToLoad();
selenium.getPageExtensions().install();
- for (int i = 0; i <= 5; i++) {
- long time = System.currentTimeMillis();
+ for (int i = 0; i <= TEST_INTERVAL_ITERATIONS; i++) {
+ long runtime = System.currentTimeMillis();
selenium.getRequestInterceptor().clearRequestTypeDone();
selenium.getRequestInterceptor().waitForRequestTypeChange();
- time -= System.currentTimeMillis();
+ runtime -= System.currentTimeMillis();
if (i > 0) {
if (isSeleniumDebug()) {
- System.out.println(time);
+ System.out.println(runtime);
}
- long deviation = Math.abs(interval - Math.abs(time));
+ long deviation = Math.abs(interval - Math.abs(runtime));
assertTrue(deviation <= MAX_DEVIATION, format(
"Particular deviation ({2}) for interval {0} was greater than {1}", interval, MAX_DEVIATION,
deviation));
@@ -87,14 +120,16 @@
}
selenium.uncheck(attributeEnabled);
- guardHttp(selenium).fireEvent(attributeEnabled, Event.CHANGE);
+ selenium.fireEvent(attributeEnabled, Event.CHANGE);
+ selenium.waitForPageToLoad();
}
+
+ long averageDeviation = total / count;
if (isSeleniumDebug()) {
- System.out.println(total / count);
+ System.out.println(averageDeviation);
}
-
- long averageDeviation = (total / count);
+
assertTrue(averageDeviation <= MAX_AVERAGE_DEVIATION, format(
"Average deviation ({1}) was greater than given maximum {0}", MAX_AVERAGE_DEVIATION, averageDeviation));
14 years, 6 months
JBoss Rich Faces SVN: r17902 - root/tests/metamer/trunk/ftest.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-10 17:09:34 -0400 (Sat, 10 Jul 2010)
New Revision: 17902
Modified:
root/tests/metamer/trunk/ftest/pom.xml
Log:
tied on richfaces-selenium version 1.5.0.Final
Modified: root/tests/metamer/trunk/ftest/pom.xml
===================================================================
--- root/tests/metamer/trunk/ftest/pom.xml 2010-07-10 21:09:23 UTC (rev 17901)
+++ root/tests/metamer/trunk/ftest/pom.xml 2010-07-10 21:09:34 UTC (rev 17902)
@@ -10,7 +10,7 @@
<parent>
<artifactId>functional-test-jboss-ci-template</artifactId>
<groupId>org.jboss.test.richfaces-selenium</groupId>
- <version>1.5.0-SNAPSHOT</version>
+ <version>1.5.0.Final</version>
</parent>
<modules>
14 years, 6 months