Author: ppitonak(a)redhat.com
Date: 2010-07-12 09:44:49 -0400 (Mon, 12 Jul 2010)
New Revision: 17953
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/A4JActionListenerTestCase.java
Log:
* test for invoking listener by type refactored
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/A4JActionListenerTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/A4JActionListenerTestCase.java 2010-07-12
13:15:29 UTC (rev 17952)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/A4JActionListenerTestCase.java 2010-07-12
13:44:49 UTC (rev 17953)
@@ -19,9 +19,9 @@
* 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 org.jboss.test.selenium.encapsulated.JavaScript;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
@@ -30,6 +30,8 @@
import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.waiting.ajax.JavaScriptCondition;
+import org.jboss.test.selenium.waiting.selenium.SeleniumCondition;
import org.richfaces.tests.metamer.ftest.AbstractTestappTestCase;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
@@ -63,11 +65,11 @@
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";
+ +
"org.richfaces.tests.metamer.bean.A4JActionListenerBean$ActionListenerImpl";
selenium.click(invokeButtonType);
waitGui.until(elementPresent.locator(message));
- String output1 = selenium.getText(message);
+ final String output1 = selenium.getText(message);
assertEquals(output1.replaceAll(hashCodeRegExp, ""), msg, "Message
after first invocation of listener by type.");
@@ -77,15 +79,14 @@
// 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");
+ waitModel.failWith("New object of class ActionListenerImpl should be
instantiated.").until(
+ new SeleniumCondition() {
- // 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.");
+ public boolean isTrue() {
+ return !output1.equals(selenium.getText(message));
+ }
+ });
count = selenium.getCount(message);
assertEquals(count, 1, "Only one message should be displayed on the
page.");