Skip to content

Commit

Permalink
Disable logging for org.htmlunit.css
Browse files Browse the repository at this point in the history
Removes 1000+ CSSValue warning, SilentCssErrorHandler doesn't cover this case
https://github.com/HtmlUnit/htmlunit/blob/4.7.0/src/main/java/org/htmlunit/css/CssStyleSheet.java#L1427
  • Loading branch information
rsvoboda authored and mjurc committed Jan 6, 2025
1 parent afa830c commit d6f8925
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.http.HttpStatus;
import org.htmlunit.FailingHttpStatusCodeException;
Expand Down Expand Up @@ -34,6 +36,7 @@ public abstract class BaseOidcJwtSecurityIT {
public void setup() {
webClient = new WebClient();
webClient.setCssErrorHandler(new SilentCssErrorHandler());
Logger.getLogger("org.htmlunit.css").setLevel(Level.OFF);
webClient.getOptions().setRedirectEnabled(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import java.net.URI;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.http.HttpStatus;
import org.htmlunit.SilentCssErrorHandler;
Expand Down Expand Up @@ -37,6 +39,7 @@ public abstract class BaseMultiTenantSecurityIT {
public void setup() {
webClient = new WebClient();
webClient.setCssErrorHandler(new SilentCssErrorHandler());
Logger.getLogger("org.htmlunit.css").setLevel(Level.OFF);
webClient.getOptions().setRedirectEnabled(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.htmlunit.SilentCssErrorHandler;
import org.htmlunit.WebClient;
Expand Down Expand Up @@ -41,7 +43,6 @@ public class LogoutSinglePageAppFlowIT {
@Test
public void singlePageAppLogoutFlow() throws IOException {
try (final WebClient webClient = createWebClient()) {
webClient.getOptions().setRedirectEnabled(true);
HtmlPage page = webClient.getPage(app.getURI(Protocol.HTTP).toString() + "/code-flow");

HtmlForm form = page.getHtmlElementById("kc-form-login");
Expand All @@ -64,6 +65,8 @@ public void singlePageAppLogoutFlow() throws IOException {
private WebClient createWebClient() {
WebClient webClient = new WebClient();
webClient.setCssErrorHandler(new SilentCssErrorHandler());
Logger.getLogger("org.htmlunit.css").setLevel(Level.OFF);
webClient.getOptions().setRedirectEnabled(true);
return webClient;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import java.io.IOException;
import java.util.Objects;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.htmlunit.SilentCssErrorHandler;
import org.htmlunit.WebClient;
Expand Down Expand Up @@ -53,7 +55,6 @@ public class LogoutSinglePageAppFlowIT {
@Test
public void singlePageAppLogoutFlow() throws IOException {
try (final WebClient webClient = createWebClient()) {
webClient.getOptions().setRedirectEnabled(true);
String content = makeHttpPostFormLogin(webClient, "/code-flow", "alice", "alice")
.getContentAsString();

Expand Down Expand Up @@ -91,6 +92,8 @@ private WebResponse makeHttpPostFormLogin(WebClient webClient, String loginPath,
private WebClient createWebClient() {
WebClient webClient = new WebClient();
webClient.setCssErrorHandler(new SilentCssErrorHandler());
Logger.getLogger("org.htmlunit.css").setLevel(Level.OFF);
webClient.getOptions().setRedirectEnabled(true);
return webClient;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import java.net.URI;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.http.HttpStatus;
import org.htmlunit.FailingHttpStatusCodeException;
Expand Down Expand Up @@ -41,6 +43,7 @@ public abstract class BaseWebappSecurityIT {
public void setup() {
webClient = new WebClient();
webClient.setCssErrorHandler(new SilentCssErrorHandler());
Logger.getLogger("org.htmlunit.css").setLevel(Level.OFF);
webClient.getOptions().setRedirectEnabled(true);
}

Expand Down

0 comments on commit d6f8925

Please sign in to comment.