Author: ppitonak(a)redhat.com
Date: 2011-02-04 09:06:56 -0500 (Fri, 04 Feb 2011)
New Revision: 21451
Modified:
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/A4JLogBean.properties
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jLog/list.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jLog/simple.xhtml
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/TestA4JLog.java
Log:
* added 4 tests for a4j:log
Modified:
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/A4JLogBean.properties
===================================================================
---
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/A4JLogBean.properties 2011-02-04
13:42:51 UTC (rev 21450)
+++
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/A4JLogBean.properties 2011-02-04
14:06:56 UTC (rev 21451)
@@ -1,4 +1,10 @@
attr.level.error=error
attr.level.debug=debug
attr.level.info=info
-attr.level.warn=warn
\ No newline at end of file
+attr.level.warn=warn
+attr.level.null=
+
+attr.mode.popup=popup
+attr.mode.inline=inline
+attr.mode.console=console
+attr.mode.null=
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jLog/list.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jLog/list.xhtml 2011-02-04
13:42:51 UTC (rev 21450)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jLog/list.xhtml 2011-02-04
14:06:56 UTC (rev 21451)
@@ -5,7 +5,7 @@
<!--
JBoss, Home of Professional Open Source
-Copyright 2010, Red Hat, Inc. and individual contributors
+Copyright 2010-2011, Red Hat, Inc. and individual contributors
by the @authors tag. See the copyright.txt in the distribution for a
full listing of individual contributors.
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jLog/simple.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jLog/simple.xhtml 2011-02-04
13:42:51 UTC (rev 21450)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jLog/simple.xhtml 2011-02-04
14:06:56 UTC (rev 21451)
@@ -6,7 +6,7 @@
<!--
JBoss, Home of Professional Open Source
-Copyright 2010, Red Hat, Inc. and individual contributors
+Copyright 2010-2011, Red Hat, Inc. and individual contributors
by the @authors tag. See the copyright.txt in the distribution for a
full listing of individual contributors.
@@ -59,8 +59,12 @@
<br/><br/>
- <a4j:log id="log"
rendered="#{a4jLogBean.attributes['rendered'].value}"
level="#{a4jLogBean.attributes['level'].value}"
- style="#{a4jLogBean.attributes['style'].value}"
styleClass="#{a4jLogBean.attributes['styleClass'].value}"/>
+ <a4j:log id="log"
+ level="#{a4jLogBean.attributes['level'].value}"
+ mode="#{a4jLogBean.attributes['mode'].value}"
+
rendered="#{a4jLogBean.attributes['rendered'].value}"
+ style="#{a4jLogBean.attributes['style'].value}"
+
styleClass="#{a4jLogBean.attributes['styleClass'].value}"/>
</ui:define>
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/TestA4JLog.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/TestA4JLog.java 2011-02-04
13:42:51 UTC (rev 21450)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/TestA4JLog.java 2011-02-04
14:06:56 UTC (rev 21451)
@@ -19,10 +19,11 @@
* 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 java.awt.event.KeyEvent;
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.jboss.test.selenium.locator.option.OptionLocatorFactory.optionLabel;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
@@ -46,13 +47,12 @@
* Enumeration representing all possible levels for a4j:log.
*/
public enum LogLevel {
- DEBUG, INFO, WARN, ERROR;
+
+ DEBUG, NULL, INFO, WARN, ERROR;
}
-
private JQueryLocator input = pjq("input[id$=nameInput]");
private JQueryLocator submitButton = pjq("input[id$=submitButton]");
private JQueryLocator output = pjq("span[id$=out]");
-
private JQueryLocator log = pjq("div.rf-log");
private JQueryLocator levelSelect = pjq("div.rf-log select");
private JQueryLocator logMsg = pjq("div.rf-log div.rf-log-contents div");
@@ -113,6 +113,11 @@
}
@Test
+ public void testDebugFilterNull() {
+ testLogging(LogLevel.DEBUG, LogLevel.NULL);
+ }
+
+ @Test
public void testDebugFilterDebug() {
testLogging(LogLevel.DEBUG, LogLevel.DEBUG);
}
@@ -133,6 +138,11 @@
}
@Test
+ public void testInfoFilterNull() {
+ testLogging(LogLevel.INFO, LogLevel.NULL);
+ }
+
+ @Test
public void testInfoFilterDebug() {
testLogging(LogLevel.INFO, LogLevel.DEBUG);
}
@@ -153,6 +163,11 @@
}
@Test
+ public void testWarnFilterNull() {
+ testLogging(LogLevel.WARN, LogLevel.NULL);
+ }
+
+ @Test
public void testWarnFilterDebug() {
testLogging(LogLevel.WARN, LogLevel.DEBUG);
}
@@ -173,6 +188,11 @@
}
@Test
+ public void testErrorFilterNull() {
+ testLogging(LogLevel.ERROR, LogLevel.NULL);
+ }
+
+ @Test
public void testErrorFilterDebug() {
testLogging(LogLevel.ERROR, LogLevel.DEBUG);
}
@@ -194,29 +214,32 @@
private void testLogging(LogLevel logLevel, LogLevel filterLevel) {
JQueryLocator logButton = pjq("input[id$=" +
logLevel.toString().toLowerCase() + "Button]");
- JQueryLocator levelInput = pjq("input[type=radio][value=" +
filterLevel.toString().toLowerCase() + "]");
JQueryLocator msgType = logMsg.getChild(jq("span.rf-log-entry-lbl"));
JQueryLocator msgContent =
logMsg.getChild(jq("span.rf-log-entry-msg"));
if (filterLevel != LogLevel.DEBUG) {
- selenium.click(levelInput);
- selenium.waitForPageToLoad(TIMEOUT);
+ selenium.select(pjq("select[name$=levelInput]"),
optionLabel(filterLevel.toString().toLowerCase()));
+ selenium.waitForPageToLoad();
}
-
+
String selectedLevel = selenium.getSelectedLabel(levelSelect);
- assertEquals(selectedLevel, filterLevel.toString().toLowerCase(), "Log level
in select wasn't changed.");
+ if (filterLevel == LogLevel.NULL) {
+ assertEquals(selectedLevel, "info", "Log level in select
wasn't changed.");
+ } else {
+ 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.");
+ "There should be only one message in log.");
if (count == 0) {
return;
}
-
+
String loggedValue = selenium.getText(msgType).replaceAll("
*\\[.*\\]:$", "");
assertEquals(loggedValue, logLevel.toString().toLowerCase(), "Message type
in log.");
loggedValue = selenium.getText(msgContent);