Author: jjamrich
Date: 2011-09-23 09:28:32 -0400 (Fri, 23 Sep 2011)
New Revision: 22748
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/MessageAttributes.java
Removed:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/RichMessageAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/RichMessageComponentAttributes.java
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/AbstractRichMessageTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/RichMessageTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessages/RichMessagesTest.java
Log:
RFPL-1439: Update tests for rich:message and messages to use unified way to setting
attributes
Plus introduced fix for @for, which is reserver java word, so not allowed to be used as
enum item
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java 2011-09-23
13:27:58 UTC (rev 22747)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/AttributeList.java 2011-09-23
13:28:32 UTC (rev 22748)
@@ -24,6 +24,7 @@
import org.richfaces.tests.metamer.ftest.richGraphValidator.GraphValidatorAttributes;
import org.richfaces.tests.metamer.ftest.richJQuery.RichJQueryAttributes;
import org.richfaces.tests.metamer.ftest.richList.ListAttributes;
+import org.richfaces.tests.metamer.ftest.richMessage.MessageAttributes;
import org.richfaces.tests.metamer.ftest.richTooltip.TooltipAttributes;
public class AttributeList {
@@ -51,5 +52,6 @@
public static Attributes<GraphValidatorAttributes> graphValidatorAttributes =
new Attributes<GraphValidatorAttributes>();
public static Attributes<RichJQueryAttributes> jQueryAttributes = new
Attributes<RichJQueryAttributes>();
public static Attributes<ListAttributes> listAttributes = new
Attributes<ListAttributes>();
+ public static Attributes<MessageAttributes> messageAttributes = new
Attributes<MessageAttributes>();
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java 2011-09-23
13:27:58 UTC (rev 22747)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/attributes/Attributes.java 2011-09-23
13:28:32 UTC (rev 22748)
@@ -55,6 +55,17 @@
setProperty(attribute.toString(), string);
}
+ /**
+ * Setter for special cases. For example, 'for' is reserved java word, but
valid richfaces attribute as well.
+ * So we use this attribute name in upper case in enum, and then set by special
method to avoid overload by
+ * toLowerCase-in over the whole world of richfaces attributes
+ * @param attribute
+ * @param string
+ */
+ public void setLower(T attribute, String string) {
+ setProperty(attribute.toString().toLowerCase(), string);
+ }
+
// TODO jjamrich 2011-09-02: make sure that this resolve to correct string
representation of number given as attr
public void set(T attribute, Number no) {
setProperty(attribute.toString(), no);
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/AbstractRichMessageTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/AbstractRichMessageTest.java 2011-09-23
13:27:58 UTC (rev 22747)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/AbstractRichMessageTest.java 2011-09-23
13:28:32 UTC (rev 22748)
@@ -24,6 +24,15 @@
import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardHttp;
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
import static
org.richfaces.tests.metamer.ftest.attributes.AttributeList.basicAttributes;
+import static
org.richfaces.tests.metamer.ftest.attributes.AttributeList.messageAttributes;
+import static
org.richfaces.tests.metamer.ftest.richMessage.MessageAttributes.ajaxRendered;
+import static org.richfaces.tests.metamer.ftest.richMessage.MessageAttributes.dir;
+import static org.richfaces.tests.metamer.ftest.richMessage.MessageAttributes.lang;
+import static org.richfaces.tests.metamer.ftest.richMessage.MessageAttributes.rendered;
+import static
org.richfaces.tests.metamer.ftest.richMessage.MessageAttributes.showDetail;
+import static
org.richfaces.tests.metamer.ftest.richMessage.MessageAttributes.showSummary;
+import static org.richfaces.tests.metamer.ftest.richMessage.MessageAttributes.style;
+import static org.richfaces.tests.metamer.ftest.richMessage.MessageAttributes.title;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
@@ -54,7 +63,6 @@
private static Logger logger =
LoggerFactory.getLogger(AbstractRichMessageTest.class);
- protected RichMessageComponentAttributes attributes = new
RichMessageComponentAttributes();
// controls
protected JQueryLocator wrongValuesBtn =
pjq("input[type=button][id$=setWrongValuesButton]");
protected JQueryLocator correctValuesBtn =
pjq("input[type=button][id$=setCorrectValuesButton]");
@@ -80,17 +88,12 @@
public abstract JQueryLocator getDetailElemLocator();
- public void testHtmlAttribute(ElementLocator<?> element, RichMessageAttributes
attribute, String value) {
+ public void testHtmlAttribute(ElementLocator<?> element, MessageAttributes
attribute, String value) {
AttributeLocator<?> attr = element.getAttribute(new
Attribute(attribute.toString()));
- selenium.type(pjq("input[id$=" + attribute + "Input]"),
value);
- if (logger.isDebugEnabled()) {
- logger.debug(" ######## attribute = " + attribute);
- }
-
- selenium.waitForPageToLoad();
-
+ messageAttributes.set(attribute, value);
+
// generate validation message
generateValidationMessages(false);
@@ -167,10 +170,10 @@
}
}
- protected void waitForAttribute(RichMessageAttributes attr) {
+ protected void waitForAttribute(MessageAttributes attr) {
waitGui.until(attributeEquals.locator(
getTestElemLocator().getAttribute(new Attribute(attr.toString())))
- .text(attr.toString()));
+ .text(attr.toString()));
}
// ==================== test methods ====================
@@ -186,7 +189,7 @@
waitGui.until(elementPresent.locator(getTestElemLocator()));
// then disable ajaxRendered
- attributes.setAjaxRendered(Boolean.FALSE);
+ messageAttributes.set(ajaxRendered, Boolean.FALSE);
generateValidationMessages(true);
waitGui.until(isNotDisplayed.locator(getTestElemLocator()));
}
@@ -197,12 +200,12 @@
public void testRendered() {
// with set to false, element with id$=simpleInputMsg shouldn't appear
- attributes.setRendered(Boolean.TRUE);
+ messageAttributes.set(rendered, Boolean.TRUE);
generateValidationMessages(false);
waitGui.until(elementPresent.locator(getTestElemLocator()));
// now disable rendering message
- attributes.setRendered(Boolean.FALSE);
+ messageAttributes.set(rendered, Boolean.FALSE);
generateValidationMessages(false);
waitGui.until(isNotDisplayed.locator(getTestElemLocator()));
}
@@ -213,11 +216,11 @@
public void testShowSummary() {
// span with class=rf-msg-sum should appear when set to true
- attributes.setShowSummary(Boolean.TRUE);
+ messageAttributes.set(showSummary, Boolean.TRUE);
generateValidationMessages(false);
waitModel.until(elementPresent.locator(getSummaryElemLocator()));
- attributes.setShowSummary(Boolean.FALSE);
+ messageAttributes.set(showSummary, Boolean.FALSE);
generateValidationMessages(false);
waitGui.until(isNotDisplayed.locator(getSummaryElemLocator()));
}
@@ -228,29 +231,30 @@
public void testShowDetail() {
// span with class=rf-msg-det should appear when set to true
- attributes.setShowDetail(Boolean.TRUE);
+ messageAttributes.set(showDetail, Boolean.TRUE);
generateValidationMessages(false);
waitGui.until(elementPresent.locator(getDetailElemLocator()));
- attributes.setShowDetail(Boolean.FALSE);
+ messageAttributes.set(showDetail, Boolean.FALSE);
generateValidationMessages(false);
waitGui.until(isNotDisplayed.locator(getDetailElemLocator()));
}
public void testTitle() {
- testHtmlAttribute(getTestElemLocator(), RichMessageAttributes.TITLE, "Title
test");
+ testHtmlAttribute(getTestElemLocator(), title, "Title test");
}
public void testDir() {
- testHtmlAttribute(getTestElemLocator(), RichMessageAttributes.DIR,
"rtl");
+ testHtmlAttribute(getTestElemLocator(), dir, "rtl");
}
public void testLang() {
- testHtmlAttribute(getTestElemLocator(), RichMessageAttributes.LANG,
"US.en");
+ testHtmlAttribute(getTestElemLocator(), lang, "US.en");
}
public void testStyle() {
- testHtmlAttribute(getTestElemLocator(), RichMessageAttributes.STYLE, "color:
blue;");
+ // this style test is different from other tests: need generate message before
testing
+ testHtmlAttribute(getTestElemLocator(), style, "color: blue;");
}
public void testStyleClass() {
Copied:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/MessageAttributes.java
(from rev 22747,
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/RichMessageAttributes.java)
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/MessageAttributes.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/MessageAttributes.java 2011-09-23
13:28:32 UTC (rev 22748)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * 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.
+ *
+ * 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.richMessage;
+
+import org.richfaces.tests.metamer.ftest.attributes.AttributeEnum;
+
+/**
+ * Component attributes for rich:message
+ *
+ * @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
+ * @version $Revision$
+ */
+public enum MessageAttributes implements AttributeEnum {
+
+ ajaxRendered,
+ dir,
+ FOR,
+ globalOnly,
+ lang,
+ rendered,
+ showDetail,
+ showSummary,
+ style,
+ title,
+
+}
Deleted:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/RichMessageAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/RichMessageAttributes.java 2011-09-23
13:27:58 UTC (rev 22747)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/RichMessageAttributes.java 2011-09-23
13:28:32 UTC (rev 22748)
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * JBoss, Home of Professional Open Source
- * 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.
- *
- * 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.richMessage;
-
-/**
- * This should be enum for all know attributes.
- * Need to implement an "retriever" method to get
- * values from key such as "class" by "_class" key
- *
- * @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
- * @version $Revision$
- */
-public enum RichMessageAttributes {
-
- AJAX_RENDERED("ajaxRendered"),
- RENDERED("rendered"),
- DIR("dir"),
- FOR("for"),
- LANG("lang"),
- TITLE("title"),
- CLASS("class"),
- STYLE("style"),
- STYLE_CLASS("styleClass");
- private String value;
-
- RichMessageAttributes(String val) {
- this.value = val;
- }
-
- @Override
- public String toString() {
- return value;
- }
-}
Deleted:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/RichMessageComponentAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/RichMessageComponentAttributes.java 2011-09-23
13:27:58 UTC (rev 22747)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/RichMessageComponentAttributes.java 2011-09-23
13:28:32 UTC (rev 22748)
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * JBoss, Home of Professional Open Source
- * 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.
- *
- * 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.richMessage;
-
-import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
-
-/**
- * Component attributes for rich:message
- *
- * @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
- * @version $Revision$
- */
-public class RichMessageComponentAttributes extends AbstractComponentAttributes {
-
- public void setRendered(Boolean rendered) {
- setProperty("rendered", rendered);
- }
-
- public void setAjaxRendered(Boolean rendered) {
- setProperty("ajaxRendered", rendered);
- }
-
- public void setShowDetail(Boolean showDetail) {
- setProperty("showDetail", showDetail);
- }
-
- public void setShowSummary(Boolean showSummary) {
- setProperty("showSummary", showSummary);
- }
-
- public void setFor(String forAttribute) {
- setProperty("for", forAttribute);
- }
-
- public void setGlobalOnly(Boolean globalOnly) {
- setProperty("globalOnly", globalOnly);
- }
-}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/RichMessageTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/RichMessageTest.java 2011-09-23
13:27:58 UTC (rev 22747)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessage/RichMessageTest.java 2011-09-23
13:28:32 UTC (rev 22748)
@@ -22,6 +22,8 @@
package org.richfaces.tests.metamer.ftest.richMessage;
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static
org.richfaces.tests.metamer.ftest.attributes.AttributeList.messageAttributes;
+import static org.richfaces.tests.metamer.ftest.richMessage.MessageAttributes.FOR;
import org.jboss.test.selenium.locator.JQueryLocator;
@@ -45,14 +47,14 @@
public void testFor() {
// firstly, remove value from attribute for and generate message
- attributes.setFor("");
+ messageAttributes.setLower(FOR, "");
generateValidationMessages(false);
// assertFalse(selenium.isElementPresent(getTestElemLocator()));
waitGui.until(isNotDisplayed.locator(getTestElemLocator()));
// now set for attribute back to "simpleInput2"
- attributes.setFor("simpleInput2");
+ messageAttributes.setLower(FOR, "simpleInput2");
generateValidationMessages(false);
waitGui.until(elementPresent.locator(getTestElemLocator()));
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessages/RichMessagesTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessages/RichMessagesTest.java 2011-09-23
13:27:58 UTC (rev 22747)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richMessages/RichMessagesTest.java 2011-09-23
13:28:32 UTC (rev 22748)
@@ -22,6 +22,9 @@
package org.richfaces.tests.metamer.ftest.richMessages;
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static
org.richfaces.tests.metamer.ftest.attributes.AttributeList.messageAttributes;
+import static org.richfaces.tests.metamer.ftest.richMessage.MessageAttributes.FOR;
+import static
org.richfaces.tests.metamer.ftest.richMessage.MessageAttributes.globalOnly;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.richMessage.AbstractRichMessageTest;
@@ -66,7 +69,7 @@
public void testFor() {
// firstly reset to null
- attributes.setFor("");
+ messageAttributes.setLower(FOR, "");
// generate faces message by btn
selenium.click(generateMsgsBtn);
@@ -75,7 +78,7 @@
waitGui.until(countEquals.count(0).locator(getTestElemLocator().getChild(jq("span[id$=msgs1:form:simpleInput1]"))));
waitGui.until(countEquals.count(0).locator(getTestElemLocator().getChild(jq("span[id$=msgs1:form:simpleInput2]"))));
- attributes.setFor("simpleInput1");
+ messageAttributes.setLower(FOR, "simpleInput1");
// generate faces messages by btn
selenium.click(generateMsgsBtn);
// only messages for simpleInput1 should appear:
@@ -85,7 +88,7 @@
// one type warning
waitModel.until(countEquals.count(1).locator(getWarnMsg()));
- attributes.setFor("simpleInput2");
+ messageAttributes.setLower(FOR, "simpleInput2");
// generate faces messages by btn
selenium.click(generateMsgsBtn);
// only 2 messages for simpleInput2
@@ -107,10 +110,10 @@
*/
public void testGlobalOnly() {
// firstly set for attribute to null
- attributes.setFor("");
+ messageAttributes.setLower(FOR, "");
// then set globalOnly attribute
- attributes.setGlobalOnly(Boolean.FALSE);
+ messageAttributes.set(globalOnly, Boolean.FALSE);
selenium.click(generateMsgsBtn);