Author: lfryc(a)redhat.com
Date: 2009-12-15 06:43:14 -0500 (Tue, 15 Dec 2009)
New Revision: 16136
Modified:
branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/RichfacesSelenium.java
Log:
* GENERAL
- refactored RichfacesSelenium to be straightway
- added toString to AjaxCommand to print out commandName and args when failure
Modified:
branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/RichfacesSelenium.java
===================================================================
---
branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/RichfacesSelenium.java 2009-12-15
11:16:00 UTC (rev 16135)
+++
branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/RichfacesSelenium.java 2009-12-15
11:43:14 UTC (rev 16136)
@@ -2,6 +2,7 @@
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.builder.ToStringBuilder;
import org.jboss.test.selenium.waiting.Retrieve;
import org.jboss.test.selenium.waiting.Wait;
@@ -28,7 +29,7 @@
super(serverHost, serverPort, browserStartCommand, browserURL);
}
- private abstract class Command<T> {
+ private abstract class AjaxCommand<T> {
public abstract T command();
}
@@ -36,31 +37,32 @@
"ERROR: Threw an exception: Error executing strategy function jquery: Permission
denied",
"ERROR: Threw an exception: Permission denied",
"ERROR: Threw an exception: Object doesn't support this property or
method",
- "ERROR: Command execution failure. Please search the forum at
http://clearspace.openqa.org for error details from the log window. The error message is:
Permission denied"};
+ "ERROR: Command execution failure. Please search the forum at
http://clearspace.openqa.org for error details from the log window. The error message is:
Permission denied" };
- private <T> T doAjax(final Command<T> command) {
+ private <T> T doAjax(final AjaxCommand<T> ajaxCommand) {
final AssertionError fail = new AssertionError("Fails with Permission denied when
trying to execute jQuery");
-
+
final T start = null;
return
Wait.timeout(Wait.DEFAULT_TIMEOUT).interval(1000).failWith(fail).waitForChangeAndReturn(start,
new Retrieve<T>() {
boolean exceptionLogged = false;
-
+
public T retrieve() {
try {
- return command.command();
+ return ajaxCommand.command();
} catch (SeleniumException e) {
final String message = StringUtils.defaultString(e.getMessage());
if (ArrayUtils.contains(PERMISSION_DENIED, message)) {
+ System.err.println(message);
if (!exceptionLogged) {
exceptionLogged = true;
+ System.err.println(ajaxCommand);
e.printStackTrace();
} else {
- System.err.println(message);
}
return null;
}
-
+
throw e;
}
}
@@ -69,11 +71,16 @@
@Override
public String doCommand(final String commandName, final String[] args) {
- return doAjax(new Command<String>() {
+ return doAjax(new AjaxCommand<String>() {
@Override
public String command() {
return RichfacesCommandProcessor.super.doCommand(commandName, args);
}
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("commandName",
commandName).append("args", args).toString();
+ }
});
}
}