Author: lfryc(a)redhat.com
Date: 2010-07-10 17:02:49 -0400 (Sat, 10 Jul 2010)
New Revision: 17893
Added:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jLog/
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jLog/A4JLogTestCase.java
Modified:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandButton/A4JCommandButtonTestCase.java
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandLink/A4JCommandLinkTestCase.java
Log:
https://jira.jboss.org/browse/RFPL-466
* added tests for a4j:log
* 2 tests (for button and link) uncommented
Modified:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandButton/A4JCommandButtonTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandButton/A4JCommandButtonTestCase.java 2010-07-10
21:02:09 UTC (rev 17892)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandButton/A4JCommandButtonTestCase.java 2010-07-10
21:02:49 UTC (rev 17893)
@@ -62,7 +62,7 @@
super.invalidateSession();
}
- // @Test(dataProvider = "templates", groups =
"client-side-perf")
+ @Test(dataProvider = "templates", groups = "client-side-perf")
public void testSimpleClick(String templates) {
selenium.typeKeys(input, "RichFaces 4");
selenium.click(button);
Modified:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandLink/A4JCommandLinkTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandLink/A4JCommandLinkTestCase.java 2010-07-10
21:02:09 UTC (rev 17892)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jCommandLink/A4JCommandLinkTestCase.java 2010-07-10
21:02:49 UTC (rev 17893)
@@ -62,7 +62,7 @@
super.invalidateSession();
}
- // @Test(dataProvider = "templates", groups =
"client-side-perf")
+ @Test(dataProvider = "templates", groups = "client-side-perf")
public void testSimpleClick(String templates) {
selenium.typeKeys(input, "RichFaces 4");
selenium.click(link);
Added:
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
(rev 0)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/a4jLog/A4JLogTestCase.java 2010-07-10
21:02:49 UTC (rev 17893)
@@ -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.testapp.a4jLog;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+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.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);
+ }
+
+ 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.");
+
+ }
+}