Author: lfryc(a)redhat.com
Date: 2009-09-02 03:11:11 -0400 (Wed, 02 Sep 2009)
New Revision: 15431
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/jsFunction/JSFunctionTestCase.java
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/jsFunction/locators.properties
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/jsFunction/messages.properties
Log:
- refactored JS Function test cases to follow conventions
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/jsFunction/JSFunctionTestCase.java
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/jsFunction/JSFunctionTestCase.java 2009-09-02
06:55:53 UTC (rev 15430)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/java/org/jboss/richfaces/integrationTest/jsFunction/JSFunctionTestCase.java 2009-09-02
07:11:11 UTC (rev 15431)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces
+ *
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This code is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This code 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 test suite; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.jboss.richfaces.integrationTest.jsFunction;
import org.apache.commons.lang.StringUtils;
@@ -4,7 +24,9 @@
import org.jboss.richfaces.integrationTest.AbstractSeleniumRichfacesTestCase;
import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.waiting.Condition;
-import org.testng.Assert;
+import static org.testng.Assert.*;
+
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
@@ -12,41 +34,45 @@
* @version $Revision$
*/
public class JSFunctionTestCase extends AbstractSeleniumRichfacesTestCase {
+ private final String LOC_SPAN_HOVER_ACTIVATED =
getLoc("SPAN_HOVER_ACTIVATED");
+ private final String LOC_OUTPUT_NAME = getLoc("OUTPUT_NAME");
+
+ private final String[] MSG_NAMES = StringUtils.split(getMsg("NAMES"),
',');
+
/**
- * Opens specified page
+ * Hovers over all of the hover activated spans and waits for output name
+ * changed right followed by hovering out and waiting for output will be
+ * blank.
*/
- private void openPage() {
- selenium.open(contextPath
- + "/richfaces/jsFunction.jsf?c=jsFunction&tab=usage");
- }
-
@Test
- public void hoveringNames() {
- openPage();
-
- final String showName = getLoc("js-function--show-name");
- String[] names = new String[] {getMess("js-function--name1"),
getMess("js-function--name2"), getMess("js-function--name3")};
+ public void testHoveringNames() {
+ for (final String msgName : MSG_NAMES) {
+ final String span = format(LOC_SPAN_HOVER_ACTIVATED, msgName);
- for (final String name : names) {
- String span = formatLoc("js-function--active-span", name);
+ assertTrue(StringUtils.isBlank(selenium.getText(LOC_OUTPUT_NAME)), "Output name
should be blank");
- Assert.assertTrue(StringUtils.isBlank(selenium.getText(showName)));
-
selenium.fireEvent(span, Event.MOUSEOVER);
- waitModelUpdate.until(new Condition() {
+ waitModelUpdate.failWith(format("Output name never changed to
'{0}'", msgName)).until(new Condition() {
public boolean isTrue() {
- return name.equals(selenium.getText(showName));
+ return msgName.equals(selenium.getText(LOC_OUTPUT_NAME));
}
});
-
+
selenium.fireEvent(span, Event.MOUSEOUT);
-
- waitModelUpdate.until(new Condition() {
+
+ waitModelUpdate.failWith("Output name never changed to blank").until(new
Condition() {
public boolean isTrue() {
- return StringUtils.isBlank(selenium.getText(showName));
+ return StringUtils.isBlank(selenium.getText(LOC_OUTPUT_NAME));
}
});
}
}
+
+ @SuppressWarnings("unused")
+ @BeforeMethod
+ private void loadPage() {
+ openComponent("JS Function");
+
+ }
}
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/jsFunction/locators.properties
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/jsFunction/locators.properties 2009-09-02
06:55:53 UTC (rev 15430)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/jsFunction/locators.properties 2009-09-02
07:11:11 UTC (rev 15431)
@@ -1,2 +1,2 @@
-js-function--active-span=//fieldset[1]/div[1]/table[1]//span[text()\='{0}']
-js-function--show-name=//*[@id\='showname']
+SPAN_HOVER_ACTIVATED=//fieldset[1]/div[1]/table[1]//span[text()\='{0}']
+OUTPUT_NAME=//*[@id\='showname']
Modified:
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/jsFunction/messages.properties
===================================================================
---
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/jsFunction/messages.properties 2009-09-02
06:55:53 UTC (rev 15430)
+++
branches/community/3.3.X/samples/richfaces-demo/functional-test/src/test/resources/org/jboss/richfaces/integrationTest/jsFunction/messages.properties 2009-09-02
07:11:11 UTC (rev 15431)
@@ -1,3 +1 @@
-js-function--name1=Kate
-js-function--name2=John
-js-function--name3=Alex
+NAMES=Kate,John,Alex
Show replies by date