Author: lfryc(a)redhat.com
Date: 2010-07-10 20:06:08 -0400 (Sat, 10 Jul 2010)
New Revision: 17914
Added:
root/tests/metamer/trunk/ftest/ftest-source/
root/tests/metamer/trunk/ftest/ftest-source/.gitignore
root/tests/metamer/trunk/ftest/ftest-source/pom.xml
root/tests/metamer/trunk/ftest/ftest-source/src/
root/tests/metamer/trunk/ftest/ftest-source/src/main/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/jboss/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/jboss/test/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/jboss/test/selenium/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/jboss/test/selenium/SeleniumGetter.java
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/jboss/test/selenium/javascript/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/jboss/test/selenium/javascript/JavaScriptEvaluator.java
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractTestappTestCase.java
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/A4JActionListenerTestCase.java
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/A4JCommandButtonTestCase.java
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/A4JCommandLinkTestCase.java
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/A4JLogTestCase.java
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/A4JOutputPanelTestCase.java
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/PollTestCase.java
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/AbstractPushTestCase.java
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/IntervalTestCase.java
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/PushAttributes.java
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/SimpleTestCase.java
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/HCommandButtonTestCase.java
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/ScrollerTestCase.java
Removed:
root/tests/metamer/trunk/ftest/test-source/.gitignore
root/tests/metamer/trunk/ftest/test-source/pom.xml
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/javascript/JavaScriptEvaluator.java
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/AbstractTestappTestCase.java
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jActionListener/A4JActionListenerTestCase.java
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/a4jLog/A4JLogTestCase.java
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jOutputPanel/A4JOutputPanelTestCase.java
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/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
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/richExtendedDataTable/DataScroller.java
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/DataTable.java
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/ScrollerTestCase.java
Modified:
root/tests/metamer/trunk/ftest/README.html
root/tests/metamer/trunk/ftest/pom.xml
root/tests/metamer/trunk/ftest/src/test/resources/testng.xml
Log:
testapp-tests refactored to place under metamer as metamer-ftest
Modified: root/tests/metamer/trunk/ftest/README.html
===================================================================
--- root/tests/metamer/trunk/ftest/README.html 2010-07-10 21:14:22 UTC (rev 17913)
+++ root/tests/metamer/trunk/ftest/README.html 2010-07-11 00:06:08 UTC (rev 17914)
@@ -1,13 +1,17 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
+<head>
<style>
body { font-family: sans-serif; }
h1 { color: darkblue; }
.indent { text-indent: 2em; }
-</style>
+</style>
+</head>
<body>
<h1>RichFaces-Demo - functional-test</h1>
+ <p>(Stub for the Metamer Functional Test)</p>
+
<h2>About</h2>
<h3>Introduction</h3>
@@ -139,10 +143,10 @@
<p class="indent"><tt>$ mvn verify <b>-DcontainerId=tomcat6x
-Dmaven.test.skip=true -P press-key-to-shutdown-server</b></tt></p>
<h4>Run Selenium server only</h4>
- <p class="indent"<tt>$ mvn verify <b>-P
'press-key-to-shutdown-server,local-selenim-session,!integration-test,!container-demoapp-deployable-dependency'</b></tt></p>
+ <p class="indent"><tt>$ mvn verify <b>-P
'press-key-to-shutdown-server,local-selenim-session,!integration-test,!container-demoapp-deployable-dependency'</b></tt></p>
<h4>Run integration test suite only</h4>
<p>If you have already running selenium server and container, you can just run a
test suite:</p>
- <p class="indent"<tt>$ mvn verify -Dbrowser="*firefox"
<b>-P
'!local-selenium-session,!container-demoapp-deployable-dependency'</b></tt></p>
+ <p class="indent"><tt>$ mvn verify -Dbrowser="*firefox"
<b>-P
'!local-selenium-session,!container-demoapp-deployable-dependency'</b></tt></p>
</body>
</html>
\ No newline at end of file
Copied: root/tests/metamer/trunk/ftest/ftest-source/.gitignore (from rev 17913,
root/tests/metamer/trunk/ftest/test-source/.gitignore)
===================================================================
--- root/tests/metamer/trunk/ftest/ftest-source/.gitignore (rev
0)
+++ root/tests/metamer/trunk/ftest/ftest-source/.gitignore 2010-07-11 00:06:08 UTC (rev
17914)
@@ -0,0 +1,5 @@
+/.classpath
+/.project
+/.settings
+/target
+/profiles.xml
Added: root/tests/metamer/trunk/ftest/ftest-source/pom.xml
===================================================================
--- root/tests/metamer/trunk/ftest/ftest-source/pom.xml (rev 0)
+++ root/tests/metamer/trunk/ftest/ftest-source/pom.xml 2010-07-11 00:06:08 UTC (rev
17914)
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>root</artifactId>
+ <groupId>org.jboss.test.richfaces-selenium</groupId>
+ <version>1.5.0.Final</version>
+ </parent>
+
+ <groupId>org.richfaces.tests</groupId>
+ <artifactId>metamer-ftest-source</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <name>Metamer: RichFaces Testing Application - Functional Test
Source</name>
+
+ <licenses>
+ <license>
+ <name>GNU Lesser General Public License, Version 2.1</name>
+ <distribution>repo</distribution>
+ <
url>http://www.gnu.org/licenses/lgpl-2.1.txt</url>
+ </license>
+ </licenses>
+
+ <scm>
+ <
connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/root/tests...
+ <
developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/root...
+ <
url>http://fisheye.jboss.org/browse/RichFaces/root/tests/metamer/trunk...
+ </scm>
+
+ <distributionManagement>
+ <snapshotRepository>
+ <id>jboss-qa-snapshots</id>
+ <name>JBoss QA snapshot repository</name>
+ <url>http://nexus.qa.jboss.com:8081/nexus/content/repositories/snapshots</url>
+ </snapshotRepository>
+ <repository>
+ <id>jboss-qa-releases</id>
+ <name>JBoss QA selease repository</name>
+ <url>http://nexus.qa.jboss.com:8081/nexus/content/repositories/releases</url>
+ </repository>
+ </distributionManagement>
+
+ <repositories>
+ <repository>
+ <id>jboss-qa-repository</id>
+ <url>http://nexus.qa.jboss.com:8081/nexus/content/groups/public-all</url>
+ </repository>
+ </repositories>
+
+ <developers>
+ <developer>
+ <name>Pavol Pitonak</name>
+ <email>ppitonak(a)redhat.com</email>
+ </developer>
+ <developer>
+ <name>Lukas Fryc</name>
+ <email>lfryc(a)redhat.com</email>
+ </developer>
+ </developers>
+
+ <issueManagement>
+ <system>jira</system>
+ <
url>https://jira.jboss.org/jira/browse/RFPL</url>
+ </issueManagement>
+
+ <dependencies>
+ <dependency>
+ <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>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Copied:
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/jboss/test/selenium/SeleniumGetter.java
(from rev 17913,
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/jboss/test/selenium/SeleniumGetter.java)
===================================================================
---
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/jboss/test/selenium/SeleniumGetter.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/jboss/test/selenium/SeleniumGetter.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -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;
+ }
+}
Copied:
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/jboss/test/selenium/javascript/JavaScriptEvaluator.java
(from rev 17913,
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/jboss/test/selenium/javascript/JavaScriptEvaluator.java)
===================================================================
---
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/jboss/test/selenium/javascript/JavaScriptEvaluator.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/jboss/test/selenium/javascript/JavaScriptEvaluator.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -0,0 +1,131 @@
+/*
+ * 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.jboss.test.selenium.javascript;
+
+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.waiting.conversion.Convertor;
+
+import static org.jboss.test.selenium.utils.PrimitiveUtils.*;
+
+/**
+ * Simplifies manipulation with results of evaluated JavaScript.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public final class JavaScriptEvaluator {
+
+ private static final AjaxSelenium SELENIUM = AjaxSeleniumProxy.getInstance();
+
+ private JavaScriptEvaluator() {
+ }
+
+ /**
+ * Returns the evaluated JavaScript result.
+ *
+ * @param script
+ * to evaluate
+ * @return the evaluated JavaScript result.
+ */
+ public static String evaluateString(JavaScript script) {
+ return checkNull(SELENIUM.getEval(script));
+ }
+
+ /**
+ * Returns the evaluated JavaScript result as Boolean.
+ *
+ * @param script
+ * to evaluate
+ * @return the evaluated JavaScript result as Boolean.
+ */
+ public static Boolean evaluateBoolean(JavaScript script) {
+ return asBoolean(checkNull(SELENIUM.getEval(script)));
+ }
+
+ /**
+ * Returns the evaluated JavaScript result as Float.
+ *
+ * @param script
+ * to evaluate
+ * @return the evaluated JavaScript result as Float.
+ */
+ public static Float evaluateFloat(JavaScript script) {
+ return asFloat(checkNull(SELENIUM.getEval(script)));
+ }
+
+ /**
+ * Returns the evaluated JavaScript result as Double.
+ *
+ * @param script
+ * to evaluate
+ * @return the evaluated JavaScript result as Double.
+ */
+ public static Double evaluateDouble(JavaScript script) {
+ return asDouble(checkNull(SELENIUM.getEval(script)));
+ }
+
+ /**
+ * Returns the evaluated JavaScript result as Long.
+ *
+ * @param script
+ * to evaluate
+ * @return the evaluated JavaScript result as Long.
+ */
+ public static Long evaluateLong(JavaScript script) {
+ return asLong(checkNull(SELENIUM.getEval(script)));
+ }
+
+ /**
+ * Returns the evaluated JavaScript result as Integer.
+ *
+ * @param script
+ * to evaluate
+ * @return the evaluated JavaScript result as Integer.
+ */
+ public static Integer evaluateInteger(JavaScript script) {
+ return asInteger(checkNull(SELENIUM.getEval(script)));
+ }
+
+ /**
+ * Returns the evaluated JavaScript result converted to T by specified converter.
+ *
+ * @param script
+ * the script to evaluate
+ * @return the evaluated JavaScript result converted to T by specified converter.
+ */
+ public static <T> T evaluate(JavaScript script, Convertor<String, T>
converter) {
+ String result = checkNull(SELENIUM.getEval(script));
+ if (result == null) {
+ return null;
+ }
+ return converter.forwardConversion(result);
+ }
+
+ private static String checkNull(String evaluatedResult) {
+ if ("null".equals(evaluatedResult) ||
"undefined".equals(evaluatedResult)) {
+ return null;
+ }
+ return evaluatedResult;
+ }
+}
Copied:
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractTestappTestCase.java
(from rev 17913,
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/AbstractTestappTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractTestappTestCase.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractTestappTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * 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;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.AbstractTestCase;
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.encapsulated.JavaScript;
+import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.testng.SkipException;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Optional;
+import org.testng.annotations.Parameters;
+
+/**
+ * Abstract test case used as a basis for majority of test cases.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public abstract class AbstractTestappTestCase extends AbstractTestCase {
+
+ /**
+ * timeout in miliseconds
+ */
+ public static final long TIMEOUT = 5000;
+ private String[][] templates;
+
+ /**
+ * Returns the url to test page to be opened by Selenium
+ *
+ * @return absolute url to the test page to be opened by Selenium
+ */
+ public abstract URL getTestUrl();
+
+ /**
+ * Data provider for templates.
+ *
+ * @return array containing templates that should be used (defined in testng.xml) or
default array (containing only
+ * plain template) if nothing is defined
+ */
+ @DataProvider(name = "templates")
+ protected Object[][] getTemplates() {
+ if (templates != null && templates.length > 0) {
+ return templates;
+ }
+
+ return new Object[][]{{"plain"}};
+ }
+
+ /**
+ * Loads and parses attribute "templates" from testng.xml.
+ *
+ * @param urlParams
+ */
+ @BeforeClass(alwaysRun = true)
+ @Parameters({"templates"})
+ public void initTemplates(@Optional String urlParams) {
+ if (urlParams == null) {
+ return;
+ }
+
+ String[] array = urlParams.split(" ");
+ templates = new String[array.length][];
+
+ for (int i = 0; i < array.length; i++) {
+ templates[i] = new String[1];
+ templates[i][0] = array[i];
+ }
+ }
+
+ /**
+ * Opens the tested page. If templates is not empty nor null, it appends url
parameter with templates.
+ *
+ * @param templates
+ * templates that will be used for test, e.g. "red_div"
+ */
+ @BeforeMethod(alwaysRun = true)
+ public void loadPage(Object[] templates) {
+ if (selenium == null) {
+ new SkipException("selenium isn't initialized");
+ }
+ String urlParams = "";
+ if (templates != null && templates.length != 0) {
+ urlParams = "?templates=" + templates[0];
+ }
+ selenium.open(buildUrl(getTestUrl() + urlParams));
+ selenium.waitForPageToLoad(TIMEOUT);
+ }
+
+ /**
+ * Invalidates session by clicking on a button on tested page.
+ */
+ public void invalidateSession() {
+ selenium.deleteAllVisibleCookies();
+ }
+
+ /**
+ * Forces the current thread sleep for given time.
+ *
+ * @param millis
+ * number of miliseconds for which the thread will sleep
+ */
+ @Deprecated
+ protected void waitFor(long millis) {
+ try {
+ Thread.sleep(millis);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Factory method for creating instances of class JQueryLocator which locates the
element using <a
+ *
href="http://api.jquery.com/category/selectors/">JQuery
Selector</a> syntax. It adds "div.content " in front of
+ * each selector.
+ *
+ * @param jquerySelector
+ * the jquery selector
+ * @return the j query locator
+ * @see JQueryLocator
+ */
+ public static JQueryLocator pjq(String jquerySelector) {
+ return new JQueryLocator("div.content " + jquerySelector);
+ }
+
+ /**
+ * A helper method for testing javascripts events. It sets
alert('testedevent') to the input field for given event
+ * and fires the event. Then it checks the message in the alert dialog.
+ *
+ * @param event
+ * JavaScript event to be tested
+ * @param element
+ * locator of tested element
+ */
+ protected void testFireEvent(Event event, ElementLocator element) {
+ ElementLocator eventInput = pjq("input[id$=on" + event.getEventName() +
"Input]");
+ final String value = "alert('" + event.getEventName() +
"')";
+
+ selenium.type(eventInput, value);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ selenium.fireEvent(element, event);
+
+ assertEquals(selenium.getAlert(), event.getEventName(), event.getEventName()
+ + " attribute did not change correctly");
+ }
+
+ /**
+ * Hides header, footer and inputs for attributes.
+ */
+ protected void hideControls() {
+ selenium.getEval(new JavaScript("window.hideControls()"));
+ }
+
+ /**
+ * Shows header, footer and inputs for attributes.
+ */
+ protected void showControls() {
+ selenium.getEval(new JavaScript("window.showControls()"));
+ }
+
+}
Copied:
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/A4JActionListenerTestCase.java
(from rev 17913,
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jActionListener/A4JActionListenerTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/A4JActionListenerTestCase.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/A4JActionListenerTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * 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.a4jActionListener;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.richfaces.tests.metamer.ftest.AbstractTestappTestCase;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/a4jActionListener/all.xhtml
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class A4JActionListenerTestCase extends AbstractTestappTestCase {
+
+ private ElementLocator invokeButtonType =
pjq("input[id$=invokeByTypeButton]");
+ private ElementLocator invokeButtonBinding =
pjq("input[id$=invokeByBindingButton]");
+ private ElementLocator invokeButtonMethod =
pjq("input[id$=invokeMethodButton]");
+ private ElementLocator invokeButtonCC =
pjq("input[id$=invokeFromCCButton:button]");
+ private JQueryLocator message = pjq("ul[id$=messages] li");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/a4jActionListener/all.xhtml");
+ }
+
+ @Override
+ @AfterMethod(alwaysRun = true)
+ public void invalidateSession() {
+ super.invalidateSession();
+ }
+
+ @Test(dataProvider = "templates")
+ public void testInvokeListenerByType(String templates) {
+ final String hashCodeRegExp = "@[0-9a-fA-F]{1,}$";
+ final String msg = "Implementation of ActionListener created and called:
"
+ +
"org.richfaces.tests.metamer.bean.A4JActionListenerBean$ActionListenerImpl";
+
+ selenium.click(invokeButtonType);
+ waitGui.until(elementPresent.locator(message));
+ String output1 = selenium.getText(message);
+
+ assertEquals(output1.replaceAll(hashCodeRegExp, ""), msg, "Message
after first invocation of listener by type.");
+
+ int count = selenium.getCount(message);
+ assertEquals(count, 1, "Only one message should be displayed on the
page.");
+
+ // do the same once again
+
+ selenium.click(invokeButtonType);
+ waitGui.until(elementPresent.locator(message));
+ String output2 = selenium.getText(message);
+
+ assertEquals(output2.replaceAll(hashCodeRegExp, ""), msg, "Message
after second invocation of listener by type");
+
+ // check that a new object of ActionListenerImpl was created
+ String hashcode1 = output1.replace(msg, "");
+ String hashcode2 = output2.replace(msg, "");
+ assertFalse(hashcode1.equals(hashcode2), "New object of class
ActionListenerImpl should be instantiated.");
+
+ count = selenium.getCount(message);
+ assertEquals(count, 1, "Only one message should be displayed on the
page.");
+
+ }
+
+ @Test(dataProvider = "templates")
+ public void testInvokeListenerByBinding(String templates) {
+ final String msg = "Bound listener called";
+
+ selenium.click(invokeButtonBinding);
+ waitGui.until(elementPresent.locator(message));
+ String output = selenium.getText(message);
+
+ assertEquals(output, msg, "Message after first invocation of listener by
binding.");
+
+ int count = selenium.getCount(message);
+ assertEquals(count, 1, "Only one message should be displayed on the
page.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testInvokeListenerMethod(String templates) {
+ final String msg = "Method expression listener called";
+
+ selenium.click(invokeButtonMethod);
+ waitGui.until(elementPresent.locator(message));
+ String output = selenium.getText(message);
+
+ assertEquals(output, msg, "Message after first invocation of listener
method.");
+
+ int count = selenium.getCount(message);
+ assertEquals(count, 1, "Only one message should be displayed on the
page.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testInvokeListenerMethodCC(String templates) {
+ final String msg = "Method expression listener called from composite
component";
+
+ selenium.click(invokeButtonCC);
+ waitGui.until(elementPresent.locator(message));
+ String output = selenium.getText(message);
+
+ assertEquals(output, msg, "Message after first invocation of listener method
from composite component.");
+
+ int count = selenium.getCount(message);
+ assertEquals(count, 1, "Only one message should be displayed on the
page.");
+ }
+}
Copied:
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/A4JCommandButtonTestCase.java
(from rev 17913,
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandButton/A4JCommandButtonTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/A4JCommandButtonTestCase.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/A4JCommandButtonTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -0,0 +1,320 @@
+/*******************************************************************************
+ * 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.a4jCommandButton;
+
+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.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.richfaces.tests.metamer.ftest.AbstractTestappTestCase;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/a4jCommandButton/simple.xhtml
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class A4JCommandButtonTestCase extends AbstractTestappTestCase {
+
+ private ElementLocator input = pjq("input[id$=input]");
+ private ElementLocator button = pjq("input[id$=a4jCommandButton]");
+ private ElementLocator output1 = pjq("span[id$=output1]");
+ private ElementLocator output2 = pjq("span[id$=output2]");
+ private ElementLocator output3 = pjq("span[id$=output3]");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/a4jCommandButton/simple.xhtml");
+ }
+
+ @Override
+ @AfterMethod(alwaysRun = true)
+ public void invalidateSession() {
+ super.invalidateSession();
+ }
+
+ @Test(dataProvider = "templates", groups = "client-side-perf")
+ public void testSimpleClick(String templates) {
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(button);
+
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
+
+ String output = selenium.getText(output1);
+ assertEquals(output, "RichFaces 4", "output1 when 'RichFaces
4' in input");
+
+ output = selenium.getText(output2);
+ assertEquals(output, "RichFa", "output2 when 'RichFaces 4'
in input");
+
+ output = selenium.getText(output3);
+ assertEquals(output, "RICHFACES 4", "output3 when 'RichFaces
4' in input");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testSimpleClickUnicode(String templates) {
+ selenium.typeKeys(input, "ľščťžýáíéňô");
+ selenium.click(button);
+
+ waitGui.until(textEquals.locator(output1).text("ľščťžýáíéňô"));
+
+ String output = selenium.getText(output1);
+ assertEquals(output, "ľščťžýáíéňô", "output1 when
'ľščťžýáíéňô' in input");
+
+ output = selenium.getText(output2);
+ assertEquals(output, "ľščťžý", "output2 when 'ľščťžýáíéňô'
in input");
+
+ output = selenium.getText(output3);
+ assertEquals(output, "ĽŠČŤŽÝÁÍÉŇÔ", "output3 when
'ľščťžýáíéňô' in input");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testAction(String templates) {
+ ElementLocator doubleStringAction =
pjq("input[value=doubleStringAction]");
+ ElementLocator first6CharsAction =
pjq("input[value=first6CharsAction]");
+ ElementLocator toUpperCaseAction =
pjq("input[value=toUpperCaseAction]");
+
+ selenium.click(doubleStringAction);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(button);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
+ String output = selenium.getText(output2);
+ assertEquals(output, "RichFaces 4RichFaces 4",
+ "output2 when 'RichFaces 4' in input and doubleStringAction
selected");
+
+ selenium.click(first6CharsAction);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4ň");
+ selenium.click(button);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4ň"));
+ output = selenium.getText(output2);
+ assertEquals(output, "RichFa", "output2 when 'RichFaces
4ň' in input and first6CharsAction selected");
+
+ selenium.click(toUpperCaseAction);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4ě");
+ selenium.click(button);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4ě"));
+ output = selenium.getText(output2);
+ assertEquals(output, "RICHFACES 4Ě", "output2 when 'RichFaces
4ě' in input and toUpperCaseAction selected");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testActionListener(String templates) {
+ ElementLocator doubleStringActionListener =
pjq("input[value=doubleStringActionListener]");
+ ElementLocator first6CharsActionListener =
pjq("input[value=first6CharsActionListener]");
+ ElementLocator toUpperCaseActionListener =
pjq("input[value=toUpperCaseActionListener]");
+
+ selenium.click(doubleStringActionListener);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(button);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
+ String output = selenium.getText(output3);
+ assertEquals(output, "RichFaces 4RichFaces 4",
+ "output2 when 'RichFaces 4' in input and
doubleStringActionListener selected");
+
+ selenium.click(first6CharsActionListener);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4ň");
+ selenium.click(button);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4ň"));
+ output = selenium.getText(output3);
+ assertEquals(output, "RichFa", "output2 when 'RichFaces
4ň' in input and first6CharsActionListener selected");
+
+ selenium.click(toUpperCaseActionListener);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4ě");
+ selenium.click(button);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4ě"));
+ output = selenium.getText(output3);
+ assertEquals(output, "RICHFACES 4Ě",
+ "output2 when 'RichFaces 4ě' in input and
toUpperCaseActionListener selected");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testDisabled(String templates) {
+ ElementLocator disabledChecbox = pjq("input[id$=disabledInput]");
+ AttributeLocator disabledAttribute = button.getAttribute(new
Attribute("disabled"));
+
+ selenium.click(disabledChecbox);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ String isDisabled = selenium.getAttribute(disabledAttribute);
+ assertEquals(isDisabled.toLowerCase(), "disabled", "The value of
attribute disabled");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnclick(String templates) {
+ testFireEvent(Event.CLICK, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOndblclick(String templates) {
+ testFireEvent(Event.DBLCLICK, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnkeydown(String templates) {
+ testFireEvent(Event.KEYDOWN, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnkeypress(String templates) {
+ testFireEvent(Event.KEYPRESS, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOneyup(String templates) {
+ testFireEvent(Event.KEYUP, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmousedown(String templates) {
+ testFireEvent(Event.MOUSEDOWN, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmousemove(String templates) {
+ testFireEvent(Event.MOUSEMOVE, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseout(String templates) {
+ testFireEvent(Event.MOUSEOUT, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseover(String templates) {
+ testFireEvent(Event.MOUSEOVER, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseup(String templates) {
+ testFireEvent(Event.MOUSEUP, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testRender(String templates) {
+ ElementLocator renderInput = pjq("input[name$=renderInput]");
+
+ selenium.type(renderInput, "output1");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ selenium.typeKeys(input, "aaa");
+ selenium.click(button);
+
+ waitGui.until(textEquals.locator(output1).text("aaa"));
+
+ String output = selenium.getText(output1);
+ assertEquals(output, "aaa", "output1 when 'aaa' in input
and 'output1' set to be rerendered");
+
+ output = selenium.getText(output2);
+ assertEquals(output, "", "output2 when 'aaa' in input and
'output1' set to be rerendered");
+
+ output = selenium.getText(output3);
+ assertEquals(output, "", "output3 when 'aaa' in input and
'output1' set to be rerendered");
+
+ selenium.type(renderInput, "output2 output3");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ selenium.typeKeys(input, "bbb");
+ selenium.click(button);
+
+ waitGui.until(textEquals.locator(output2).text("bbb"));
+
+ output = selenium.getText(output1);
+ assertEquals(output, "aaa", "output1 when 'bbb' in input
and 'output2 output3' set to be rerendered");
+
+ output = selenium.getText(output2);
+ assertEquals(output, "bbb", "output2 when 'bbb' in input
and 'output2 output3' set to be rerendered");
+
+ output = selenium.getText(output3);
+ assertEquals(output, "BBB", "output3 when 'bbb' in input
and 'output2 output3' set to be rerendered");
+
+ }
+
+ @Test(dataProvider = "templates")
+ public void testRendered(String templates) {
+ ElementLocator renderedCheckbox = pjq("input[name$=renderedInput]");
+
+ selenium.click(renderedCheckbox);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertFalse(selenium.isElementPresent(button), "Button should not be
displayed");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testStyleClass(String templates) {
+ ElementLocator wide = pjq("input[name$=styleClassInput][value=wide]");
+ ElementLocator big = pjq("input[name$=styleClassInput][value=big]");
+ ElementLocator none = pjq("input[name$=styleClassInput][value=]");
+
+ final AttributeLocator classAttribute = button.getAttribute(new
Attribute("class"));
+
+ selenium.click(wide);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.belongsClass(button, "wide"), "Button's
class was not changed to 'wide'");
+
+ selenium.click(big);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.belongsClass(button, "big"), "Button's
class was not changed to 'big'");
+
+ selenium.click(none);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertFalse(selenium.isAttributePresent(classAttribute), "Button's class
was not removed.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testStyle(String templates) {
+ ElementLocator styleInput = pjq("input[id$=styleInput]");
+ final AttributeLocator attribute = button.getAttribute(new
Attribute("style"));
+ final String value = "font-size: 20px;";
+
+ selenium.type(styleInput, value);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ assertEquals(selenium.getAttribute(attribute), value, "Style of the button
did not change");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testValue(String templates) {
+ ElementLocator valueInput = pjq("input[id$=valueInput]");
+ final AttributeLocator attribute = button.getAttribute(new
Attribute("value"));
+ final String value = "new label";
+
+ selenium.type(valueInput, value);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ assertEquals(selenium.getAttribute(attribute), value, "Value of the button
did not change");
+ }
+
+}
Copied:
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/A4JCommandLinkTestCase.java
(from rev 17913,
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandLink/A4JCommandLinkTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/A4JCommandLinkTestCase.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/A4JCommandLinkTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -0,0 +1,336 @@
+/*******************************************************************************
+ * 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.a4jCommandLink;
+
+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.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.richfaces.tests.metamer.ftest.AbstractTestappTestCase;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/a4jCommandLink/simple.xhtml
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class A4JCommandLinkTestCase extends AbstractTestappTestCase {
+
+ private ElementLocator input = pjq("input[id$=input]");
+ private ElementLocator link = pjq("a[id$=a4jCommandLink]");
+ private ElementLocator output1 = pjq("span[id$=output1]");
+ private ElementLocator output2 = pjq("span[id$=output2]");
+ private ElementLocator output3 = pjq("span[id$=output3]");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/a4jCommandLink/simple.xhtml");
+ }
+
+ @Override
+ @AfterMethod(alwaysRun = true)
+ public void invalidateSession() {
+ super.invalidateSession();
+ }
+
+ @Test(dataProvider = "templates", groups = "client-side-perf")
+ public void testSimpleClick(String templates) {
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(link);
+
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
+
+ String output = selenium.getText(output1);
+ assertEquals(output, "RichFaces 4", "output1 when 'RichFaces
4' in input");
+
+ output = selenium.getText(output2);
+ assertEquals(output, "RichFa", "output2 when 'RichFaces 4'
in input");
+
+ output = selenium.getText(output3);
+ assertEquals(output, "RICHFACES 4", "output3 when 'RichFaces
4' in input");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testSimpleClickUnicode(String templates) {
+ selenium.typeKeys(input, "ľščťžýáíéňô");
+ selenium.click(link);
+
+ waitGui.until(textEquals.locator(output1).text("ľščťžýáíéňô"));
+
+ String output = selenium.getText(output1);
+ assertEquals(output, "ľščťžýáíéňô", "output1 when
'ľščťžýáíéňô' in input");
+
+ output = selenium.getText(output2);
+ assertEquals(output, "ľščťžý", "output2 when 'ľščťžýáíéňô'
in input");
+
+ output = selenium.getText(output3);
+ assertEquals(output, "ĽŠČŤŽÝÁÍÉŇÔ", "output3 when
'ľščťžýáíéňô' in input");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testAction(String templates) {
+ ElementLocator doubleStringAction =
pjq("input[value=doubleStringAction]");
+ ElementLocator first6CharsAction =
pjq("input[value=first6CharsAction]");
+ ElementLocator toUpperCaseAction =
pjq("input[value=toUpperCaseAction]");
+
+ selenium.click(doubleStringAction);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(link);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
+ String output = selenium.getText(output2);
+ assertEquals(output, "RichFaces 4RichFaces 4",
+ "output2 when 'RichFaces 4' in input and doubleStringAction
selected");
+
+ selenium.click(first6CharsAction);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4ň");
+ selenium.click(link);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4ň"));
+ output = selenium.getText(output2);
+ assertEquals(output, "RichFa", "output2 when 'RichFaces
4ň' in input and first6CharsAction selected");
+
+ selenium.click(toUpperCaseAction);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4ě");
+ selenium.click(link);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4ě"));
+ output = selenium.getText(output2);
+ assertEquals(output, "RICHFACES 4Ě", "output2 when 'RichFaces
4ě' in input and toUpperCaseAction selected");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testActionListener(String templates) {
+ ElementLocator doubleStringActionListener =
pjq("input[value=doubleStringActionListener]");
+ ElementLocator first6CharsActionListener =
pjq("input[value=first6CharsActionListener]");
+ ElementLocator toUpperCaseActionListener =
pjq("input[value=toUpperCaseActionListener]");
+
+ selenium.click(doubleStringActionListener);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(link);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
+ String output = selenium.getText(output3);
+ assertEquals(output, "RichFaces 4RichFaces 4",
+ "output2 when 'RichFaces 4' in input and
doubleStringActionListener selected");
+
+ selenium.click(first6CharsActionListener);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4ň");
+ selenium.click(link);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4ň"));
+ output = selenium.getText(output3);
+ assertEquals(output, "RichFa", "output2 when 'RichFaces
4ň' in input and first6CharsActionListener selected");
+
+ selenium.click(toUpperCaseActionListener);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4ě");
+ selenium.click(link);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4ě"));
+ output = selenium.getText(output3);
+ assertEquals(output, "RICHFACES 4Ě",
+ "output2 when 'RichFaces 4ě' in input and
toUpperCaseActionListener selected");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testDisabled(String templates) {
+ ElementLocator disabledChecbox = pjq("input[id$=disabledInput]");
+ ElementLocator newLink = pjq("span[id$=a4jCommandLink]");
+
+ selenium.click(disabledChecbox);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ assertFalse(selenium.isElementPresent(link), link.getAsString()
+ + " should not be on page when the link is disabled");
+ assertTrue(selenium.isElementPresent(newLink), newLink.getAsString()
+ + " should be on page when the link is disabled");
+
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnclick(String templates) {
+ testFireEvent(Event.CLICK, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOndblclick(String templates) {
+ testFireEvent(Event.DBLCLICK, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnkeydown(String templates) {
+ testFireEvent(Event.KEYDOWN, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnkeypress(String templates) {
+ testFireEvent(Event.KEYPRESS, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOneyup(String templates) {
+ testFireEvent(Event.KEYUP, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmousedown(String templates) {
+ testFireEvent(Event.MOUSEDOWN, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmousemove(String templates) {
+ testFireEvent(Event.MOUSEMOVE, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseout(String templates) {
+ testFireEvent(Event.MOUSEOUT, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseover(String templates) {
+ testFireEvent(Event.MOUSEOVER, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseup(String templates) {
+ testFireEvent(Event.MOUSEUP, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testRender(String templates) {
+ ElementLocator renderInput = pjq("input[name$=renderInput]");
+
+ selenium.type(renderInput, "output1");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ selenium.typeKeys(input, "aaa");
+ selenium.click(link);
+
+ waitGui.until(textEquals.locator(output1).text("aaa"));
+
+ String output = selenium.getText(output1);
+ assertEquals(output, "aaa", "output1 when 'aaa' in input
and 'output1' set to be rerendered");
+
+ output = selenium.getText(output2);
+ assertEquals(output, "", "output2 when 'aaa' in input and
'output1' set to be rerendered");
+
+ output = selenium.getText(output3);
+ assertEquals(output, "", "output3 when 'aaa' in input and
'output1' set to be rerendered");
+
+ selenium.type(renderInput, "output2 output3");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ selenium.typeKeys(input, "bbb");
+ selenium.click(link);
+
+ waitGui.until(textEquals.locator(output2).text("bbb"));
+
+ output = selenium.getText(output1);
+ assertEquals(output, "aaa", "output1 when 'bbb' in input
and 'output2 output3' set to be rerendered");
+
+ output = selenium.getText(output2);
+ assertEquals(output, "bbb", "output2 when 'bbb' in input
and 'output2 output3' set to be rerendered");
+
+ output = selenium.getText(output3);
+ assertEquals(output, "BBB", "output3 when 'bbb' in input
and 'output2 output3' set to be rerendered");
+
+ }
+
+ @Test(dataProvider = "templates")
+ public void testRendered(String templates) {
+ ElementLocator renderedCheckbox = pjq("input[name$=renderedInput]");
+
+ selenium.click(renderedCheckbox);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertFalse(selenium.isElementPresent(link), "Button should not be
displayed");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testStyleClass(String templates) {
+ ElementLocator bold = pjq("input[name$=styleClassInput][value=bold]");
+ ElementLocator strike =
pjq("input[name$=styleClassInput][value=strike]");
+ ElementLocator none = pjq("input[name$=styleClassInput][value=]");
+
+ final AttributeLocator classAttribute = link.getAttribute(new
Attribute("class"));
+
+ selenium.click(bold);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.belongsClass(link, "bold"), "Button's
class was not changed to 'bold'");
+
+ selenium.click(strike);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.belongsClass(link, "strike"), "Button's
class was not changed to 'strike'");
+
+ selenium.click(none);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertFalse(selenium.isAttributePresent(classAttribute), "Button's class
was not removed.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testStyle(String templates) {
+ ElementLocator styleInput = pjq("input[id$=styleInput]");
+ final AttributeLocator attribute = link.getAttribute(new
Attribute("style"));
+ final String value = "font-size: 20px;";
+
+ selenium.type(styleInput, value);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ assertEquals(selenium.getAttribute(attribute), value, "Style of the button
did not change");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testValue(String templates) {
+ ElementLocator valueInput = pjq("input[id$=valueInput]");
+ final String value = "new label";
+
+ selenium.type(valueInput, value);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ assertEquals(selenium.getText(link), value, "Value of the button did not
change");
+ }
+
+ private void testFireEvent(Event event) {
+ ElementLocator eventInput = pjq("input[id$=on" + event.getEventName() +
"Input]");
+ final String value = "alert('" + event.getEventName() +
"')";
+
+ selenium.type(eventInput, value);
+ selenium.fireEvent(eventInput, Event.BLUR);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ selenium.fireEvent(link, event);
+
+ assertEquals(selenium.getAlert(), event.getEventName(), event.getEventName()
+ + " attribute did not change correctly");
+ }
+
+}
Copied:
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/A4JLogTestCase.java
(from rev 17913,
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jLog/A4JLogTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/A4JLogTestCase.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/A4JLogTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -0,0 +1,234 @@
+/*******************************************************************************
+ * 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.a4jLog;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+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.ElementLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.richfaces.tests.metamer.ftest.AbstractTestappTestCase;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/a4jLog/simple.xhtml
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class A4JLogTestCase extends AbstractTestappTestCase {
+
+ /**
+ * Enumeration representing all possible levels for a4j:log.
+ */
+ public enum LogLevel {
+ DEBUG, INFO, WARN, ERROR;
+ }
+
+ private ElementLocator input = pjq("input[id$=nameInput]");
+ private ElementLocator submitButton = pjq("input[id$=submitButton]");
+ private ElementLocator output = pjq("span[id$=out]");
+
+ private ElementLocator log = pjq("div.rich-log");
+ private ElementLocator levelSelect = pjq("div.rich-log select");
+ private JQueryLocator logMsg = pjq("div.rich-log div.rich-log-contents
div");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/a4jLog/simple.xhtml");
+ }
+
+ @Override
+ @AfterMethod(alwaysRun = true)
+ public void invalidateSession() {
+ super.invalidateSession();
+ }
+
+ @Test(dataProvider = "templates")
+ public void testSubmit(String templates) {
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(submitButton);
+
+ waitGui.until(textEquals.locator(output).text("Hello RichFaces 4!"));
+
+ int count = selenium.getCount(logMsg);
+ assertTrue(count > 0, "There should be at least one message in log after
submit button was clicked.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testSubmitUnicode(String templates) {
+ selenium.typeKeys(input, "ľščťžýáíéôúäň");
+ selenium.click(submitButton);
+
+ waitGui.until(textEquals.locator(output).text("Hello
ľščťžýáíéôúäň!"));
+
+ int count = selenium.getCount(logMsg);
+ assertTrue(count > 0, "There should be at least one message in log after
submit button was clicked.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testClearButton(String templates) {
+ ElementLocator clearButton = pjq("div.rich-log button");
+
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(submitButton);
+
+ waitGui.until(textEquals.locator(output).text("Hello RichFaces 4!"));
+
+ int count = selenium.getCount(logMsg);
+ assertTrue(count > 0, "There should be at least one message in log after
submit button was clicked.");
+
+ // test clear
+ selenium.click(clearButton);
+ count = selenium.getCount(logMsg);
+ assertEquals(count, 0, "There should be no messages in log after clear
button was clicked.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testRendered(String templates) {
+ ElementLocator renderedInput = pjq("input[id$=renderedInput]");
+
+ selenium.click(renderedInput);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ assertFalse(selenium.isElementPresent(log), "Log should not be
displayed.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testDebugFilterDebug(String templates) {
+ testLogging(LogLevel.DEBUG, LogLevel.DEBUG);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testDebugFilterInfo(String templates) {
+ testLogging(LogLevel.DEBUG, LogLevel.INFO);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testDebugFilterWarn(String templates) {
+ testLogging(LogLevel.DEBUG, LogLevel.WARN);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testDebugFilterError(String templates) {
+ testLogging(LogLevel.DEBUG, LogLevel.ERROR);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testInfoFilterDebug(String templates) {
+ testLogging(LogLevel.INFO, LogLevel.DEBUG);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testInfoFilterInfo(String templates) {
+ testLogging(LogLevel.INFO, LogLevel.INFO);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testInfoFilterWarn(String templates) {
+ testLogging(LogLevel.INFO, LogLevel.WARN);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testInfoFilterError(String templates) {
+ testLogging(LogLevel.INFO, LogLevel.ERROR);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testWarnFilterDebug(String templates) {
+ testLogging(LogLevel.WARN, LogLevel.DEBUG);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testWarnFilterInfo(String templates) {
+ testLogging(LogLevel.WARN, LogLevel.INFO);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testWarnFilterWarn(String templates) {
+ testLogging(LogLevel.WARN, LogLevel.WARN);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testWarnFilterError(String templates) {
+ testLogging(LogLevel.WARN, LogLevel.ERROR);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testErrorFilterDebug(String templates) {
+ testLogging(LogLevel.ERROR, LogLevel.DEBUG);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testErrorFilterInfo(String templates) {
+ testLogging(LogLevel.ERROR, LogLevel.INFO);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testErrorFilterWarn(String templates) {
+ testLogging(LogLevel.ERROR, LogLevel.WARN);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testErrorFilterError(String templates) {
+ testLogging(LogLevel.ERROR, LogLevel.ERROR);
+ }
+
+ private void testLogging(LogLevel logLevel, LogLevel filterLevel) {
+ ElementLocator logButton = pjq("input[id$=" +
logLevel.toString().toLowerCase() + "Button]");
+ ElementLocator levelInput = pjq("input[type=radio][value=" +
filterLevel.toString().toLowerCase() + "]");
+ ElementLocator msgType = logMsg.getChild(jq("span:eq(0)"));
+ ElementLocator msgContent = logMsg.getChild(jq("span:eq(1)"));
+
+ if (filterLevel != LogLevel.DEBUG) {
+ selenium.click(levelInput);
+ selenium.waitForPageToLoad(TIMEOUT);
+ }
+
+ String selectedLevel = selenium.getSelectedLabel(levelSelect);
+ assertEquals(selectedLevel, filterLevel.toString().toLowerCase(), "Log level
in select wasn't changed.");
+
+ selenium.typeKeys(input, logLevel.toString());
+ selenium.click(logButton);
+
+ int count = selenium.getCount(logMsg);
+ assertEquals(count, filterLevel.ordinal() <= logLevel.ordinal() ? 1 : 0,
+ "There should be only one message in log.");
+
+ if (count == 0) {
+ return;
+ }
+
+ String output = selenium.getText(msgType).replaceAll("\\[.*\\]:$",
"");
+ assertEquals(output, logLevel.toString().toLowerCase(), "Message type in
log.");
+ output = selenium.getText(msgContent);
+ assertEquals(output, logLevel.toString(), "Message content.");
+
+ }
+}
Copied:
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/A4JOutputPanelTestCase.java
(from rev 17913,
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jOutputPanel/A4JOutputPanelTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/A4JOutputPanelTestCase.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/A4JOutputPanelTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -0,0 +1,307 @@
+/*******************************************************************************
+ * 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.a4jOutputPanel;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+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.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.richfaces.tests.metamer.ftest.AbstractTestappTestCase;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/a4jOutputPanel/simple.xhtml
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class A4JOutputPanelTestCase extends AbstractTestappTestCase {
+
+ private ElementLocator increaseCounterButton = pjq("input[id$=button]");
+ private ElementLocator outputDiv = pjq("div[id$=outputPanel]");
+ private ElementLocator outputSpan = pjq("span[id$=outputPanel]");
+ private ElementLocator optionBlue =
pjq("input[name$=styleClassInput][value=blue-background]");
+ private ElementLocator optionGray =
pjq("input[name$=styleClassInput][value=gray-background]");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/a4jOutputPanel/simple.xhtml");
+ }
+
+ @Override
+ @AfterMethod(alwaysRun = true)
+ public void invalidateSession() {
+ super.invalidateSession();
+ }
+
+ /**
+ * Data provider for templates, events and layout of output panel.
+ *
+ * @return array containing templates that should be used (defined in testng.xml) or
default array (containing only
+ * plain template) if nothing is defined, JavaScript events that are defined
for output panel and layout of
+ * panel (block or inline)
+ */
+ @DataProvider(name = "templatesEventsLayouts")
+ private Object[][] getTemplatesEventsLayouts() {
+ final int layoutsCount = 2;
+ // list of templates, e.g. {{"plain"},
{"richDataTable1,redDiv"}}
+ Object[][] templates = getTemplates();
+ // list of events that will be tested
+ Event[] events = new Event[]{Event.CLICK, Event.DBLCLICK, Event.KEYDOWN,
Event.KEYPRESS, Event.KEYUP,
+ Event.MOUSEDOWN, Event.MOUSEMOVE, Event.MOUSEOUT, Event.MOUSEOVER,
Event.MOUSEUP};
+
+ Object[][] result = new Object[templates.length * events.length *
layoutsCount][];
+ int index = 0;
+
+ for (int i = 0; i < templates.length; i++) {
+ for (int j = 0; j < events.length; j++) {
+ for (int k = 0; k < layoutsCount; k++) {
+ index = i * events.length * layoutsCount + j * layoutsCount + k;
+ result[index] = new Object[]{templates[i][0], events[j], k == 0 ?
"block" : "inline"};
+ }
+ }
+ }
+
+ return result;
+ }
+
+ @Test(dataProvider = "templatesEventsLayouts")
+ public void testEvent(String templates, Event event, String type) {
+ ElementLocator element = null;
+
+ if ("inline".equals(type)) {
+ // for inline layout set background to blue
+ selenium.click(pjq("input[name$=layoutInput][value=inline]"));
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ selenium.click(optionBlue);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ element = outputSpan;
+ } else {
+ // for inline layout set background to gray
+ selenium.click(optionGray);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ element = outputDiv;
+ }
+
+ testFireEvent(event, element);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testClick(String templates) {
+ selenium.click(increaseCounterButton);
+ waitGui.until(textEquals.locator(outputDiv).text("1"));
+
+ selenium.click(increaseCounterButton);
+ waitGui.until(textEquals.locator(outputDiv).text("2"));
+ }
+
+ @Test(dataProvider = "templates")
+ public void testAjaxRendered(String templates) {
+ ElementLocator ajaxRenderedCheckbox =
pjq("input[id$=ajaxRenderedInput]");
+ ElementLocator reRenderAllImage = jq("div.header
img[id$=reRenderAllImage]");
+
+ selenium.click(ajaxRenderedCheckbox);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ selenium.click(increaseCounterButton);
+ selenium.click(increaseCounterButton);
+
+ String output = selenium.getText(outputDiv);
+ assertEquals(output, "0", "Output after two clicks when
ajaxRendered is set to false.");
+
+ selenium.click(reRenderAllImage);
+ waitGui.until(textEquals.locator(outputDiv).text("2"));
+ }
+
+ @Test(dataProvider = "templates")
+ public void testDir(String templates) {
+ ElementLocator optionLtr = pjq("input[name$=dirInput][value=ltr]");
+ ElementLocator optionRtl = pjq("input[name$=dirInput][value=rtl]");
+ ElementLocator optionNone = pjq("input[name$=dirInput][value=]");
+ AttributeLocator attributeDir = outputDiv.getAttribute(new
Attribute("dir"));
+
+ // right-to-left
+ selenium.click(optionRtl);
+ selenium.waitForPageToLoad(TIMEOUT);
+ String attributeValue = selenium.getAttribute(attributeDir);
+ assertEquals(attributeValue, "rtl", "Attribute dir after rtl was
set.");
+
+ // left-to-right
+ selenium.click(optionLtr);
+ selenium.waitForPageToLoad(TIMEOUT);
+ attributeValue = selenium.getAttribute(attributeDir);
+ assertEquals(attributeValue, "ltr", "Attribute dir after ltr was
set.");
+
+ // not specified
+ selenium.click(optionNone);
+ selenium.waitForPageToLoad(TIMEOUT);
+ if (selenium.isAttributePresent(attributeDir)) {
+ attributeValue = selenium.getAttribute(attributeDir);
+ assertEquals(attributeValue, "", "Attribute dir after none was
set.");
+ }
+ }
+
+ @Test(dataProvider = "templates")
+ public void testLang(String templates) {
+ ElementLocator langInput = pjq("input[id$=langInput]");
+ AttributeLocator attributeLang = outputDiv.getAttribute(new
Attribute("lang"));
+
+ selenium.typeKeys(langInput, "en");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ String attributeValue = selenium.getAttribute(attributeLang);
+ assertEquals(attributeValue, "en", "Lang attribute");
+
+ selenium.typeKeys(langInput, "sk");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ attributeValue = selenium.getAttribute(attributeLang);
+ assertEquals(attributeValue, "sk", "Lang attribute");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testLayout(String templates) {
+ ElementLocator optionBlock =
pjq("input[name$=layoutInput][value=block]");
+ ElementLocator optionInline =
pjq("input[name$=layoutInput][value=inline]");
+ ElementLocator optionNone =
pjq("input[name$=layoutInput][value=none]");
+
+ assertTrue(selenium.isElementPresent(outputDiv), "Div should be rendered on
the beginning.");
+ assertFalse(selenium.isElementPresent(outputSpan), "Div should be rendered
on the beginning.");
+
+ selenium.click(optionInline);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertFalse(selenium.isElementPresent(outputDiv), "Span should be rendered
when inline is set.");
+ assertTrue(selenium.isElementPresent(outputSpan), "Span should be rendered
when inline is set.");
+
+ selenium.click(optionBlock);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.isElementPresent(outputDiv), "Div should be rendered
when block is set.");
+ assertFalse(selenium.isElementPresent(outputSpan), "Div should be rendered
when block is set.");
+
+ selenium.click(optionNone);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertFalse(selenium.isElementPresent(outputDiv), "Span should be rendered
when none is set.");
+ assertTrue(selenium.isElementPresent(outputSpan), "Span should be rendered
when none is set.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testRendered(String templates) {
+ ElementLocator renderedInput = pjq("input[id$=renderedInput]");
+
+ selenium.click(renderedInput);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertFalse(selenium.isElementPresent(outputDiv), "Panel should not be
rendered.");
+
+ selenium.click(increaseCounterButton);
+ selenium.click(increaseCounterButton);
+
+ selenium.click(renderedInput);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.isElementPresent(outputDiv), "Panel should be
rendered.");
+
+ String counter = selenium.getText(outputDiv);
+ assertEquals(counter, "2", "Counter after two clicks on
button.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testStyle(String templates) {
+ String style = "background-color: magenta; color: white; font-weight:
bold;";
+ ElementLocator styleInput = pjq("input[id$=styleInput]");
+ AttributeLocator attributeStyle = outputDiv.getAttribute(Attribute.STYLE);
+
+ selenium.typeKeys(styleInput, style);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ String attributeValue = selenium.getAttribute(attributeStyle);
+ assertEquals(attributeValue, style, "Value of attribute style.");
+
+ selenium.typeKeys(styleInput, "");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ if (selenium.isAttributePresent(attributeStyle)) {
+ attributeValue = selenium.getAttribute(attributeStyle);
+ assertEquals(attributeValue, "", "Value of attribute
style.");
+ }
+ }
+
+ @Test(dataProvider = "templates")
+ public void testStyleClass(String templates) {
+ ElementLocator optionNone =
pjq("input[name$=styleClassInput][value=]");
+ AttributeLocator attributeClass = outputDiv.getAttribute(Attribute.CLASS);
+
+ selenium.click(optionBlue);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.belongsClass(outputDiv, "blue-background"),
"Panel should have class blue-background set.");
+ assertFalse(selenium.belongsClass(outputDiv, "gray-background"),
+ "Panel should not have class gray-background set.");
+
+ selenium.click(optionGray);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.belongsClass(outputDiv, "gray-background"),
"Panel should have class gray-background set.");
+ assertFalse(selenium.belongsClass(outputDiv, "blue-background"),
+ "Panel should not have class blue-background set.");
+
+ selenium.click(optionNone);
+ selenium.waitForPageToLoad(TIMEOUT);
+ if (selenium.isAttributePresent(attributeClass)) {
+ assertFalse(selenium.belongsClass(outputDiv, "blue-background"),
+ "Panel should not have class blue-background set.");
+ assertFalse(selenium.belongsClass(outputDiv, "gray-background"),
+ "Panel should not have class gray-background set.");
+ }
+ }
+
+ @Test(dataProvider = "templates")
+ public void testTitle(String templates) {
+ String title = "a4j:outputPanel title";
+ ElementLocator titleInput = pjq("input[id$=titleInput]");
+ AttributeLocator attributeTitle = outputDiv.getAttribute(new
Attribute("title"));
+
+ selenium.typeKeys(titleInput, title);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ String attributeValue = selenium.getAttribute(attributeTitle);
+ assertEquals(attributeValue, title, "Value of attribute title.");
+
+ selenium.typeKeys(titleInput, "");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ if (selenium.isAttributePresent(attributeTitle)) {
+ attributeValue = selenium.getAttribute(attributeTitle);
+ assertEquals(attributeValue, "", "Value of attribute
style.");
+ }
+ }
+}
Copied:
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/PollTestCase.java
(from rev 17913,
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPoll/PollTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/PollTestCase.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/PollTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * 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.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.metamer.ftest.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.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.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+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 = 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() {
+ 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 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>
+ */
+ @Test(dataProvider = "templates", groups = "client-side-perf")
+ public void testIntervalFromClientPerspective(String templates) {
+
+ long total = 0;
+ long count = 0;
+ for (int interval : TEST_INTERVAL_VALUES) {
+ selenium.type(attributeInterval, String.valueOf(interval));
+ selenium.waitForPageToLoad();
+
+ selenium.check(attributeEnabled);
+ selenium.fireEvent(attributeEnabled, Event.CHANGE);
+ selenium.waitForPageToLoad();
+
+ 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 -= getClientTime();
+ if (i > 0) {
+
+ long deviation = Math.abs(interval - Math.abs(runtime));
+ if (isSeleniumDebug()) {
+ System.out.println(format("deviation for interval {0}:
{1}", interval, deviation));
+ }
+ 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(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));
+ }
+
+}
Copied:
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/AbstractPushTestCase.java
(from rev 17913,
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/AbstractPushTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/AbstractPushTestCase.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/AbstractPushTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -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.metamer.ftest.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.metamer.ftest.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());
+ }
+
+ /**
+ * 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);
+ }
+}
Copied:
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/IntervalTestCase.java
(from rev 17913,
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/IntervalTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/IntervalTestCase.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/IntervalTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * 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.a4jPush;
+
+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;
+
+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;
+
+/**
+ * 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 Attribute ATTRIBUTE_TITLE = new Attribute("title");
+ private static final int[] INTERVAL_VALUES = new int[]{1000, 5000, 500};
+ 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;
+
+ 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 testIntervalFromClientPerspective() 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 = getClientTime();
+ 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 = 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(format("deviation for interval {0}: {1}",
interval, 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));
+ }
+
+ /**
+ * 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));
+ }
+}
Copied:
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/PushAttributes.java
(from rev 17913,
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/PushAttributes.java)
===================================================================
---
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/PushAttributes.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/PushAttributes.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -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.metamer.ftest.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();
+ }
+}
Copied:
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/SimpleTestCase.java
(from rev 17913,
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/SimpleTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/SimpleTestCase.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/SimpleTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -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.metamer.ftest.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));
+ }
+}
Copied:
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/HCommandButtonTestCase.java
(from rev 17913,
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/hCommandButton/HCommandButtonTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/HCommandButtonTestCase.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/HCommandButtonTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -0,0 +1,290 @@
+/*******************************************************************************
+ * 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.hCommandButton;
+
+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.dom.Event;
+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.AbstractTestappTestCase;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/commandButton/simple.xhtml
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class HCommandButtonTestCase extends AbstractTestappTestCase {
+
+ private JQueryLocator input = pjq("input[id$=input]");
+ private JQueryLocator button = pjq("input[id$=commandButton]");
+ private JQueryLocator output1 = pjq("span[id$=output1]");
+ private JQueryLocator output2 = pjq("span[id$=output2]");
+ private JQueryLocator output3 = pjq("span[id$=output3]");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/commandButton/simple.xhtml");
+ }
+
+ @Override
+ @AfterMethod(alwaysRun = true)
+ public void invalidateSession() {
+ super.invalidateSession();
+ }
+
+ @Test(dataProvider = "templates", groups = "client-side-perf")
+ public void testSimpleClick(String templates) {
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(button);
+
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
+
+ String output = selenium.getText(output1);
+ assertEquals(output, "RichFaces 4", "output1 when 'RichFaces
4' in input");
+
+ output = selenium.getText(output2);
+ assertEquals(output, "RichFa", "output2 when 'RichFaces 4'
in input");
+
+ output = selenium.getText(output3);
+ assertEquals(output, "RICHFACES 4", "output3 when 'RichFaces
4' in input");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testSimpleClickUnicode(String templates) {
+ selenium.typeKeys(input, "ľščťžýáíéňô");
+ selenium.click(button);
+
+ waitGui.until(textEquals.locator(output1).text("ľščťžýáíéňô"));
+
+ String output = selenium.getText(output1);
+ assertEquals(output, "ľščťžýáíéňô", "output1 when
'ľščťžýáíéňô' in input");
+
+ output = selenium.getText(output2);
+ assertEquals(output, "ľščťžý", "output2 when 'ľščťžýáíéňô'
in input");
+
+ output = selenium.getText(output3);
+ assertEquals(output, "ĽŠČŤŽÝÁÍÉŇÔ", "output3 when
'ľščťžýáíéňô' in input");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testAction(String templates) {
+ JQueryLocator doubleStringAction =
pjq("input[value=doubleStringAction]");
+ JQueryLocator first6CharsAction =
pjq("input[value=first6CharsAction]");
+ JQueryLocator toUpperCaseAction =
pjq("input[value=toUpperCaseAction]");
+
+ selenium.click(doubleStringAction);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(button);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
+ String output = selenium.getText(output2);
+ assertEquals(output, "RichFaces 4RichFaces 4",
+ "output2 when 'RichFaces 4' in input and doubleStringAction
selected");
+
+ selenium.click(first6CharsAction);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4ň");
+ selenium.click(button);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4ň"));
+ output = selenium.getText(output2);
+ assertEquals(output, "RichFa", "output2 when 'RichFaces
4ň' in input and first6CharsAction selected");
+
+ selenium.click(toUpperCaseAction);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4ě");
+ selenium.click(button);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4ě"));
+ output = selenium.getText(output2);
+ assertEquals(output, "RICHFACES 4Ě", "output2 when 'RichFaces
4ě' in input and toUpperCaseAction selected");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testActionListener(String templates) {
+ JQueryLocator doubleStringActionListener =
pjq("input[value=doubleStringActionListener]");
+ JQueryLocator first6CharsActionListener =
pjq("input[value=first6CharsActionListener]");
+ JQueryLocator toUpperCaseActionListener =
pjq("input[value=toUpperCaseActionListener]");
+
+ selenium.click(doubleStringActionListener);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(button);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
+ String output = selenium.getText(output3);
+ assertEquals(output, "RichFaces 4RichFaces 4",
+ "output2 when 'RichFaces 4' in input and
doubleStringActionListener selected");
+
+ selenium.click(first6CharsActionListener);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4ň");
+ selenium.click(button);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4ň"));
+ output = selenium.getText(output3);
+ assertEquals(output, "RichFa", "output2 when 'RichFaces
4ň' in input and first6CharsActionListener selected");
+
+ selenium.click(toUpperCaseActionListener);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4ě");
+ selenium.click(button);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4ě"));
+ output = selenium.getText(output3);
+ assertEquals(output, "RICHFACES 4Ě",
+ "output2 when 'RichFaces 4ě' in input and
toUpperCaseActionListener selected");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testDisabled(String templates) {
+ JQueryLocator disabledChecbox = pjq("input[id$=disabledInput]");
+ AttributeLocator disabledAttribute = button.getAttribute(new
Attribute("disabled"));
+
+ selenium.click(disabledChecbox);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ String isDisabled = selenium.getAttribute(disabledAttribute);
+ assertEquals(isDisabled.toLowerCase(), "disabled", "The value of
attribute disabled");
+ }
+
+ // not implemented in Mojarra
+ // @Test(dataProvider = "templates")
+ public void testOnblur(String templates) {
+ testFireEvent(Event.BLUR, button);
+ }
+
+ // not implemented in Mojarra
+ // @Test(dataProvider = "templates")
+ public void testOnchange(String templates) {
+ testFireEvent(Event.CHANGE, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnclick(String templates) {
+ testFireEvent(Event.CLICK, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOndblclick(String templates) {
+ testFireEvent(Event.DBLCLICK, button);
+ }
+
+ // not implemented in Mojarra
+ // @Test(dataProvider = "templates")
+ public void testOnfocus(String templates) {
+ testFireEvent(Event.FOCUS, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnkeydown(String templates) {
+ testFireEvent(Event.KEYDOWN, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnkeypress(String templates) {
+ testFireEvent(Event.KEYPRESS, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnkeyup(String templates) {
+ testFireEvent(Event.KEYUP, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmousedown(String templates) {
+ testFireEvent(Event.MOUSEDOWN, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmousemove(String templates) {
+ testFireEvent(Event.MOUSEMOVE, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseout(String templates) {
+ testFireEvent(Event.MOUSEOUT, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseover(String templates) {
+ testFireEvent(Event.MOUSEOVER, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseup(String templates) {
+ testFireEvent(Event.MOUSEUP, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testStyleClass(String templates) {
+
+ JQueryLocator wide = pjq("input[name$=styleClassInput][value=wide]");
+ JQueryLocator big = pjq("input[name$=styleClassInput][value=big]");
+ JQueryLocator none = pjq("input[name$=styleClassInput][value=]");
+
+ final AttributeLocator classAttribute = button.getAttribute(new
Attribute("class"));
+
+ selenium.click(wide);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.belongsClass(button, "wide"), "Button's
class was not changed to 'wide'");
+
+ selenium.click(big);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.belongsClass(button, "big"), "Button's
class was not changed to 'big'");
+
+ selenium.click(none);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertFalse(selenium.isAttributePresent(classAttribute), "Button's class
was not removed.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testStyle(String templates) {
+ JQueryLocator styleInput = pjq("input[id$=styleInput]");
+ final AttributeLocator attribute = button.getAttribute(new
Attribute("style"));
+ final String value = "font-size: 20px;";
+
+ selenium.type(styleInput, value);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ assertEquals(selenium.getAttribute(attribute), value, "Style of the button
did not change");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testValue(String templates) {
+ JQueryLocator valueInput = pjq("input[id$=valueInput]");
+ final AttributeLocator attribute = button.getAttribute(new
Attribute("value"));
+ final String value = "new label";
+
+ selenium.type(valueInput, value);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ assertEquals(selenium.getAttribute(attribute), value, "Value of the button
did not change");
+ }
+
+}
Copied:
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java
(from rev 17913,
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/DataScroller.java)
===================================================================
---
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * 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.richExtendedDataTable;
+
+import org.jboss.test.selenium.framework.AjaxSelenium;
+import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
+import org.jboss.test.selenium.locator.JQueryLocator;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.*;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.*;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class DataScroller {
+
+ AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+
+ JQueryLocator scrollerRoot;
+ JQueryLocator pageNumbers = jq(".rf-ds-dtl");
+ JQueryLocator firstPageButton = jq(".rf-ds-l[id$=ds_f]");
+ JQueryLocator lastPageButton = jq(".rf-ds-r:eq(1)");
+ JQueryLocator lastVisiblePage = jq(".rf-ds-dtl:last");
+ JQueryLocator currentPage = jq(".rf-ds-cur");
+
+ public DataScroller(JQueryLocator scrollerRoot) {
+ this.scrollerRoot = scrollerRoot;
+ }
+
+ public JQueryLocator getRoot() {
+ return scrollerRoot;
+ }
+
+ public void gotoFirstPage() {
+ if (!isFirstPage()) {
+ clickFirstPageButton();
+ }
+ }
+
+ public void gotoLastPage() {
+ if (!isLastPage()) {
+ clickLastPageButton();
+ }
+ }
+
+ public void clickLastPageButton() {
+ JQueryLocator locator = scrollerRoot.getDescendant(lastPageButton);
+ guardXhr(selenium).click(locator);
+ }
+
+ public void clickFirstPageButton() {
+ JQueryLocator locator = scrollerRoot.getDescendant(firstPageButton);
+ guardXhr(selenium).click(locator);
+ }
+
+ public int getCountOfVisiblePages() {
+ JQueryLocator locator = scrollerRoot.getDescendant(pageNumbers);
+ return selenium.getCount(locator);
+ }
+
+ public boolean hasPages() {
+ JQueryLocator locator = scrollerRoot.getDescendant(lastVisiblePage);
+ return selenium.isElementPresent(locator);
+ }
+
+ public Integer getLastVisiblePage() {
+ JQueryLocator locator = scrollerRoot.getDescendant(lastVisiblePage);
+ if (!hasPages()) {
+ return null;
+ }
+ return integer(selenium.getText(locator));
+ }
+
+ public int getCurrentPage() {
+ JQueryLocator locator = scrollerRoot.getDescendant(currentPage);
+ if (!hasPages()) {
+ return 1;
+ }
+ return integer(selenium.getText(locator));
+ }
+
+ public boolean isFirstPage() {
+ return getCurrentPage() == 1;
+ }
+
+ public boolean isLastPage() {
+ return getCurrentPage() == getLastVisiblePage();
+ }
+
+ public static int integer(String string) {
+ return Integer.valueOf(string);
+ }
+}
Copied:
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java
(from rev 17913,
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/DataTable.java)
===================================================================
---
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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.richExtendedDataTable;
+
+import org.jboss.test.selenium.framework.AjaxSelenium;
+import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
+import org.jboss.test.selenium.locator.JQueryLocator;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.*;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class DataTable {
+
+ AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+
+ JQueryLocator tableRoot;
+ JQueryLocator tableRows = jq(".rf-dt-c:nth-child(1)");
+
+ public DataTable(JQueryLocator tableRoot) {
+ super();
+ this.tableRoot = tableRoot;
+ }
+
+ public int getCountOfTableRows() {
+ JQueryLocator locator = tableRoot.getDescendant(tableRows);
+ return selenium.getCount(locator);
+ }
+
+ public String getTableText() {
+ return selenium.getText(tableRoot);
+ }
+}
Copied:
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/ScrollerTestCase.java
(from rev 17913,
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/ScrollerTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/ScrollerTestCase.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/ScrollerTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * 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.richExtendedDataTable;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.*;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.locator.ElementLocator;
+import org.richfaces.tests.metamer.ftest.AbstractTestappTestCase;
+import org.testng.annotations.Test;
+
+/**
+ * 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]"));
+ ElementLocator attributeRowsInput = id("form:attributes:rowsInput");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richExtendedDataTable/scroller.xhtml");
+ }
+
+ /**
+ * Tests row count for scroller in footer of the EDT.
+ *
+ * @see {@link #testRowCount(DataScroller)}
+ */
+ @Test(dataProvider = "templates", groups = "client-side-perf")
+ 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 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 : ROW_COUNT_VALUES) {
+ if (rowsPerPage != null) {
+ selenium.type(attributeRowsInput, String.valueOf(rowsPerPage));
+ selenium.fireEvent(attributeRowsInput, Event.BLUR);
+ selenium.waitForPageToLoad();
+ }
+
+ dataScroller.gotoFirstPage();
+ int rowCountPreset = Integer.valueOf(selenium.getValue(attributeRowsInput));
+ int rowCountActual = table.getCountOfTableRows();
+ assertEquals(rowCountActual, Math.min(TOTAL_ROW_COUNT, rowCountPreset));
+
+ assertEquals(dataScroller.hasPages(), rowCountActual < TOTAL_ROW_COUNT);
+ if (dataScroller.hasPages()) {
+ dataScroller.gotoLastPage();
+
+ int pagesExpected = pageCountActualExpected(rowCountActual);
+ int countOfVisiblePages = dataScroller.getCountOfVisiblePages();
+
+ if (countOfVisiblePages < pagesExpected) {
+ int lastVisiblePage = dataScroller.getLastVisiblePage();
+ assertEquals(lastVisiblePage,
pageCountActualExpected(rowCountActual));
+ } else {
+ assertEquals(countOfVisiblePages, pagesExpected);
+ }
+
+ int rowCountExpected = rowCountLastPageExpected(rowCountPreset);
+ rowCountActual = table.getCountOfTableRows();
+ assertEquals(rowCountActual, rowCountExpected);
+ }
+ }
+ }
+
+ private int pageCountActualExpected(int rowCountActual) {
+ return Double.valueOf(Math.ceil((double) TOTAL_ROW_COUNT /
rowCountActual)).intValue();
+ }
+
+ private int rowCountLastPageExpected(int rowCountPreset) {
+ int result = TOTAL_ROW_COUNT % rowCountPreset;
+ return (result == 0) ? rowCountPreset : result;
+ }
+
+}
Modified: root/tests/metamer/trunk/ftest/pom.xml
===================================================================
--- root/tests/metamer/trunk/ftest/pom.xml 2010-07-10 21:14:22 UTC (rev 17913)
+++ root/tests/metamer/trunk/ftest/pom.xml 2010-07-11 00:06:08 UTC (rev 17914)
@@ -1,11 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.richfaces.tests</groupId>
- <artifactId>testapp-tests</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <name>RichFaces 4.0 TestApp: Functional Test</name>
- <packaging>pom</packaging>
<parent>
<artifactId>functional-test-jboss-ci-template</artifactId>
@@ -13,47 +32,84 @@
<version>1.5.0.Final</version>
</parent>
+ <groupId>org.richfaces.tests</groupId>
+ <artifactId>metamer-ftest</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <name>Metamer: RichFaces Testing Application - Functional Test</name>
+ <packaging>pom</packaging>
+
<modules>
- <module>test-source</module>
+ <module>ftest-source</module>
</modules>
+ <scm>
+ <
connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/root/tests...
+ <
developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/root...
+ <
url>http://fisheye.jboss.org/browse/RichFaces/root/tests/metamer/trunk...
+ </scm>
+
+ <licenses>
+ <license>
+ <name>GNU Lesser General Public License, Version 2.1</name>
+ <distribution>repo</distribution>
+ <
url>http://www.gnu.org/licenses/lgpl-2.1.txt</url>
+ </license>
+ </licenses>
+
+ <distributionManagement>
+ <snapshotRepository>
+ <id>jboss-qa-snapshots</id>
+ <name>JBoss QA snapshot repository</name>
+ <url>http://nexus.qa.jboss.com:8081/nexus/content/repositories/snapshots</url>
+ </snapshotRepository>
+ <repository>
+ <id>jboss-qa-releases</id>
+ <name>JBoss QA selease repository</name>
+ <url>http://nexus.qa.jboss.com:8081/nexus/content/repositories/releases</url>
+ </repository>
+ </distributionManagement>
+
+ <developers>
+ <developer>
+ <name>Pavol Pitonak</name>
+ <email>ppitonak(a)redhat.com</email>
+ </developer>
+ <developer>
+ <name>Lukas Fryc</name>
+ <email>lfryc(a)redhat.com</email>
+ </developer>
+ </developers>
+
+ <issueManagement>
+ <system>jira</system>
+ <
url>https://jira.jboss.org/jira/browse/RFPL</url>
+ </issueManagement>
+
<properties>
- <context.path>/testapp/</context.path>
+ <context.path>/metamer/</context.path>
<deployable.version>4.0.0-SNAPSHOT</deployable.version>
+ <ftest.source.version>${project.version}</ftest.source.version>
<testng.suite.xml>src/test/resources/testng.xml</testng.suite.xml>
</properties>
- <pluginRepositories>
- <pluginRepository>
- <id>ossrh</id>
- <name>Sonatype OSS Repository</name>
- <
url>http://oss.sonatype.org/content/groups/public</url>
- <layout>default</layout>
- </pluginRepository>
- </pluginRepositories>
-
<repositories>
<repository>
- <id>download-java-net-glassfish</id>
- <
url>http://download.java.net/maven/glassfish</url>
+ <id>jboss-qa-repository</id>
+ <url>http://nexus.qa.jboss.com:8081/nexus/content/groups/public-all</url>
</repository>
- <repository>
- <id>jboss-public-repository-group</id>
- <
url>https://repository.jboss.org/nexus/content/groups/public/</url>
- </repository>
</repositories>
<dependencies>
<dependency>
- <groupId>org.richfaces.examples</groupId>
- <artifactId>testapp</artifactId>
+ <groupId>org.richfaces.tests</groupId>
+ <artifactId>metamer</artifactId>
<type>${deployable.type}</type>
<version>${deployable.version}</version>
</dependency>
<dependency>
- <groupId>org.richfaces.tests.testapp</groupId>
- <artifactId>test-source</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <groupId>org.richfaces.tests</groupId>
+ <artifactId>metamer-ftest-source</artifactId>
+ <version>${ftest.source.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -85,8 +141,8 @@
<type>installed</type>
<deployables>
<deployable>
- <groupId>org.richfaces.examples</groupId>
- <artifactId>testapp</artifactId>
+ <groupId>org.richfaces.tests</groupId>
+ <artifactId>metamer</artifactId>
<type>${deployable.type}</type>
<properties>
<context>${context.deploy.path}</context>
@@ -155,8 +211,8 @@
<goal>unpack-dependencies</goal>
</goals>
<configuration>
- <includeGroupIds>org.richfaces.tests.testapp</includeGroupIds>
- <includeArtifactIds>test-source</includeArtifactIds>
+ <includeGroupIds>org.richfaces.tests</includeGroupIds>
+ <includeArtifactIds>metamer-ftest-source</includeArtifactIds>
<includes>**</includes>
<outputDirectory>target/test-classes</outputDirectory>
<overWriteReleases>true</overWriteReleases>
@@ -193,7 +249,7 @@
<configuration>
<tasks>
<copy todir="target/test-classes/">
- <fileset dir="../testapp-tests/test-source/target/classes/">
+ <fileset dir="../metamer-ftest/ftest-source/target/classes/">
<include name="**/*.*" />
</fileset>
</copy>
Modified: root/tests/metamer/trunk/ftest/src/test/resources/testng.xml
===================================================================
--- root/tests/metamer/trunk/ftest/src/test/resources/testng.xml 2010-07-10 21:14:22 UTC
(rev 17913)
+++ root/tests/metamer/trunk/ftest/src/test/resources/testng.xml 2010-07-11 00:06:08 UTC
(rev 17914)
@@ -4,7 +4,7 @@
<test name="Component Tests">
<parameter name="templates" value="plain richDataTable1,redDiv
richDataTable2,redDiv a4jRepeat1 a4jRepeat2 hDataTable1 hDataTable2 uiRepeat1
uiRepeat2"/>
<packages>
- <package name="org.richfaces.tests.testapp" />
+ <package name="org.richfaces.tests.metamer.ftest" />
</packages>
</test>
Deleted: root/tests/metamer/trunk/ftest/test-source/.gitignore
===================================================================
--- root/tests/metamer/trunk/ftest/test-source/.gitignore 2010-07-10 21:14:22 UTC (rev
17913)
+++ root/tests/metamer/trunk/ftest/test-source/.gitignore 2010-07-11 00:06:08 UTC (rev
17914)
@@ -1,5 +0,0 @@
-/.classpath
-/.project
-/.settings
-/target
-/profiles.xml
Deleted: root/tests/metamer/trunk/ftest/test-source/pom.xml
===================================================================
--- root/tests/metamer/trunk/ftest/test-source/pom.xml 2010-07-10 21:14:22 UTC (rev
17913)
+++ root/tests/metamer/trunk/ftest/test-source/pom.xml 2010-07-11 00:06:08 UTC (rev
17914)
@@ -1,39 +0,0 @@
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <artifactId>root</artifactId>
- <groupId>org.jboss.test.richfaces-selenium</groupId>
- <version>1.5.0.Final</version>
- </parent>
-
- <groupId>org.richfaces.tests.testapp</groupId>
- <artifactId>test-source</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <name>RichFaces 4.0 TestApp: Functional Test Source</name>
-
- <dependencies>
- <dependency>
- <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>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
\ No newline at end of file
Deleted:
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 2010-07-10
21:14:22 UTC (rev 17913)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/jboss/test/selenium/SeleniumGetter.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -1,101 +0,0 @@
-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;
- }
-}
Deleted:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/jboss/test/selenium/javascript/JavaScriptEvaluator.java
===================================================================
---
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/jboss/test/selenium/javascript/JavaScriptEvaluator.java 2010-07-10
21:14:22 UTC (rev 17913)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/jboss/test/selenium/javascript/JavaScriptEvaluator.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -1,131 +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.jboss.test.selenium.javascript;
-
-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.waiting.conversion.Convertor;
-
-import static org.jboss.test.selenium.utils.PrimitiveUtils.*;
-
-/**
- * Simplifies manipulation with results of evaluated JavaScript.
- *
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-public final class JavaScriptEvaluator {
-
- private static final AjaxSelenium SELENIUM = AjaxSeleniumProxy.getInstance();
-
- private JavaScriptEvaluator() {
- }
-
- /**
- * Returns the evaluated JavaScript result.
- *
- * @param script
- * to evaluate
- * @return the evaluated JavaScript result.
- */
- public static String evaluateString(JavaScript script) {
- return checkNull(SELENIUM.getEval(script));
- }
-
- /**
- * Returns the evaluated JavaScript result as Boolean.
- *
- * @param script
- * to evaluate
- * @return the evaluated JavaScript result as Boolean.
- */
- public static Boolean evaluateBoolean(JavaScript script) {
- return asBoolean(checkNull(SELENIUM.getEval(script)));
- }
-
- /**
- * Returns the evaluated JavaScript result as Float.
- *
- * @param script
- * to evaluate
- * @return the evaluated JavaScript result as Float.
- */
- public static Float evaluateFloat(JavaScript script) {
- return asFloat(checkNull(SELENIUM.getEval(script)));
- }
-
- /**
- * Returns the evaluated JavaScript result as Double.
- *
- * @param script
- * to evaluate
- * @return the evaluated JavaScript result as Double.
- */
- public static Double evaluateDouble(JavaScript script) {
- return asDouble(checkNull(SELENIUM.getEval(script)));
- }
-
- /**
- * Returns the evaluated JavaScript result as Long.
- *
- * @param script
- * to evaluate
- * @return the evaluated JavaScript result as Long.
- */
- public static Long evaluateLong(JavaScript script) {
- return asLong(checkNull(SELENIUM.getEval(script)));
- }
-
- /**
- * Returns the evaluated JavaScript result as Integer.
- *
- * @param script
- * to evaluate
- * @return the evaluated JavaScript result as Integer.
- */
- public static Integer evaluateInteger(JavaScript script) {
- return asInteger(checkNull(SELENIUM.getEval(script)));
- }
-
- /**
- * Returns the evaluated JavaScript result converted to T by specified converter.
- *
- * @param script
- * the script to evaluate
- * @return the evaluated JavaScript result converted to T by specified converter.
- */
- public static <T> T evaluate(JavaScript script, Convertor<String, T>
converter) {
- String result = checkNull(SELENIUM.getEval(script));
- if (result == null) {
- return null;
- }
- return converter.forwardConversion(result);
- }
-
- private static String checkNull(String evaluatedResult) {
- if ("null".equals(evaluatedResult) ||
"undefined".equals(evaluatedResult)) {
- return null;
- }
- return evaluatedResult;
- }
-}
Deleted:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/AbstractTestappTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/AbstractTestappTestCase.java 2010-07-10
21:14:22 UTC (rev 17913)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/AbstractTestappTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -1,190 +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.testapp;
-
-import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
-import static org.testng.Assert.assertEquals;
-
-import java.net.URL;
-
-import org.jboss.test.selenium.AbstractTestCase;
-import org.jboss.test.selenium.dom.Event;
-import org.jboss.test.selenium.encapsulated.JavaScript;
-import org.jboss.test.selenium.locator.ElementLocator;
-import org.jboss.test.selenium.locator.JQueryLocator;
-import org.testng.SkipException;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Optional;
-import org.testng.annotations.Parameters;
-
-/**
- * Abstract test case used as a basis for majority of test cases.
- *
- * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
- * @version $Revision$
- */
-public abstract class AbstractTestappTestCase extends AbstractTestCase {
-
- /**
- * timeout in miliseconds
- */
- public static final long TIMEOUT = 5000;
- private String[][] templates;
-
- /**
- * Returns the url to test page to be opened by Selenium
- *
- * @return absolute url to the test page to be opened by Selenium
- */
- public abstract URL getTestUrl();
-
- /**
- * Data provider for templates.
- *
- * @return array containing templates that should be used (defined in testng.xml) or
default array (containing only
- * plain template) if nothing is defined
- */
- @DataProvider(name = "templates")
- protected Object[][] getTemplates() {
- if (templates != null && templates.length > 0) {
- return templates;
- }
-
- return new Object[][]{{"plain"}};
- }
-
- /**
- * Loads and parses attribute "templates" from testng.xml.
- *
- * @param urlParams
- */
- @BeforeClass(alwaysRun = true)
- @Parameters({"templates"})
- public void initTemplates(@Optional String urlParams) {
- if (urlParams == null) {
- return;
- }
-
- String[] array = urlParams.split(" ");
- templates = new String[array.length][];
-
- for (int i = 0; i < array.length; i++) {
- templates[i] = new String[1];
- templates[i][0] = array[i];
- }
- }
-
- /**
- * Opens the tested page. If templates is not empty nor null, it appends url
parameter with templates.
- *
- * @param templates
- * templates that will be used for test, e.g. "red_div"
- */
- @BeforeMethod(alwaysRun = true)
- public void loadPage(Object[] templates) {
- if (selenium == null) {
- new SkipException("selenium isn't initialized");
- }
- String urlParams = "";
- if (templates != null && templates.length != 0) {
- urlParams = "?templates=" + templates[0];
- }
- selenium.open(buildUrl(getTestUrl() + urlParams));
- selenium.waitForPageToLoad(TIMEOUT);
- }
-
- /**
- * Invalidates session by clicking on a button on tested page.
- */
- public void invalidateSession() {
- selenium.deleteAllVisibleCookies();
- }
-
- /**
- * Forces the current thread sleep for given time.
- *
- * @param millis
- * number of miliseconds for which the thread will sleep
- */
- @Deprecated
- protected void waitFor(long millis) {
- try {
- Thread.sleep(millis);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Factory method for creating instances of class JQueryLocator which locates the
element using <a
- *
href="http://api.jquery.com/category/selectors/">JQuery
Selector</a> syntax. It adds "div.content " in front of
- * each selector.
- *
- * @param jquerySelector
- * the jquery selector
- * @return the j query locator
- * @see JQueryLocator
- */
- public static JQueryLocator pjq(String jquerySelector) {
- return new JQueryLocator("div.content " + jquerySelector);
- }
-
- /**
- * A helper method for testing javascripts events. It sets
alert('testedevent') to the input field for given event
- * and fires the event. Then it checks the message in the alert dialog.
- *
- * @param event
- * JavaScript event to be tested
- * @param element
- * locator of tested element
- */
- protected void testFireEvent(Event event, ElementLocator element) {
- ElementLocator eventInput = pjq("input[id$=on" + event.getEventName() +
"Input]");
- final String value = "alert('" + event.getEventName() +
"')";
-
- selenium.type(eventInput, value);
- selenium.waitForPageToLoad(TIMEOUT);
-
- selenium.fireEvent(element, event);
-
- assertEquals(selenium.getAlert(), event.getEventName(), event.getEventName()
- + " attribute did not change correctly");
- }
-
- /**
- * Hides header, footer and inputs for attributes.
- */
- protected void hideControls() {
- selenium.getEval(new JavaScript("window.hideControls()"));
- }
-
- /**
- * Shows header, footer and inputs for attributes.
- */
- protected void showControls() {
- selenium.getEval(new JavaScript("window.showControls()"));
- }
-
-}
Deleted:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jActionListener/A4JActionListenerTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jActionListener/A4JActionListenerTestCase.java 2010-07-10
21:14:22 UTC (rev 17913)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jActionListener/A4JActionListenerTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -1,136 +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.testapp.a4jActionListener;
-
-import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-
-import java.net.URL;
-
-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;
-
-/**
- * Test case for page /faces/components/a4jActionListener/all.xhtml
- *
- * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
- * @version $Revision$
- */
-public class A4JActionListenerTestCase extends AbstractTestappTestCase {
-
- private ElementLocator invokeButtonType =
pjq("input[id$=invokeByTypeButton]");
- private ElementLocator invokeButtonBinding =
pjq("input[id$=invokeByBindingButton]");
- private ElementLocator invokeButtonMethod =
pjq("input[id$=invokeMethodButton]");
- private ElementLocator invokeButtonCC =
pjq("input[id$=invokeFromCCButton:button]");
- private JQueryLocator message = pjq("ul[id$=messages] li");
-
- @Override
- public URL getTestUrl() {
- return buildUrl(contextPath,
"faces/components/a4jActionListener/all.xhtml");
- }
-
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
-
- @Test(dataProvider = "templates")
- public void testInvokeListenerByType(String templates) {
- final String hashCodeRegExp = "@[0-9a-fA-F]{1,}$";
- final String msg = "Implementation of ActionListener created and called:
"
- +
"org.richfaces.testapp.bean.A4JActionListenerBean$ActionListenerImpl";
-
- selenium.click(invokeButtonType);
- waitGui.until(elementPresent.locator(message));
- String output1 = selenium.getText(message);
-
- assertEquals(output1.replaceAll(hashCodeRegExp, ""), msg, "Message
after first invocation of listener by type.");
-
- int count = selenium.getCount(message);
- assertEquals(count, 1, "Only one message should be displayed on the
page.");
-
- // do the same once again
-
- selenium.click(invokeButtonType);
- waitGui.until(elementPresent.locator(message));
- String output2 = selenium.getText(message);
-
- assertEquals(output2.replaceAll(hashCodeRegExp, ""), msg, "Message
after second invocation of listener by type");
-
- // check that a new object of ActionListenerImpl was created
- String hashcode1 = output1.replace(msg, "");
- String hashcode2 = output2.replace(msg, "");
- assertFalse(hashcode1.equals(hashcode2), "New object of class
ActionListenerImpl should be instantiated.");
-
- count = selenium.getCount(message);
- assertEquals(count, 1, "Only one message should be displayed on the
page.");
-
- }
-
- @Test(dataProvider = "templates")
- public void testInvokeListenerByBinding(String templates) {
- final String msg = "Bound listener called";
-
- selenium.click(invokeButtonBinding);
- waitGui.until(elementPresent.locator(message));
- String output = selenium.getText(message);
-
- assertEquals(output, msg, "Message after first invocation of listener by
binding.");
-
- int count = selenium.getCount(message);
- assertEquals(count, 1, "Only one message should be displayed on the
page.");
- }
-
- @Test(dataProvider = "templates")
- public void testInvokeListenerMethod(String templates) {
- final String msg = "Method expression listener called";
-
- selenium.click(invokeButtonMethod);
- waitGui.until(elementPresent.locator(message));
- String output = selenium.getText(message);
-
- assertEquals(output, msg, "Message after first invocation of listener
method.");
-
- int count = selenium.getCount(message);
- assertEquals(count, 1, "Only one message should be displayed on the
page.");
- }
-
- @Test(dataProvider = "templates")
- public void testInvokeListenerMethodCC(String templates) {
- final String msg = "Method expression listener called from composite
component";
-
- selenium.click(invokeButtonCC);
- waitGui.until(elementPresent.locator(message));
- String output = selenium.getText(message);
-
- assertEquals(output, msg, "Message after first invocation of listener method
from composite component.");
-
- int count = selenium.getCount(message);
- assertEquals(count, 1, "Only one message should be displayed on the
page.");
- }
-}
Deleted:
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:14:22 UTC (rev 17913)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandButton/A4JCommandButtonTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -1,320 +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.testapp.a4jCommandButton;
-
-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.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.richfaces.tests.testapp.AbstractTestappTestCase;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-/**
- * Test case for page /faces/components/a4jCommandButton/simple.xhtml
- *
- * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
- * @version $Revision$
- */
-public class A4JCommandButtonTestCase extends AbstractTestappTestCase {
-
- private ElementLocator input = pjq("input[id$=input]");
- private ElementLocator button = pjq("input[id$=a4jCommandButton]");
- private ElementLocator output1 = pjq("span[id$=output1]");
- private ElementLocator output2 = pjq("span[id$=output2]");
- private ElementLocator output3 = pjq("span[id$=output3]");
-
- @Override
- public URL getTestUrl() {
- return buildUrl(contextPath,
"faces/components/a4jCommandButton/simple.xhtml");
- }
-
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
-
- @Test(dataProvider = "templates", groups = "client-side-perf")
- public void testSimpleClick(String templates) {
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(button);
-
- waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
-
- String output = selenium.getText(output1);
- assertEquals(output, "RichFaces 4", "output1 when 'RichFaces
4' in input");
-
- output = selenium.getText(output2);
- assertEquals(output, "RichFa", "output2 when 'RichFaces 4'
in input");
-
- output = selenium.getText(output3);
- assertEquals(output, "RICHFACES 4", "output3 when 'RichFaces
4' in input");
- }
-
- @Test(dataProvider = "templates")
- public void testSimpleClickUnicode(String templates) {
- selenium.typeKeys(input, "ľščťžýáíéňô");
- selenium.click(button);
-
- waitGui.until(textEquals.locator(output1).text("ľščťžýáíéňô"));
-
- String output = selenium.getText(output1);
- assertEquals(output, "ľščťžýáíéňô", "output1 when
'ľščťžýáíéňô' in input");
-
- output = selenium.getText(output2);
- assertEquals(output, "ľščťžý", "output2 when 'ľščťžýáíéňô'
in input");
-
- output = selenium.getText(output3);
- assertEquals(output, "ĽŠČŤŽÝÁÍÉŇÔ", "output3 when
'ľščťžýáíéňô' in input");
- }
-
- @Test(dataProvider = "templates")
- public void testAction(String templates) {
- ElementLocator doubleStringAction =
pjq("input[value=doubleStringAction]");
- ElementLocator first6CharsAction =
pjq("input[value=first6CharsAction]");
- ElementLocator toUpperCaseAction =
pjq("input[value=toUpperCaseAction]");
-
- selenium.click(doubleStringAction);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(button);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
- String output = selenium.getText(output2);
- assertEquals(output, "RichFaces 4RichFaces 4",
- "output2 when 'RichFaces 4' in input and doubleStringAction
selected");
-
- selenium.click(first6CharsAction);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4ň");
- selenium.click(button);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4ň"));
- output = selenium.getText(output2);
- assertEquals(output, "RichFa", "output2 when 'RichFaces
4ň' in input and first6CharsAction selected");
-
- selenium.click(toUpperCaseAction);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4ě");
- selenium.click(button);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4ě"));
- output = selenium.getText(output2);
- assertEquals(output, "RICHFACES 4Ě", "output2 when 'RichFaces
4ě' in input and toUpperCaseAction selected");
- }
-
- @Test(dataProvider = "templates")
- public void testActionListener(String templates) {
- ElementLocator doubleStringActionListener =
pjq("input[value=doubleStringActionListener]");
- ElementLocator first6CharsActionListener =
pjq("input[value=first6CharsActionListener]");
- ElementLocator toUpperCaseActionListener =
pjq("input[value=toUpperCaseActionListener]");
-
- selenium.click(doubleStringActionListener);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(button);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
- String output = selenium.getText(output3);
- assertEquals(output, "RichFaces 4RichFaces 4",
- "output2 when 'RichFaces 4' in input and
doubleStringActionListener selected");
-
- selenium.click(first6CharsActionListener);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4ň");
- selenium.click(button);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4ň"));
- output = selenium.getText(output3);
- assertEquals(output, "RichFa", "output2 when 'RichFaces
4ň' in input and first6CharsActionListener selected");
-
- selenium.click(toUpperCaseActionListener);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4ě");
- selenium.click(button);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4ě"));
- output = selenium.getText(output3);
- assertEquals(output, "RICHFACES 4Ě",
- "output2 when 'RichFaces 4ě' in input and
toUpperCaseActionListener selected");
- }
-
- @Test(dataProvider = "templates")
- public void testDisabled(String templates) {
- ElementLocator disabledChecbox = pjq("input[id$=disabledInput]");
- AttributeLocator disabledAttribute = button.getAttribute(new
Attribute("disabled"));
-
- selenium.click(disabledChecbox);
- selenium.waitForPageToLoad(TIMEOUT);
-
- String isDisabled = selenium.getAttribute(disabledAttribute);
- assertEquals(isDisabled.toLowerCase(), "disabled", "The value of
attribute disabled");
- }
-
- @Test(dataProvider = "templates")
- public void testOnclick(String templates) {
- testFireEvent(Event.CLICK, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOndblclick(String templates) {
- testFireEvent(Event.DBLCLICK, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnkeydown(String templates) {
- testFireEvent(Event.KEYDOWN, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnkeypress(String templates) {
- testFireEvent(Event.KEYPRESS, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOneyup(String templates) {
- testFireEvent(Event.KEYUP, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmousedown(String templates) {
- testFireEvent(Event.MOUSEDOWN, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmousemove(String templates) {
- testFireEvent(Event.MOUSEMOVE, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmouseout(String templates) {
- testFireEvent(Event.MOUSEOUT, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmouseover(String templates) {
- testFireEvent(Event.MOUSEOVER, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmouseup(String templates) {
- testFireEvent(Event.MOUSEUP, button);
- }
-
- @Test(dataProvider = "templates")
- public void testRender(String templates) {
- ElementLocator renderInput = pjq("input[name$=renderInput]");
-
- selenium.type(renderInput, "output1");
- selenium.waitForPageToLoad(TIMEOUT);
-
- selenium.typeKeys(input, "aaa");
- selenium.click(button);
-
- waitGui.until(textEquals.locator(output1).text("aaa"));
-
- String output = selenium.getText(output1);
- assertEquals(output, "aaa", "output1 when 'aaa' in input
and 'output1' set to be rerendered");
-
- output = selenium.getText(output2);
- assertEquals(output, "", "output2 when 'aaa' in input and
'output1' set to be rerendered");
-
- output = selenium.getText(output3);
- assertEquals(output, "", "output3 when 'aaa' in input and
'output1' set to be rerendered");
-
- selenium.type(renderInput, "output2 output3");
- selenium.waitForPageToLoad(TIMEOUT);
-
- selenium.typeKeys(input, "bbb");
- selenium.click(button);
-
- waitGui.until(textEquals.locator(output2).text("bbb"));
-
- output = selenium.getText(output1);
- assertEquals(output, "aaa", "output1 when 'bbb' in input
and 'output2 output3' set to be rerendered");
-
- output = selenium.getText(output2);
- assertEquals(output, "bbb", "output2 when 'bbb' in input
and 'output2 output3' set to be rerendered");
-
- output = selenium.getText(output3);
- assertEquals(output, "BBB", "output3 when 'bbb' in input
and 'output2 output3' set to be rerendered");
-
- }
-
- @Test(dataProvider = "templates")
- public void testRendered(String templates) {
- ElementLocator renderedCheckbox = pjq("input[name$=renderedInput]");
-
- selenium.click(renderedCheckbox);
- selenium.waitForPageToLoad(TIMEOUT);
- assertFalse(selenium.isElementPresent(button), "Button should not be
displayed");
- }
-
- @Test(dataProvider = "templates")
- public void testStyleClass(String templates) {
- ElementLocator wide = pjq("input[name$=styleClassInput][value=wide]");
- ElementLocator big = pjq("input[name$=styleClassInput][value=big]");
- ElementLocator none = pjq("input[name$=styleClassInput][value=]");
-
- final AttributeLocator classAttribute = button.getAttribute(new
Attribute("class"));
-
- selenium.click(wide);
- selenium.waitForPageToLoad(TIMEOUT);
- assertTrue(selenium.belongsClass(button, "wide"), "Button's
class was not changed to 'wide'");
-
- selenium.click(big);
- selenium.waitForPageToLoad(TIMEOUT);
- assertTrue(selenium.belongsClass(button, "big"), "Button's
class was not changed to 'big'");
-
- selenium.click(none);
- selenium.waitForPageToLoad(TIMEOUT);
- assertFalse(selenium.isAttributePresent(classAttribute), "Button's class
was not removed.");
- }
-
- @Test(dataProvider = "templates")
- public void testStyle(String templates) {
- ElementLocator styleInput = pjq("input[id$=styleInput]");
- final AttributeLocator attribute = button.getAttribute(new
Attribute("style"));
- final String value = "font-size: 20px;";
-
- selenium.type(styleInput, value);
- selenium.waitForPageToLoad(TIMEOUT);
-
- assertEquals(selenium.getAttribute(attribute), value, "Style of the button
did not change");
- }
-
- @Test(dataProvider = "templates")
- public void testValue(String templates) {
- ElementLocator valueInput = pjq("input[id$=valueInput]");
- final AttributeLocator attribute = button.getAttribute(new
Attribute("value"));
- final String value = "new label";
-
- selenium.type(valueInput, value);
- selenium.waitForPageToLoad(TIMEOUT);
-
- assertEquals(selenium.getAttribute(attribute), value, "Value of the button
did not change");
- }
-
-}
Deleted:
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:14:22 UTC (rev 17913)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandLink/A4JCommandLinkTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -1,336 +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.testapp.a4jCommandLink;
-
-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.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.richfaces.tests.testapp.AbstractTestappTestCase;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-/**
- * Test case for page /faces/components/a4jCommandLink/simple.xhtml
- *
- * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
- * @version $Revision$
- */
-public class A4JCommandLinkTestCase extends AbstractTestappTestCase {
-
- private ElementLocator input = pjq("input[id$=input]");
- private ElementLocator link = pjq("a[id$=a4jCommandLink]");
- private ElementLocator output1 = pjq("span[id$=output1]");
- private ElementLocator output2 = pjq("span[id$=output2]");
- private ElementLocator output3 = pjq("span[id$=output3]");
-
- @Override
- public URL getTestUrl() {
- return buildUrl(contextPath,
"faces/components/a4jCommandLink/simple.xhtml");
- }
-
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
-
- @Test(dataProvider = "templates", groups = "client-side-perf")
- public void testSimpleClick(String templates) {
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(link);
-
- waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
-
- String output = selenium.getText(output1);
- assertEquals(output, "RichFaces 4", "output1 when 'RichFaces
4' in input");
-
- output = selenium.getText(output2);
- assertEquals(output, "RichFa", "output2 when 'RichFaces 4'
in input");
-
- output = selenium.getText(output3);
- assertEquals(output, "RICHFACES 4", "output3 when 'RichFaces
4' in input");
- }
-
- @Test(dataProvider = "templates")
- public void testSimpleClickUnicode(String templates) {
- selenium.typeKeys(input, "ľščťžýáíéňô");
- selenium.click(link);
-
- waitGui.until(textEquals.locator(output1).text("ľščťžýáíéňô"));
-
- String output = selenium.getText(output1);
- assertEquals(output, "ľščťžýáíéňô", "output1 when
'ľščťžýáíéňô' in input");
-
- output = selenium.getText(output2);
- assertEquals(output, "ľščťžý", "output2 when 'ľščťžýáíéňô'
in input");
-
- output = selenium.getText(output3);
- assertEquals(output, "ĽŠČŤŽÝÁÍÉŇÔ", "output3 when
'ľščťžýáíéňô' in input");
- }
-
- @Test(dataProvider = "templates")
- public void testAction(String templates) {
- ElementLocator doubleStringAction =
pjq("input[value=doubleStringAction]");
- ElementLocator first6CharsAction =
pjq("input[value=first6CharsAction]");
- ElementLocator toUpperCaseAction =
pjq("input[value=toUpperCaseAction]");
-
- selenium.click(doubleStringAction);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(link);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
- String output = selenium.getText(output2);
- assertEquals(output, "RichFaces 4RichFaces 4",
- "output2 when 'RichFaces 4' in input and doubleStringAction
selected");
-
- selenium.click(first6CharsAction);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4ň");
- selenium.click(link);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4ň"));
- output = selenium.getText(output2);
- assertEquals(output, "RichFa", "output2 when 'RichFaces
4ň' in input and first6CharsAction selected");
-
- selenium.click(toUpperCaseAction);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4ě");
- selenium.click(link);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4ě"));
- output = selenium.getText(output2);
- assertEquals(output, "RICHFACES 4Ě", "output2 when 'RichFaces
4ě' in input and toUpperCaseAction selected");
- }
-
- @Test(dataProvider = "templates")
- public void testActionListener(String templates) {
- ElementLocator doubleStringActionListener =
pjq("input[value=doubleStringActionListener]");
- ElementLocator first6CharsActionListener =
pjq("input[value=first6CharsActionListener]");
- ElementLocator toUpperCaseActionListener =
pjq("input[value=toUpperCaseActionListener]");
-
- selenium.click(doubleStringActionListener);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(link);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
- String output = selenium.getText(output3);
- assertEquals(output, "RichFaces 4RichFaces 4",
- "output2 when 'RichFaces 4' in input and
doubleStringActionListener selected");
-
- selenium.click(first6CharsActionListener);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4ň");
- selenium.click(link);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4ň"));
- output = selenium.getText(output3);
- assertEquals(output, "RichFa", "output2 when 'RichFaces
4ň' in input and first6CharsActionListener selected");
-
- selenium.click(toUpperCaseActionListener);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4ě");
- selenium.click(link);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4ě"));
- output = selenium.getText(output3);
- assertEquals(output, "RICHFACES 4Ě",
- "output2 when 'RichFaces 4ě' in input and
toUpperCaseActionListener selected");
- }
-
- @Test(dataProvider = "templates")
- public void testDisabled(String templates) {
- ElementLocator disabledChecbox = pjq("input[id$=disabledInput]");
- ElementLocator newLink = pjq("span[id$=a4jCommandLink]");
-
- selenium.click(disabledChecbox);
- selenium.waitForPageToLoad(TIMEOUT);
-
- assertFalse(selenium.isElementPresent(link), link.getAsString()
- + " should not be on page when the link is disabled");
- assertTrue(selenium.isElementPresent(newLink), newLink.getAsString()
- + " should be on page when the link is disabled");
-
- }
-
- @Test(dataProvider = "templates")
- public void testOnclick(String templates) {
- testFireEvent(Event.CLICK, link);
- }
-
- @Test(dataProvider = "templates")
- public void testOndblclick(String templates) {
- testFireEvent(Event.DBLCLICK, link);
- }
-
- @Test(dataProvider = "templates")
- public void testOnkeydown(String templates) {
- testFireEvent(Event.KEYDOWN, link);
- }
-
- @Test(dataProvider = "templates")
- public void testOnkeypress(String templates) {
- testFireEvent(Event.KEYPRESS, link);
- }
-
- @Test(dataProvider = "templates")
- public void testOneyup(String templates) {
- testFireEvent(Event.KEYUP, link);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmousedown(String templates) {
- testFireEvent(Event.MOUSEDOWN, link);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmousemove(String templates) {
- testFireEvent(Event.MOUSEMOVE, link);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmouseout(String templates) {
- testFireEvent(Event.MOUSEOUT, link);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmouseover(String templates) {
- testFireEvent(Event.MOUSEOVER, link);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmouseup(String templates) {
- testFireEvent(Event.MOUSEUP, link);
- }
-
- @Test(dataProvider = "templates")
- public void testRender(String templates) {
- ElementLocator renderInput = pjq("input[name$=renderInput]");
-
- selenium.type(renderInput, "output1");
- selenium.waitForPageToLoad(TIMEOUT);
-
- selenium.typeKeys(input, "aaa");
- selenium.click(link);
-
- waitGui.until(textEquals.locator(output1).text("aaa"));
-
- String output = selenium.getText(output1);
- assertEquals(output, "aaa", "output1 when 'aaa' in input
and 'output1' set to be rerendered");
-
- output = selenium.getText(output2);
- assertEquals(output, "", "output2 when 'aaa' in input and
'output1' set to be rerendered");
-
- output = selenium.getText(output3);
- assertEquals(output, "", "output3 when 'aaa' in input and
'output1' set to be rerendered");
-
- selenium.type(renderInput, "output2 output3");
- selenium.waitForPageToLoad(TIMEOUT);
-
- selenium.typeKeys(input, "bbb");
- selenium.click(link);
-
- waitGui.until(textEquals.locator(output2).text("bbb"));
-
- output = selenium.getText(output1);
- assertEquals(output, "aaa", "output1 when 'bbb' in input
and 'output2 output3' set to be rerendered");
-
- output = selenium.getText(output2);
- assertEquals(output, "bbb", "output2 when 'bbb' in input
and 'output2 output3' set to be rerendered");
-
- output = selenium.getText(output3);
- assertEquals(output, "BBB", "output3 when 'bbb' in input
and 'output2 output3' set to be rerendered");
-
- }
-
- @Test(dataProvider = "templates")
- public void testRendered(String templates) {
- ElementLocator renderedCheckbox = pjq("input[name$=renderedInput]");
-
- selenium.click(renderedCheckbox);
- selenium.waitForPageToLoad(TIMEOUT);
- assertFalse(selenium.isElementPresent(link), "Button should not be
displayed");
- }
-
- @Test(dataProvider = "templates")
- public void testStyleClass(String templates) {
- ElementLocator bold = pjq("input[name$=styleClassInput][value=bold]");
- ElementLocator strike =
pjq("input[name$=styleClassInput][value=strike]");
- ElementLocator none = pjq("input[name$=styleClassInput][value=]");
-
- final AttributeLocator classAttribute = link.getAttribute(new
Attribute("class"));
-
- selenium.click(bold);
- selenium.waitForPageToLoad(TIMEOUT);
- assertTrue(selenium.belongsClass(link, "bold"), "Button's
class was not changed to 'bold'");
-
- selenium.click(strike);
- selenium.waitForPageToLoad(TIMEOUT);
- assertTrue(selenium.belongsClass(link, "strike"), "Button's
class was not changed to 'strike'");
-
- selenium.click(none);
- selenium.waitForPageToLoad(TIMEOUT);
- assertFalse(selenium.isAttributePresent(classAttribute), "Button's class
was not removed.");
- }
-
- @Test(dataProvider = "templates")
- public void testStyle(String templates) {
- ElementLocator styleInput = pjq("input[id$=styleInput]");
- final AttributeLocator attribute = link.getAttribute(new
Attribute("style"));
- final String value = "font-size: 20px;";
-
- selenium.type(styleInput, value);
- selenium.waitForPageToLoad(TIMEOUT);
-
- assertEquals(selenium.getAttribute(attribute), value, "Style of the button
did not change");
- }
-
- @Test(dataProvider = "templates")
- public void testValue(String templates) {
- ElementLocator valueInput = pjq("input[id$=valueInput]");
- final String value = "new label";
-
- selenium.type(valueInput, value);
- selenium.waitForPageToLoad(TIMEOUT);
-
- assertEquals(selenium.getText(link), value, "Value of the button did not
change");
- }
-
- private void testFireEvent(Event event) {
- ElementLocator eventInput = pjq("input[id$=on" + event.getEventName() +
"Input]");
- final String value = "alert('" + event.getEventName() +
"')";
-
- selenium.type(eventInput, value);
- selenium.fireEvent(eventInput, Event.BLUR);
- selenium.waitForPageToLoad(TIMEOUT);
-
- selenium.fireEvent(link, event);
-
- assertEquals(selenium.getAlert(), event.getEventName(), event.getEventName()
- + " attribute did not change correctly");
- }
-
-}
Deleted:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jLog/A4JLogTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jLog/A4JLogTestCase.java 2010-07-10
21:14:22 UTC (rev 17913)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jLog/A4JLogTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -1,234 +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.testapp.a4jLog;
-
-import static org.jboss.test.selenium.locator.LocatorFactory.jq;
-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.ElementLocator;
-import org.jboss.test.selenium.locator.JQueryLocator;
-import org.richfaces.tests.testapp.AbstractTestappTestCase;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-/**
- * Test case for page /faces/components/a4jLog/simple.xhtml
- *
- * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
- * @version $Revision$
- */
-public class A4JLogTestCase extends AbstractTestappTestCase {
-
- /**
- * Enumeration representing all possible levels for a4j:log.
- */
- public enum LogLevel {
- DEBUG, INFO, WARN, ERROR;
- }
-
- private ElementLocator input = pjq("input[id$=nameInput]");
- private ElementLocator submitButton = pjq("input[id$=submitButton]");
- private ElementLocator output = pjq("span[id$=out]");
-
- private ElementLocator log = pjq("div.rich-log");
- private ElementLocator levelSelect = pjq("div.rich-log select");
- private JQueryLocator logMsg = pjq("div.rich-log div.rich-log-contents
div");
-
- @Override
- public URL getTestUrl() {
- return buildUrl(contextPath, "faces/components/a4jLog/simple.xhtml");
- }
-
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
-
- @Test(dataProvider = "templates")
- public void testSubmit(String templates) {
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(submitButton);
-
- waitGui.until(textEquals.locator(output).text("Hello RichFaces 4!"));
-
- int count = selenium.getCount(logMsg);
- assertTrue(count > 0, "There should be at least one message in log after
submit button was clicked.");
- }
-
- @Test(dataProvider = "templates")
- public void testSubmitUnicode(String templates) {
- selenium.typeKeys(input, "ľščťžýáíéôúäň");
- selenium.click(submitButton);
-
- waitGui.until(textEquals.locator(output).text("Hello
ľščťžýáíéôúäň!"));
-
- int count = selenium.getCount(logMsg);
- assertTrue(count > 0, "There should be at least one message in log after
submit button was clicked.");
- }
-
- @Test(dataProvider = "templates")
- public void testClearButton(String templates) {
- ElementLocator clearButton = pjq("div.rich-log button");
-
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(submitButton);
-
- waitGui.until(textEquals.locator(output).text("Hello RichFaces 4!"));
-
- int count = selenium.getCount(logMsg);
- assertTrue(count > 0, "There should be at least one message in log after
submit button was clicked.");
-
- // test clear
- selenium.click(clearButton);
- count = selenium.getCount(logMsg);
- assertEquals(count, 0, "There should be no messages in log after clear
button was clicked.");
- }
-
- @Test(dataProvider = "templates")
- public void testRendered(String templates) {
- ElementLocator renderedInput = pjq("input[id$=renderedInput]");
-
- selenium.click(renderedInput);
- selenium.waitForPageToLoad(TIMEOUT);
-
- assertFalse(selenium.isElementPresent(log), "Log should not be
displayed.");
- }
-
- @Test(dataProvider = "templates")
- public void testDebugFilterDebug(String templates) {
- testLogging(LogLevel.DEBUG, LogLevel.DEBUG);
- }
-
- @Test(dataProvider = "templates")
- public void testDebugFilterInfo(String templates) {
- testLogging(LogLevel.DEBUG, LogLevel.INFO);
- }
-
- @Test(dataProvider = "templates")
- public void testDebugFilterWarn(String templates) {
- testLogging(LogLevel.DEBUG, LogLevel.WARN);
- }
-
- @Test(dataProvider = "templates")
- public void testDebugFilterError(String templates) {
- testLogging(LogLevel.DEBUG, LogLevel.ERROR);
- }
-
- @Test(dataProvider = "templates")
- public void testInfoFilterDebug(String templates) {
- testLogging(LogLevel.INFO, LogLevel.DEBUG);
- }
-
- @Test(dataProvider = "templates")
- public void testInfoFilterInfo(String templates) {
- testLogging(LogLevel.INFO, LogLevel.INFO);
- }
-
- @Test(dataProvider = "templates")
- public void testInfoFilterWarn(String templates) {
- testLogging(LogLevel.INFO, LogLevel.WARN);
- }
-
- @Test(dataProvider = "templates")
- public void testInfoFilterError(String templates) {
- testLogging(LogLevel.INFO, LogLevel.ERROR);
- }
-
- @Test(dataProvider = "templates")
- public void testWarnFilterDebug(String templates) {
- testLogging(LogLevel.WARN, LogLevel.DEBUG);
- }
-
- @Test(dataProvider = "templates")
- public void testWarnFilterInfo(String templates) {
- testLogging(LogLevel.WARN, LogLevel.INFO);
- }
-
- @Test(dataProvider = "templates")
- public void testWarnFilterWarn(String templates) {
- testLogging(LogLevel.WARN, LogLevel.WARN);
- }
-
- @Test(dataProvider = "templates")
- public void testWarnFilterError(String templates) {
- testLogging(LogLevel.WARN, LogLevel.ERROR);
- }
-
- @Test(dataProvider = "templates")
- public void testErrorFilterDebug(String templates) {
- testLogging(LogLevel.ERROR, LogLevel.DEBUG);
- }
-
- @Test(dataProvider = "templates")
- public void testErrorFilterInfo(String templates) {
- testLogging(LogLevel.ERROR, LogLevel.INFO);
- }
-
- @Test(dataProvider = "templates")
- public void testErrorFilterWarn(String templates) {
- testLogging(LogLevel.ERROR, LogLevel.WARN);
- }
-
- @Test(dataProvider = "templates")
- public void testErrorFilterError(String templates) {
- testLogging(LogLevel.ERROR, LogLevel.ERROR);
- }
-
- private void testLogging(LogLevel logLevel, LogLevel filterLevel) {
- ElementLocator logButton = pjq("input[id$=" +
logLevel.toString().toLowerCase() + "Button]");
- ElementLocator levelInput = pjq("input[type=radio][value=" +
filterLevel.toString().toLowerCase() + "]");
- ElementLocator msgType = logMsg.getChild(jq("span:eq(0)"));
- ElementLocator msgContent = logMsg.getChild(jq("span:eq(1)"));
-
- if (filterLevel != LogLevel.DEBUG) {
- selenium.click(levelInput);
- selenium.waitForPageToLoad(TIMEOUT);
- }
-
- String selectedLevel = selenium.getSelectedLabel(levelSelect);
- assertEquals(selectedLevel, filterLevel.toString().toLowerCase(), "Log level
in select wasn't changed.");
-
- selenium.typeKeys(input, logLevel.toString());
- selenium.click(logButton);
-
- int count = selenium.getCount(logMsg);
- assertEquals(count, filterLevel.ordinal() <= logLevel.ordinal() ? 1 : 0,
- "There should be only one message in log.");
-
- if (count == 0) {
- return;
- }
-
- String output = selenium.getText(msgType).replaceAll("\\[.*\\]:$",
"");
- assertEquals(output, logLevel.toString().toLowerCase(), "Message type in
log.");
- output = selenium.getText(msgContent);
- assertEquals(output, logLevel.toString(), "Message content.");
-
- }
-}
Deleted:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jOutputPanel/A4JOutputPanelTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jOutputPanel/A4JOutputPanelTestCase.java 2010-07-10
21:14:22 UTC (rev 17913)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jOutputPanel/A4JOutputPanelTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -1,307 +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.testapp.a4jOutputPanel;
-
-import static org.jboss.test.selenium.locator.LocatorFactory.jq;
-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.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.richfaces.tests.testapp.AbstractTestappTestCase;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-/**
- * Test case for page /faces/components/a4jOutputPanel/simple.xhtml
- *
- * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
- * @version $Revision$
- */
-public class A4JOutputPanelTestCase extends AbstractTestappTestCase {
-
- private ElementLocator increaseCounterButton = pjq("input[id$=button]");
- private ElementLocator outputDiv = pjq("div[id$=outputPanel]");
- private ElementLocator outputSpan = pjq("span[id$=outputPanel]");
- private ElementLocator optionBlue =
pjq("input[name$=styleClassInput][value=blue-background]");
- private ElementLocator optionGray =
pjq("input[name$=styleClassInput][value=gray-background]");
-
- @Override
- public URL getTestUrl() {
- return buildUrl(contextPath,
"faces/components/a4jOutputPanel/simple.xhtml");
- }
-
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
-
- /**
- * Data provider for templates, events and layout of output panel.
- *
- * @return array containing templates that should be used (defined in testng.xml) or
default array (containing only
- * plain template) if nothing is defined, JavaScript events that are defined
for output panel and layout of
- * panel (block or inline)
- */
- @DataProvider(name = "templatesEventsLayouts")
- private Object[][] getTemplatesEventsLayouts() {
- final int layoutsCount = 2;
- // list of templates, e.g. {{"plain"},
{"richDataTable1,redDiv"}}
- Object[][] templates = getTemplates();
- // list of events that will be tested
- Event[] events = new Event[]{Event.CLICK, Event.DBLCLICK, Event.KEYDOWN,
Event.KEYPRESS, Event.KEYUP,
- Event.MOUSEDOWN, Event.MOUSEMOVE, Event.MOUSEOUT, Event.MOUSEOVER,
Event.MOUSEUP};
-
- Object[][] result = new Object[templates.length * events.length *
layoutsCount][];
- int index = 0;
-
- for (int i = 0; i < templates.length; i++) {
- for (int j = 0; j < events.length; j++) {
- for (int k = 0; k < layoutsCount; k++) {
- index = i * events.length * layoutsCount + j * layoutsCount + k;
- result[index] = new Object[]{templates[i][0], events[j], k == 0 ?
"block" : "inline"};
- }
- }
- }
-
- return result;
- }
-
- @Test(dataProvider = "templatesEventsLayouts")
- public void testEvent(String templates, Event event, String type) {
- ElementLocator element = null;
-
- if ("inline".equals(type)) {
- // for inline layout set background to blue
- selenium.click(pjq("input[name$=layoutInput][value=inline]"));
- selenium.waitForPageToLoad(TIMEOUT);
-
- selenium.click(optionBlue);
- selenium.waitForPageToLoad(TIMEOUT);
-
- element = outputSpan;
- } else {
- // for inline layout set background to gray
- selenium.click(optionGray);
- selenium.waitForPageToLoad(TIMEOUT);
-
- element = outputDiv;
- }
-
- testFireEvent(event, element);
- }
-
- @Test(dataProvider = "templates")
- public void testClick(String templates) {
- selenium.click(increaseCounterButton);
- waitGui.until(textEquals.locator(outputDiv).text("1"));
-
- selenium.click(increaseCounterButton);
- waitGui.until(textEquals.locator(outputDiv).text("2"));
- }
-
- @Test(dataProvider = "templates")
- public void testAjaxRendered(String templates) {
- ElementLocator ajaxRenderedCheckbox =
pjq("input[id$=ajaxRenderedInput]");
- ElementLocator reRenderAllImage = jq("div.header
img[id$=reRenderAllImage]");
-
- selenium.click(ajaxRenderedCheckbox);
- selenium.waitForPageToLoad(TIMEOUT);
-
- selenium.click(increaseCounterButton);
- selenium.click(increaseCounterButton);
-
- String output = selenium.getText(outputDiv);
- assertEquals(output, "0", "Output after two clicks when
ajaxRendered is set to false.");
-
- selenium.click(reRenderAllImage);
- waitGui.until(textEquals.locator(outputDiv).text("2"));
- }
-
- @Test(dataProvider = "templates")
- public void testDir(String templates) {
- ElementLocator optionLtr = pjq("input[name$=dirInput][value=ltr]");
- ElementLocator optionRtl = pjq("input[name$=dirInput][value=rtl]");
- ElementLocator optionNone = pjq("input[name$=dirInput][value=]");
- AttributeLocator attributeDir = outputDiv.getAttribute(new
Attribute("dir"));
-
- // right-to-left
- selenium.click(optionRtl);
- selenium.waitForPageToLoad(TIMEOUT);
- String attributeValue = selenium.getAttribute(attributeDir);
- assertEquals(attributeValue, "rtl", "Attribute dir after rtl was
set.");
-
- // left-to-right
- selenium.click(optionLtr);
- selenium.waitForPageToLoad(TIMEOUT);
- attributeValue = selenium.getAttribute(attributeDir);
- assertEquals(attributeValue, "ltr", "Attribute dir after ltr was
set.");
-
- // not specified
- selenium.click(optionNone);
- selenium.waitForPageToLoad(TIMEOUT);
- if (selenium.isAttributePresent(attributeDir)) {
- attributeValue = selenium.getAttribute(attributeDir);
- assertEquals(attributeValue, "", "Attribute dir after none was
set.");
- }
- }
-
- @Test(dataProvider = "templates")
- public void testLang(String templates) {
- ElementLocator langInput = pjq("input[id$=langInput]");
- AttributeLocator attributeLang = outputDiv.getAttribute(new
Attribute("lang"));
-
- selenium.typeKeys(langInput, "en");
- selenium.waitForPageToLoad(TIMEOUT);
-
- String attributeValue = selenium.getAttribute(attributeLang);
- assertEquals(attributeValue, "en", "Lang attribute");
-
- selenium.typeKeys(langInput, "sk");
- selenium.waitForPageToLoad(TIMEOUT);
-
- attributeValue = selenium.getAttribute(attributeLang);
- assertEquals(attributeValue, "sk", "Lang attribute");
- }
-
- @Test(dataProvider = "templates")
- public void testLayout(String templates) {
- ElementLocator optionBlock =
pjq("input[name$=layoutInput][value=block]");
- ElementLocator optionInline =
pjq("input[name$=layoutInput][value=inline]");
- ElementLocator optionNone =
pjq("input[name$=layoutInput][value=none]");
-
- assertTrue(selenium.isElementPresent(outputDiv), "Div should be rendered on
the beginning.");
- assertFalse(selenium.isElementPresent(outputSpan), "Div should be rendered
on the beginning.");
-
- selenium.click(optionInline);
- selenium.waitForPageToLoad(TIMEOUT);
- assertFalse(selenium.isElementPresent(outputDiv), "Span should be rendered
when inline is set.");
- assertTrue(selenium.isElementPresent(outputSpan), "Span should be rendered
when inline is set.");
-
- selenium.click(optionBlock);
- selenium.waitForPageToLoad(TIMEOUT);
- assertTrue(selenium.isElementPresent(outputDiv), "Div should be rendered
when block is set.");
- assertFalse(selenium.isElementPresent(outputSpan), "Div should be rendered
when block is set.");
-
- selenium.click(optionNone);
- selenium.waitForPageToLoad(TIMEOUT);
- assertFalse(selenium.isElementPresent(outputDiv), "Span should be rendered
when none is set.");
- assertTrue(selenium.isElementPresent(outputSpan), "Span should be rendered
when none is set.");
- }
-
- @Test(dataProvider = "templates")
- public void testRendered(String templates) {
- ElementLocator renderedInput = pjq("input[id$=renderedInput]");
-
- selenium.click(renderedInput);
- selenium.waitForPageToLoad(TIMEOUT);
- assertFalse(selenium.isElementPresent(outputDiv), "Panel should not be
rendered.");
-
- selenium.click(increaseCounterButton);
- selenium.click(increaseCounterButton);
-
- selenium.click(renderedInput);
- selenium.waitForPageToLoad(TIMEOUT);
- assertTrue(selenium.isElementPresent(outputDiv), "Panel should be
rendered.");
-
- String counter = selenium.getText(outputDiv);
- assertEquals(counter, "2", "Counter after two clicks on
button.");
- }
-
- @Test(dataProvider = "templates")
- public void testStyle(String templates) {
- String style = "background-color: magenta; color: white; font-weight:
bold;";
- ElementLocator styleInput = pjq("input[id$=styleInput]");
- AttributeLocator attributeStyle = outputDiv.getAttribute(Attribute.STYLE);
-
- selenium.typeKeys(styleInput, style);
- selenium.waitForPageToLoad(TIMEOUT);
-
- String attributeValue = selenium.getAttribute(attributeStyle);
- assertEquals(attributeValue, style, "Value of attribute style.");
-
- selenium.typeKeys(styleInput, "");
- selenium.waitForPageToLoad(TIMEOUT);
-
- if (selenium.isAttributePresent(attributeStyle)) {
- attributeValue = selenium.getAttribute(attributeStyle);
- assertEquals(attributeValue, "", "Value of attribute
style.");
- }
- }
-
- @Test(dataProvider = "templates")
- public void testStyleClass(String templates) {
- ElementLocator optionNone =
pjq("input[name$=styleClassInput][value=]");
- AttributeLocator attributeClass = outputDiv.getAttribute(Attribute.CLASS);
-
- selenium.click(optionBlue);
- selenium.waitForPageToLoad(TIMEOUT);
- assertTrue(selenium.belongsClass(outputDiv, "blue-background"),
"Panel should have class blue-background set.");
- assertFalse(selenium.belongsClass(outputDiv, "gray-background"),
- "Panel should not have class gray-background set.");
-
- selenium.click(optionGray);
- selenium.waitForPageToLoad(TIMEOUT);
- assertTrue(selenium.belongsClass(outputDiv, "gray-background"),
"Panel should have class gray-background set.");
- assertFalse(selenium.belongsClass(outputDiv, "blue-background"),
- "Panel should not have class blue-background set.");
-
- selenium.click(optionNone);
- selenium.waitForPageToLoad(TIMEOUT);
- if (selenium.isAttributePresent(attributeClass)) {
- assertFalse(selenium.belongsClass(outputDiv, "blue-background"),
- "Panel should not have class blue-background set.");
- assertFalse(selenium.belongsClass(outputDiv, "gray-background"),
- "Panel should not have class gray-background set.");
- }
- }
-
- @Test(dataProvider = "templates")
- public void testTitle(String templates) {
- String title = "a4j:outputPanel title";
- ElementLocator titleInput = pjq("input[id$=titleInput]");
- AttributeLocator attributeTitle = outputDiv.getAttribute(new
Attribute("title"));
-
- selenium.typeKeys(titleInput, title);
- selenium.waitForPageToLoad(TIMEOUT);
-
- String attributeValue = selenium.getAttribute(attributeTitle);
- assertEquals(attributeValue, title, "Value of attribute title.");
-
- selenium.typeKeys(titleInput, "");
- selenium.waitForPageToLoad(TIMEOUT);
-
- if (selenium.isAttributePresent(attributeTitle)) {
- attributeValue = selenium.getAttribute(attributeTitle);
- assertEquals(attributeValue, "", "Value of attribute
style.");
- }
- }
-}
Deleted:
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:14:22 UTC (rev 17913)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPoll/PollTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -1,155 +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.testapp.a4jPoll;
-
-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;
-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.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.
- *
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-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 = 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() {
- 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 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>
- */
- @Test(dataProvider = "templates", groups = "client-side-perf")
- public void testIntervalFromClientPerspective(String templates) {
-
- long total = 0;
- long count = 0;
- for (int interval : TEST_INTERVAL_VALUES) {
- selenium.type(attributeInterval, String.valueOf(interval));
- selenium.waitForPageToLoad();
-
- selenium.check(attributeEnabled);
- selenium.fireEvent(attributeEnabled, Event.CHANGE);
- selenium.waitForPageToLoad();
-
- 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 -= getClientTime();
- if (i > 0) {
-
- long deviation = Math.abs(interval - Math.abs(runtime));
- if (isSeleniumDebug()) {
- System.out.println(format("deviation for interval {0}:
{1}", interval, deviation));
- }
- 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(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));
- }
-
-}
Deleted:
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:14:22 UTC (rev 17913)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/AbstractPushTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -1,116 +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.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());
- }
-
- /**
- * 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);
- }
-}
Deleted:
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:14:22 UTC (rev 17913)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/IntervalTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -1,165 +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.testapp.a4jPush;
-
-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;
-
-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;
-
-/**
- * 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 Attribute ATTRIBUTE_TITLE = new Attribute("title");
- private static final int[] INTERVAL_VALUES = new int[]{1000, 5000, 500};
- 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;
-
- 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 testIntervalFromClientPerspective() 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 = getClientTime();
- 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 = 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(format("deviation for interval {0}: {1}",
interval, 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));
- }
-
- /**
- * 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));
- }
-}
Deleted:
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 2010-07-10
21:14:22 UTC (rev 17913)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/PushAttributes.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -1,51 +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.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();
- }
-}
Deleted:
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 2010-07-10
21:14:22 UTC (rev 17913)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jPush/SimpleTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -1,65 +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.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));
- }
-}
Deleted:
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:14:22 UTC (rev 17913)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/hCommandButton/HCommandButtonTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -1,290 +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.testapp.hCommandButton;
-
-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.dom.Event;
-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.testapp.AbstractTestappTestCase;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-/**
- * Test case for page /faces/components/commandButton/simple.xhtml
- *
- * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
- * @version $Revision$
- */
-public class HCommandButtonTestCase extends AbstractTestappTestCase {
-
- private JQueryLocator input = pjq("input[id$=input]");
- private JQueryLocator button = pjq("input[id$=commandButton]");
- private JQueryLocator output1 = pjq("span[id$=output1]");
- private JQueryLocator output2 = pjq("span[id$=output2]");
- private JQueryLocator output3 = pjq("span[id$=output3]");
-
- @Override
- public URL getTestUrl() {
- return buildUrl(contextPath,
"faces/components/commandButton/simple.xhtml");
- }
-
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
-
- @Test(dataProvider = "templates", groups = "client-side-perf")
- public void testSimpleClick(String templates) {
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(button);
-
- waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
-
- String output = selenium.getText(output1);
- assertEquals(output, "RichFaces 4", "output1 when 'RichFaces
4' in input");
-
- output = selenium.getText(output2);
- assertEquals(output, "RichFa", "output2 when 'RichFaces 4'
in input");
-
- output = selenium.getText(output3);
- assertEquals(output, "RICHFACES 4", "output3 when 'RichFaces
4' in input");
- }
-
- @Test(dataProvider = "templates")
- public void testSimpleClickUnicode(String templates) {
- selenium.typeKeys(input, "ľščťžýáíéňô");
- selenium.click(button);
-
- waitGui.until(textEquals.locator(output1).text("ľščťžýáíéňô"));
-
- String output = selenium.getText(output1);
- assertEquals(output, "ľščťžýáíéňô", "output1 when
'ľščťžýáíéňô' in input");
-
- output = selenium.getText(output2);
- assertEquals(output, "ľščťžý", "output2 when 'ľščťžýáíéňô'
in input");
-
- output = selenium.getText(output3);
- assertEquals(output, "ĽŠČŤŽÝÁÍÉŇÔ", "output3 when
'ľščťžýáíéňô' in input");
- }
-
- @Test(dataProvider = "templates")
- public void testAction(String templates) {
- JQueryLocator doubleStringAction =
pjq("input[value=doubleStringAction]");
- JQueryLocator first6CharsAction =
pjq("input[value=first6CharsAction]");
- JQueryLocator toUpperCaseAction =
pjq("input[value=toUpperCaseAction]");
-
- selenium.click(doubleStringAction);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(button);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
- String output = selenium.getText(output2);
- assertEquals(output, "RichFaces 4RichFaces 4",
- "output2 when 'RichFaces 4' in input and doubleStringAction
selected");
-
- selenium.click(first6CharsAction);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4ň");
- selenium.click(button);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4ň"));
- output = selenium.getText(output2);
- assertEquals(output, "RichFa", "output2 when 'RichFaces
4ň' in input and first6CharsAction selected");
-
- selenium.click(toUpperCaseAction);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4ě");
- selenium.click(button);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4ě"));
- output = selenium.getText(output2);
- assertEquals(output, "RICHFACES 4Ě", "output2 when 'RichFaces
4ě' in input and toUpperCaseAction selected");
- }
-
- @Test(dataProvider = "templates")
- public void testActionListener(String templates) {
- JQueryLocator doubleStringActionListener =
pjq("input[value=doubleStringActionListener]");
- JQueryLocator first6CharsActionListener =
pjq("input[value=first6CharsActionListener]");
- JQueryLocator toUpperCaseActionListener =
pjq("input[value=toUpperCaseActionListener]");
-
- selenium.click(doubleStringActionListener);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(button);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
- String output = selenium.getText(output3);
- assertEquals(output, "RichFaces 4RichFaces 4",
- "output2 when 'RichFaces 4' in input and
doubleStringActionListener selected");
-
- selenium.click(first6CharsActionListener);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4ň");
- selenium.click(button);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4ň"));
- output = selenium.getText(output3);
- assertEquals(output, "RichFa", "output2 when 'RichFaces
4ň' in input and first6CharsActionListener selected");
-
- selenium.click(toUpperCaseActionListener);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4ě");
- selenium.click(button);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4ě"));
- output = selenium.getText(output3);
- assertEquals(output, "RICHFACES 4Ě",
- "output2 when 'RichFaces 4ě' in input and
toUpperCaseActionListener selected");
- }
-
- @Test(dataProvider = "templates")
- public void testDisabled(String templates) {
- JQueryLocator disabledChecbox = pjq("input[id$=disabledInput]");
- AttributeLocator disabledAttribute = button.getAttribute(new
Attribute("disabled"));
-
- selenium.click(disabledChecbox);
- selenium.waitForPageToLoad(TIMEOUT);
-
- String isDisabled = selenium.getAttribute(disabledAttribute);
- assertEquals(isDisabled.toLowerCase(), "disabled", "The value of
attribute disabled");
- }
-
- // not implemented in Mojarra
- // @Test(dataProvider = "templates")
- public void testOnblur(String templates) {
- testFireEvent(Event.BLUR, button);
- }
-
- // not implemented in Mojarra
- // @Test(dataProvider = "templates")
- public void testOnchange(String templates) {
- testFireEvent(Event.CHANGE, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnclick(String templates) {
- testFireEvent(Event.CLICK, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOndblclick(String templates) {
- testFireEvent(Event.DBLCLICK, button);
- }
-
- // not implemented in Mojarra
- // @Test(dataProvider = "templates")
- public void testOnfocus(String templates) {
- testFireEvent(Event.FOCUS, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnkeydown(String templates) {
- testFireEvent(Event.KEYDOWN, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnkeypress(String templates) {
- testFireEvent(Event.KEYPRESS, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnkeyup(String templates) {
- testFireEvent(Event.KEYUP, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmousedown(String templates) {
- testFireEvent(Event.MOUSEDOWN, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmousemove(String templates) {
- testFireEvent(Event.MOUSEMOVE, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmouseout(String templates) {
- testFireEvent(Event.MOUSEOUT, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmouseover(String templates) {
- testFireEvent(Event.MOUSEOVER, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmouseup(String templates) {
- testFireEvent(Event.MOUSEUP, button);
- }
-
- @Test(dataProvider = "templates")
- public void testStyleClass(String templates) {
-
- JQueryLocator wide = pjq("input[name$=styleClassInput][value=wide]");
- JQueryLocator big = pjq("input[name$=styleClassInput][value=big]");
- JQueryLocator none = pjq("input[name$=styleClassInput][value=]");
-
- final AttributeLocator classAttribute = button.getAttribute(new
Attribute("class"));
-
- selenium.click(wide);
- selenium.waitForPageToLoad(TIMEOUT);
- assertTrue(selenium.belongsClass(button, "wide"), "Button's
class was not changed to 'wide'");
-
- selenium.click(big);
- selenium.waitForPageToLoad(TIMEOUT);
- assertTrue(selenium.belongsClass(button, "big"), "Button's
class was not changed to 'big'");
-
- selenium.click(none);
- selenium.waitForPageToLoad(TIMEOUT);
- assertFalse(selenium.isAttributePresent(classAttribute), "Button's class
was not removed.");
- }
-
- @Test(dataProvider = "templates")
- public void testStyle(String templates) {
- JQueryLocator styleInput = pjq("input[id$=styleInput]");
- final AttributeLocator attribute = button.getAttribute(new
Attribute("style"));
- final String value = "font-size: 20px;";
-
- selenium.type(styleInput, value);
- selenium.waitForPageToLoad(TIMEOUT);
-
- assertEquals(selenium.getAttribute(attribute), value, "Style of the button
did not change");
- }
-
- @Test(dataProvider = "templates")
- public void testValue(String templates) {
- JQueryLocator valueInput = pjq("input[id$=valueInput]");
- final AttributeLocator attribute = button.getAttribute(new
Attribute("value"));
- final String value = "new label";
-
- selenium.type(valueInput, value);
- selenium.waitForPageToLoad(TIMEOUT);
-
- assertEquals(selenium.getAttribute(attribute), value, "Value of the button
did not change");
- }
-
-}
Deleted:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/DataScroller.java
===================================================================
---
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/DataScroller.java 2010-07-10
21:14:22 UTC (rev 17913)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/DataScroller.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -1,114 +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.testapp.richExtendedDataTable;
-
-import org.jboss.test.selenium.framework.AjaxSelenium;
-import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
-import org.jboss.test.selenium.locator.JQueryLocator;
-
-import static org.jboss.test.selenium.locator.LocatorFactory.*;
-import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.*;
-
-/**
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-public class DataScroller {
-
- AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
-
- JQueryLocator scrollerRoot;
- JQueryLocator pageNumbers = jq(".rf-ds-dtl");
- JQueryLocator firstPageButton = jq(".rf-ds-l[id$=ds_f]");
- JQueryLocator lastPageButton = jq(".rf-ds-r:eq(1)");
- JQueryLocator lastVisiblePage = jq(".rf-ds-dtl:last");
- JQueryLocator currentPage = jq(".rf-ds-cur");
-
- public DataScroller(JQueryLocator scrollerRoot) {
- this.scrollerRoot = scrollerRoot;
- }
-
- public JQueryLocator getRoot() {
- return scrollerRoot;
- }
-
- public void gotoFirstPage() {
- if (!isFirstPage()) {
- clickFirstPageButton();
- }
- }
-
- public void gotoLastPage() {
- if (!isLastPage()) {
- clickLastPageButton();
- }
- }
-
- public void clickLastPageButton() {
- JQueryLocator locator = scrollerRoot.getDescendant(lastPageButton);
- guardXhr(selenium).click(locator);
- }
-
- public void clickFirstPageButton() {
- JQueryLocator locator = scrollerRoot.getDescendant(firstPageButton);
- guardXhr(selenium).click(locator);
- }
-
- public int getCountOfVisiblePages() {
- JQueryLocator locator = scrollerRoot.getDescendant(pageNumbers);
- return selenium.getCount(locator);
- }
-
- public boolean hasPages() {
- JQueryLocator locator = scrollerRoot.getDescendant(lastVisiblePage);
- return selenium.isElementPresent(locator);
- }
-
- public Integer getLastVisiblePage() {
- JQueryLocator locator = scrollerRoot.getDescendant(lastVisiblePage);
- if (!hasPages()) {
- return null;
- }
- return integer(selenium.getText(locator));
- }
-
- public int getCurrentPage() {
- JQueryLocator locator = scrollerRoot.getDescendant(currentPage);
- if (!hasPages()) {
- return 1;
- }
- return integer(selenium.getText(locator));
- }
-
- public boolean isFirstPage() {
- return getCurrentPage() == 1;
- }
-
- public boolean isLastPage() {
- return getCurrentPage() == getLastVisiblePage();
- }
-
- public static int integer(String string) {
- return Integer.valueOf(string);
- }
-}
Deleted:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/DataTable.java
===================================================================
---
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/DataTable.java 2010-07-10
21:14:22 UTC (rev 17913)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/DataTable.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -1,55 +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.testapp.richExtendedDataTable;
-
-import org.jboss.test.selenium.framework.AjaxSelenium;
-import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
-import org.jboss.test.selenium.locator.JQueryLocator;
-
-import static org.jboss.test.selenium.locator.LocatorFactory.*;
-
-/**
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-public class DataTable {
-
- AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
-
- JQueryLocator tableRoot;
- JQueryLocator tableRows = jq(".rf-dt-c:nth-child(1)");
-
- public DataTable(JQueryLocator tableRoot) {
- super();
- this.tableRoot = tableRoot;
- }
-
- public int getCountOfTableRows() {
- JQueryLocator locator = tableRoot.getDescendant(tableRows);
- return selenium.getCount(locator);
- }
-
- public String getTableText() {
- return selenium.getText(tableRoot);
- }
-}
Deleted:
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:14:22 UTC (rev 17913)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/ScrollerTestCase.java 2010-07-11
00:06:08 UTC (rev 17914)
@@ -1,145 +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.testapp.richExtendedDataTable;
-
-import static org.jboss.test.selenium.locator.LocatorFactory.*;
-import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
-import static org.testng.Assert.assertEquals;
-
-import java.net.URL;
-
-import org.jboss.test.selenium.dom.Event;
-import org.jboss.test.selenium.locator.ElementLocator;
-import org.richfaces.tests.testapp.AbstractTestappTestCase;
-import org.testng.annotations.Test;
-
-/**
- * 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]"));
- ElementLocator attributeRowsInput = id("form:attributes:rowsInput");
-
- @Override
- public URL getTestUrl() {
- return buildUrl(contextPath,
"faces/components/richExtendedDataTable/scroller.xhtml");
- }
-
- /**
- * Tests row count for scroller in footer of the EDT.
- *
- * @see {@link #testRowCount(DataScroller)}
- */
- @Test(dataProvider = "templates", groups = "client-side-perf")
- 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 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 : ROW_COUNT_VALUES) {
- if (rowsPerPage != null) {
- selenium.type(attributeRowsInput, String.valueOf(rowsPerPage));
- selenium.fireEvent(attributeRowsInput, Event.BLUR);
- selenium.waitForPageToLoad();
- }
-
- dataScroller.gotoFirstPage();
- int rowCountPreset = Integer.valueOf(selenium.getValue(attributeRowsInput));
- int rowCountActual = table.getCountOfTableRows();
- assertEquals(rowCountActual, Math.min(TOTAL_ROW_COUNT, rowCountPreset));
-
- assertEquals(dataScroller.hasPages(), rowCountActual < TOTAL_ROW_COUNT);
- if (dataScroller.hasPages()) {
- dataScroller.gotoLastPage();
-
- int pagesExpected = pageCountActualExpected(rowCountActual);
- int countOfVisiblePages = dataScroller.getCountOfVisiblePages();
-
- if (countOfVisiblePages < pagesExpected) {
- int lastVisiblePage = dataScroller.getLastVisiblePage();
- assertEquals(lastVisiblePage,
pageCountActualExpected(rowCountActual));
- } else {
- assertEquals(countOfVisiblePages, pagesExpected);
- }
-
- int rowCountExpected = rowCountLastPageExpected(rowCountPreset);
- rowCountActual = table.getCountOfTableRows();
- assertEquals(rowCountActual, rowCountExpected);
- }
- }
- }
-
- private int pageCountActualExpected(int rowCountActual) {
- return Double.valueOf(Math.ceil((double) TOTAL_ROW_COUNT /
rowCountActual)).intValue();
- }
-
- private int rowCountLastPageExpected(int rowCountPreset) {
- int result = TOTAL_ROW_COUNT % rowCountPreset;
- return (result == 0) ? rowCountPreset : result;
- }
-
-}