Author: lfryc(a)redhat.com
Date: 2009-12-15 06:16:00 -0500 (Tue, 15 Dec 2009)
New Revision: 16135
Modified:
branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/AbstractSeleniumRichfacesTestCase.java
branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/RichfacesSelenium.java
Log:
* GENERAL
- seleniumLoggingListener creation and registration moved to @BeforeSuite (object made as
static), referencing selenium in @BeforeClass initializeContext and unreferencing in
@AfterClass finalizeContext
- added logic to Permission Denied treatment - first catch prints stacktrace, each other
only logs exception message
Modified:
branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/AbstractSeleniumRichfacesTestCase.java
===================================================================
---
branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/AbstractSeleniumRichfacesTestCase.java 2009-12-15
10:27:28 UTC (rev 16134)
+++
branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/AbstractSeleniumRichfacesTestCase.java 2009-12-15
11:16:00 UTC (rev 16135)
@@ -39,7 +39,7 @@
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.BeforeTest;
+import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Parameters;
/**
@@ -76,33 +76,23 @@
protected Waiting waitModelUpdate = Wait.interval(100).timeout(30000);
protected Waiting waitGuiInteraction = Wait.interval(100).timeout(500);
- /**
- * Test listener used to logging to selenium's server.log
- * via getEval() method (see {@link SeleniumLoggingTestListener})
- *
- * Don't forget to use SeleniumLoggingTestListener.setSelenium(Selenium)
- * to initialize selenium-side logging properly
- */
- SeleniumLoggingTestListener loggingTestListener;
-
- /**
- * Register test listener in test context
- *
- * @param context
- * will be injected by TestNG
- */
- @BeforeTest
- protected void addTestListeners(ITestContext context) {
- TestRunner runner = (TestRunner) context;
+ /**
+ * Test listener used to logging to selenium's server.log via getEval()
+ * method (see {@link SeleniumLoggingTestListener})
+ *
+ * Don't forget to use SeleniumLoggingTestListener.setSelenium(Selenium) to
+ * initialize selenium-side logging properly
+ */
+ private static volatile SeleniumLoggingTestListener loggingTestListener;
+
+ @BeforeSuite
+ protected void registerSeleniumInListeners(ITestContext context) {
loggingTestListener = new SeleniumLoggingTestListener();
+
+ TestRunner runner = (TestRunner) context;
runner.addTestListener(loggingTestListener);
}
- @BeforeMethod
- protected void registerSeleniumInListeners() {
- loggingTestListener.setSelenium(selenium);
- }
-
/**
* Initializes context before each class run.
*
@@ -134,6 +124,7 @@
selenium.start();
allowInitialXpath();
loadCustomLocationStrategies();
+ loggingTestListener.setSelenium(selenium);
selenium.windowFocus();
selenium.windowMaximize();
@@ -168,6 +159,7 @@
*/
@AfterClass
public void finalizeContext() {
+ loggingTestListener.setSelenium(null);
selenium.close();
selenium.stop();
selenium = null;
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
10:27:28 UTC (rev 16134)
+++
branches/sandbox/rf-demo-ftest-iexplore/src/test/java/org/jboss/richfaces/integrationTest/RichfacesSelenium.java 2009-12-15
11:16:00 UTC (rev 16135)
@@ -44,14 +44,20 @@
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();
} catch (SeleniumException e) {
final String message = StringUtils.defaultString(e.getMessage());
-
if (ArrayUtils.contains(PERMISSION_DENIED, message)) {
- System.err.println(message);
+ if (!exceptionLogged) {
+ exceptionLogged = true;
+ e.printStackTrace();
+ } else {
+ System.err.println(message);
+ }
return null;
}
Show replies by date