Closed
Description
Description
As part of the HtmlUnit (https://github.com/HtmlUnit/htmlunit) project i have a lot of test cases doing detailed and sometimes strange things to test some functionality.
In this special case i temporary add an appender to check if something happen on the wire.
The code looks like this:
final Logger logger = (Logger) LogManager.getLogger("org.apache.http.headers");
final Level oldLevel = logger.getLevel();
Configurator.setLevel(logger.getName(), Level.DEBUG);
final StringWriter stringWriter = new StringWriter();
final PatternLayout layout = PatternLayout.newBuilder().withPattern("%msg%n").build();
final WriterAppender writerAppender = WriterAppender.newBuilder().setName("writeLogger").setTarget(stringWriter)
.setLayout(layout).build();
writerAppender.start();
logger.addAppender(writerAppender);
try {
((DefaultCredentialsProvider) getWebClient().getCredentialsProvider())
.addCredentials("jetty", "jetty".toCharArray());
loadPage("Hi There");
int unauthorizedCount = StringUtils.countMatches(stringWriter.toString(), "HTTP/1.1 401");
assertEquals(1, unauthorizedCount);
}
finally {
logger.removeAppender(writerAppender);
Configurator.setLevel(logger.getName(), oldLevel);
}
This works fine in 2.20.0 and the years before but now with 2.21.0 i fails because there is not output at all - stringWriter.toString() returns an empty string.
Any idea?
Will try to help as much as possible, doing debugging or what else needed to get this working again with the new versions.
Thanks for the great libaray
Ronald
Configuration
Version: 2.21.0
Operating system: Win
JDK: JDK 11