Skip to content

Commit

Permalink
test changes related to LOGBACK-1693 LOGBACK-1694
Browse files Browse the repository at this point in the history
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
  • Loading branch information
ceki committed Oct 7, 2022
1 parent 6259aad commit ba5eb23
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 32 deletions.
27 changes: 27 additions & 0 deletions logback-classic-blackbox/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,33 @@
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.eclipse.angus</groupId>
<artifactId>angus-mail</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.icegreen</groupId>
<artifactId>greenmail</artifactId>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<To>nospam@qos.ch</To>
<From>user@host.dom</From>
<Subject>testCustomEvaluator %logger - %m</Subject>
<evaluator class="ch.qos.logback.classic.net.CounterBasedEvaluator">
<evaluator class="ch.qos.logback.classic.blackbox.net.CounterBasedEvaluator">
<limit>2</limit>
</evaluator>
<layout class="ch.qos.logback.classic.PatternLayout">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Logback: the reliable, generic, fast and flexible logging framework.
* Copyright (C) 1999-2015, QOS.ch. All rights reserved.
*
* This program and the accompanying materials are dual-licensed under
* either the terms of the Eclipse Public License v1.0 as published by
* the Eclipse Foundation
*
* or (per the licensee's choosing)
*
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/

package ch.qos.logback.classic.blackbox.html;

import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;

public class XHTMLEntityResolver implements EntityResolver {

// key: public id, value: relative path to DTD file
static Map<String, String> entityMap = new HashMap<String, String>();

static {
entityMap.put("-//W3C//DTD XHTML 1.0 Strict//EN", "/dtd/xhtml1-strict.dtd");
entityMap.put("-//W3C//ENTITIES Latin 1 for XHTML//EN", "/dtd/xhtml-lat1.ent");
entityMap.put("-//W3C//ENTITIES Symbols for XHTML//EN", "/dtd/xhtml-symbol.ent");
entityMap.put("-//W3C//ENTITIES Special for XHTML//EN", "/dtd/xhtml-special.ent");
}

public InputSource resolveEntity(String publicId, String systemId) {
// System.out.println(publicId);
final String relativePath = (String) entityMap.get(publicId);

if (relativePath != null) {
Class<?> clazz = getClass();
InputStream in = clazz.getResourceAsStream(relativePath);
if (in == null) {
return null;
} else {
return new InputSource(in);
}
} else {
return null;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
/*
* Logback: the reliable, generic, fast and flexible logging framework.
* Copyright (C) 1999-2015, QOS.ch. All rights reserved.
* Copyright (C) 1999-2022, QOS.ch. All rights reserved.
*
* This program and the accompanying materials are dual-licensed under
* either the terms of the Eclipse Public License v1.0 as published by
Expand All @@ -11,7 +11,7 @@
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
package ch.qos.logback.classic.net;
package ch.qos.logback.classic.blackbox.net;

import ch.qos.logback.core.boolex.EvaluationException;
import ch.qos.logback.core.boolex.EventEvaluator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
/*
* Logback: the reliable, generic, fast and flexible logging framework.
* Copyright (C) 1999-2015, QOS.ch. All rights reserved.
* Copyright (C) 1999-2022, QOS.ch. All rights reserved.
*
* This program and the accompanying materials are dual-licensed under
* either the terms of the Eclipse Public License v1.0 as published by
Expand All @@ -11,14 +11,16 @@
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
package ch.qos.logback.classic.net;
package ch.qos.logback.classic.blackbox.net;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.TimeUnit;

import ch.qos.logback.classic.blackbox.BlackboxClassicTestConstants;
import ch.qos.logback.classic.net.SMTPAppender;
import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;
import org.junit.jupiter.api.AfterEach;
Expand All @@ -32,12 +34,12 @@
import com.icegreen.greenmail.util.GreenMailUtil;
import com.icegreen.greenmail.util.ServerSetup;

import ch.qos.logback.classic.ClassicTestConstants;
//import ch.qos.logback.classic.ClassicTestConstants;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.PatternLayout;
import ch.qos.logback.classic.html.HTMLLayout;
import ch.qos.logback.classic.html.XHTMLEntityResolver;
import ch.qos.logback.classic.blackbox.html.XHTMLEntityResolver;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.Layout;
Expand Down Expand Up @@ -297,7 +299,7 @@ private void configure(String file) throws JoranException {
@Test
public void testCustomEvaluator() throws Exception {
startSMTPServer(NO_SSL);
configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "smtp/customEvaluator.xml");
configure(BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "smtp/customEvaluator.xml");

logger.debug("test");
String msg2 = "CustomEvaluator";
Expand All @@ -313,7 +315,7 @@ public void testCustomEvaluator() throws Exception {
@Test
public void testCustomBufferSize() throws Exception {
startSMTPServer(NO_SSL);
configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "smtp/customBufferSize.xml");
configure(BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "smtp/customBufferSize.xml");

logger.debug("invisible1");
logger.debug("invisible2");
Expand Down
6 changes: 6 additions & 0 deletions logback-classic-blackbox/src/test/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
requires jakarta.mail;
requires janino;

requires dom4j;
requires greenmail;

requires org.junit.jupiter.api;
requires org.junit.jupiter.engine;
requires org.slf4j;

exports ch.qos.logback.classic.blackbox.boolex;

exports ch.qos.logback.classic.blackbox.joran;
exports ch.qos.logback.classic.blackbox.joran.conditional;
exports ch.qos.logback.classic.blackbox.html;
exports ch.qos.logback.classic.blackbox.net;
}
21 changes: 2 additions & 19 deletions logback-classic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<version>1.2.18.4</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
Expand Down Expand Up @@ -102,6 +103,7 @@
<artifactId>janino</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
Expand All @@ -114,22 +116,6 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.icegreen</groupId>
<artifactId>greenmail</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.main</artifactId>
Expand Down Expand Up @@ -294,9 +280,6 @@
<exclude>org.slf4j.implTest.InitializationOutputTest.java</exclude>
<exclude>ch.qos.logback.classic.util.ContextInitializerTest.java</exclude>
<exclude>ch.qos.logback.classic.spi.InvocationTest.java</exclude>
<!--- temporary -->
<exclude>**/JaninoEventEvaluatorTest.java</exclude>
<exclude>**/ConditionalTest.java</exclude>
</excludes>
</configuration>
</execution>
Expand Down
4 changes: 2 additions & 2 deletions logback-classic/src/test/input/fqcn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ ch.qos.logback.classic.multiJVM.FileAppenderPerf
ch.qos.logback.classic.multiJVM.LoggingThread
ch.qos.logback.classic.multiJVM.SafeModeFileAppender
ch.qos.logback.classic.multiJVM.SafeModeRollingFileAppender
ch.qos.logback.classic.net.CounterBasedEvaluator
ch.qos.logback.classic.blackbox.net.CounterBasedEvaluator
ch.qos.logback.classic.net.DilutedSMTPAppenderTest
ch.qos.logback.classic.net.ExternalMockSocketServer
ch.qos.logback.classic.net.mock.MockAppender
Expand All @@ -387,7 +387,7 @@ ch.qos.logback.classic.net.server.RemoteAppenderStreamClientTest
ch.qos.logback.classic.net.server.ServerSocketReceiverFunctionalTest
ch.qos.logback.classic.net.server.ServerSocketReceiverTest
ch.qos.logback.classic.net.server.SSLServerSocketReceiverTest
ch.qos.logback.classic.net.SMTPAppender_GreenTest
ch.qos.logback.classic.blackbox.net.SMTPAppender_GreenTest
ch.qos.logback.classic.net.SocketAppenderMessageLossTest
ch.qos.logback.classic.net.SocketMin
ch.qos.logback.classic.net.SocketReceiverTest
Expand Down

0 comments on commit ba5eb23

Please sign in to comment.