tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject [1/3] git commit: Use SLF4J Logging
Date Mon, 04 Nov 2013 19:49:08 GMT
Updated Branches:
  refs/heads/master c685a96e1 -> bec5a5c77


Use SLF4J Logging


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/864623aa
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/864623aa
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/864623aa

Branch: refs/heads/master
Commit: 864623aa8db942c99bcd3e256b3685a08d87fd71
Parents: c685a96
Author: Howard M. Lewis Ship <hlship@apache.org>
Authored: Mon Nov 4 10:55:50 2013 -0800
Committer: Howard M. Lewis Ship <hlship@apache.org>
Committed: Mon Nov 4 10:55:50 2013 -0800

----------------------------------------------------------------------
 .../apache/tapestry5/test/SeleniumTestCase.java | 73 ++++++++++++++------
 1 file changed, 51 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/864623aa/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
----------------------------------------------------------------------
diff --git a/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java b/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
index c2b6232..6233879 100644
--- a/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
+++ b/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
@@ -20,6 +20,8 @@ import com.thoughtworks.selenium.HttpCommandProcessor;
 import com.thoughtworks.selenium.Selenium;
 import org.openqa.selenium.server.RemoteControlConfiguration;
 import org.openqa.selenium.server.SeleniumServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.testng.Assert;
 import org.testng.ITestContext;
 import org.testng.annotations.*;
@@ -37,6 +39,8 @@ import java.lang.reflect.Method;
  */
 public abstract class SeleniumTestCase extends Assert implements Selenium
 {
+    public final Logger LOGGER = LoggerFactory.getLogger(SeleniumTestCase.class);
+
     /**
      * 15 seconds
      */
@@ -175,14 +179,16 @@ public abstract class SeleniumTestCase extends Assert implements Selenium
 
         String baseURL = String.format("http://localhost:%d%s/", port, contextPath);
 
-        System.err.println("Starting SeleniumTestCase:");
-        System.err.println("    currentDir: " + System.getProperty("user.dir"));
-        System.err.println("  webAppFolder: " + webAppFolder);
-        System.err.println("     container: " + container);
-        System.err.println("   contextPath: " + contextPath);
-        System.err.printf("         ports: %d / %d%n", port, sslPort);
-        System.err.println("  browserStart: " + browserStartCommand);
-        System.err.println("       baseURL: " + baseURL);
+        String sep = System.getProperty("line.separator");
+
+        LOGGER.info("Starting SeleniumTestCase:" + sep +
+                "    currentDir: " + System.getProperty("user.dir") + sep +
+                "  webAppFolder: " + webAppFolder + sep +
+                "     container: " + container + sep +
+                "   contextPath: " + contextPath + sep +
+                String.format("         ports: %d / %d", port, sslPort) + sep +
+                "  browserStart: " + browserStartCommand + sep +
+                "       baseURL: " + baseURL);
 
         final Runnable stopWebServer = launchWebServer(container, webAppFolder, contextPath,
port, sslPort);
 
@@ -221,17 +227,35 @@ public abstract class SeleniumTestCase extends Assert implements Selenium
             {
                 try
                 {
-                    System.err.println("Shutting down selenium client ...");
-
-                    selenium.stop();
-
-                    System.err.println("Shutting down selenium server ...");
-
-                    seleniumServer.stop();
-
-                    System.err.println("Shutting web server ...");
-
-                    stopWebServer.run();
+                    LOGGER.info("Shutting down selenium client ...");
+
+                    try
+                    {
+                        selenium.stop();
+                    } catch (RuntimeException e)
+                    {
+                        LOGGER.error("Selenium client shutdown failure.", e);
+                    }
+
+                    LOGGER.info("Shutting down selenium server ...");
+
+                    try
+                    {
+                        seleniumServer.stop();
+                    } catch (RuntimeException e)
+                    {
+                        LOGGER.error("Selenium server shutdown failure.", e);
+                    }
+
+                    LOGGER.info("Shutting web server ...");
+
+                    try
+                    {
+                        stopWebServer.run();
+                    } catch (RuntimeException e)
+                    {
+                        LOGGER.error("Web server shutdown failure.", e);
+                    }
 
                     // Output, at the end of the Test, any html capture or screen shots (this
makes it much easier
                     // to locate them at the end of the run; there's such a variance on where
they end up based
@@ -1158,18 +1182,23 @@ public abstract class SeleniumTestCase extends Assert implements Selenium
         // that does not include the body element and data-page-initialized element. In those
cases,
         // there will never be page initialization in the Tapestry sense and we return immediately.
 
-        if (!isElementPresent("css=body[data-page-initialized]")) { return; }
+        if (!isElementPresent("css=body[data-page-initialized]"))
+        {
+            return;
+        }
 
         int totalTime = 0;
         int sleepTime = 20;
 
-        while (true) {
+        while (true)
+        {
             if (isElementPresent("css=body[data-page-initialized='true']"))
             {
                 return;
             }
 
-            if (totalTime > 10000) {
+            if (totalTime > 10000)
+            {
                 reportAndThrowAssertionError("Page did not finish initializing.");
             }
 


Mime
View raw message