You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by as...@apache.org on 2019/03/27 23:44:11 UTC
[portals-pluto] 02/05: PLUTO-760 Disable unnecessary HtmlUnit
logging and exceptions
This is an automated email from the ASF dual-hosted git repository.
asfgriff pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/portals-pluto.git
commit 5c88b4642c1036074f9c0628efd641da89e56c66
Author: Kyle Stiemann <st...@gmail.com>
AuthorDate: Thu Nov 15 12:16:00 2018 -0500
PLUTO-760 Disable unnecessary HtmlUnit logging and exceptions
---
.../pluto/test/utilities/SimpleTestDriver.java | 24 +++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/test-base/src/main/java/org/apache/portals/pluto/test/utilities/SimpleTestDriver.java b/test-base/src/main/java/org/apache/portals/pluto/test/utilities/SimpleTestDriver.java
index 9c45e49..b52b73f 100644
--- a/test-base/src/main/java/org/apache/portals/pluto/test/utilities/SimpleTestDriver.java
+++ b/test-base/src/main/java/org/apache/portals/pluto/test/utilities/SimpleTestDriver.java
@@ -17,7 +17,13 @@
*/
package org.apache.portals.pluto.test.utilities;
+import com.gargoylesoftware.htmlunit.SilentCssErrorHandler;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.WebClientOptions;
import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.commons.logging.LogFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -34,6 +40,7 @@ import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.safari.SafariDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
+import sun.util.logging.resources.logging;
/**
@@ -159,7 +166,22 @@ public class SimpleTestDriver {
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, binary);
driver = new PhantomJSDriver(capabilities);
} else if (browser.equalsIgnoreCase("htmlUnit")) {
- driver = new HtmlUnitDriver();
+ LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log",
+ "org.apache.commons.logging.impl.NoOpLog");
+ Logger.getLogger("com.gargoylesoftware").setLevel(Level.SEVERE);
+ Logger.getLogger("org.apache.commons.httpclient").setLevel(Level.SEVERE);
+ driver = new HtmlUnitDriver() {
+ @Override
+ protected WebClient getWebClient() {
+ WebClient webClient = super.getWebClient();
+ WebClientOptions options = webClient.getOptions();
+ options.setThrowExceptionOnFailingStatusCode(false);
+ options.setThrowExceptionOnScriptError(false);
+ options.setPrintContentOnFailingStatusCode(false);
+ webClient.setCssErrorHandler(new SilentCssErrorHandler());
+ return webClient;
+ }
+ };
} else if (browser.equalsIgnoreCase("safari")) {
driver = new SafariDriver();
} else {