Skip to content

Commit ba5eb23

Browse files
committed
test changes related to LOGBACK-1693 LOGBACK-1694
Signed-off-by: Ceki Gulcu <[email protected]>
1 parent 6259aad commit ba5eb23

File tree

9 files changed

+102
-32
lines changed

9 files changed

+102
-32
lines changed

logback-classic-blackbox/pom.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,33 @@
3939
<scope>compile</scope>
4040
</dependency>
4141

42+
<dependency>
43+
<groupId>org.dom4j</groupId>
44+
<artifactId>dom4j</artifactId>
45+
<scope>compile</scope>
46+
</dependency>
47+
48+
<dependency>
49+
<groupId>org.eclipse.angus</groupId>
50+
<artifactId>angus-mail</artifactId>
51+
<scope>test</scope>
52+
</dependency>
53+
54+
<dependency>
55+
<groupId>com.icegreen</groupId>
56+
<artifactId>greenmail</artifactId>
57+
<scope>compile</scope>
58+
<exclusions>
59+
<exclusion>
60+
<groupId>junit</groupId>
61+
<artifactId>junit</artifactId>
62+
</exclusion>
63+
<exclusion>
64+
<groupId>com.sun.mail</groupId>
65+
<artifactId>jakarta.mail</artifactId>
66+
</exclusion>
67+
</exclusions>
68+
</dependency>
4269
</dependencies>
4370

4471
<build>

logback-classic/src/test/input/joran/smtp/customEvaluator.xml renamed to logback-classic-blackbox/src/test/blackboxInput/joran/smtp/customEvaluator.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
<From>[email protected]</From>
88
<Subject>testCustomEvaluator %logger - %m</Subject>
9-
<evaluator class="ch.qos.logback.classic.net.CounterBasedEvaluator">
9+
<evaluator class="ch.qos.logback.classic.blackbox.net.CounterBasedEvaluator">
1010
<limit>2</limit>
1111
</evaluator>
1212
<layout class="ch.qos.logback.classic.PatternLayout">
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* Logback: the reliable, generic, fast and flexible logging framework.
3+
* Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4+
*
5+
* This program and the accompanying materials are dual-licensed under
6+
* either the terms of the Eclipse Public License v1.0 as published by
7+
* the Eclipse Foundation
8+
*
9+
* or (per the licensee's choosing)
10+
*
11+
* under the terms of the GNU Lesser General Public License version 2.1
12+
* as published by the Free Software Foundation.
13+
*/
14+
15+
package ch.qos.logback.classic.blackbox.html;
16+
17+
import java.io.InputStream;
18+
import java.util.HashMap;
19+
import java.util.Map;
20+
21+
import org.xml.sax.EntityResolver;
22+
import org.xml.sax.InputSource;
23+
24+
public class XHTMLEntityResolver implements EntityResolver {
25+
26+
// key: public id, value: relative path to DTD file
27+
static Map<String, String> entityMap = new HashMap<String, String>();
28+
29+
static {
30+
entityMap.put("-//W3C//DTD XHTML 1.0 Strict//EN", "/dtd/xhtml1-strict.dtd");
31+
entityMap.put("-//W3C//ENTITIES Latin 1 for XHTML//EN", "/dtd/xhtml-lat1.ent");
32+
entityMap.put("-//W3C//ENTITIES Symbols for XHTML//EN", "/dtd/xhtml-symbol.ent");
33+
entityMap.put("-//W3C//ENTITIES Special for XHTML//EN", "/dtd/xhtml-special.ent");
34+
}
35+
36+
public InputSource resolveEntity(String publicId, String systemId) {
37+
// System.out.println(publicId);
38+
final String relativePath = (String) entityMap.get(publicId);
39+
40+
if (relativePath != null) {
41+
Class<?> clazz = getClass();
42+
InputStream in = clazz.getResourceAsStream(relativePath);
43+
if (in == null) {
44+
return null;
45+
} else {
46+
return new InputSource(in);
47+
}
48+
} else {
49+
return null;
50+
}
51+
}
52+
}

logback-classic/src/test/java/ch/qos/logback/classic/net/CounterBasedEvaluator.java renamed to logback-classic-blackbox/src/test/java/ch/qos/logback/classic/blackbox/net/CounterBasedEvaluator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/**
1+
/*
22
* Logback: the reliable, generic, fast and flexible logging framework.
3-
* Copyright (C) 1999-2015, QOS.ch. All rights reserved.
3+
* Copyright (C) 1999-2022, QOS.ch. All rights reserved.
44
*
55
* This program and the accompanying materials are dual-licensed under
66
* either the terms of the Eclipse Public License v1.0 as published by
@@ -11,7 +11,7 @@
1111
* under the terms of the GNU Lesser General Public License version 2.1
1212
* as published by the Free Software Foundation.
1313
*/
14-
package ch.qos.logback.classic.net;
14+
package ch.qos.logback.classic.blackbox.net;
1515

1616
import ch.qos.logback.core.boolex.EvaluationException;
1717
import ch.qos.logback.core.boolex.EventEvaluator;

logback-classic/src/test/java/ch/qos/logback/classic/net/SMTPAppender_GreenTest.java renamed to logback-classic-blackbox/src/test/java/ch/qos/logback/classic/blackbox/net/SMTPAppender_GreenTest.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/**
1+
/*
22
* Logback: the reliable, generic, fast and flexible logging framework.
3-
* Copyright (C) 1999-2015, QOS.ch. All rights reserved.
3+
* Copyright (C) 1999-2022, QOS.ch. All rights reserved.
44
*
55
* This program and the accompanying materials are dual-licensed under
66
* either the terms of the Eclipse Public License v1.0 as published by
@@ -11,14 +11,16 @@
1111
* under the terms of the GNU Lesser General Public License version 2.1
1212
* as published by the Free Software Foundation.
1313
*/
14-
package ch.qos.logback.classic.net;
14+
package ch.qos.logback.classic.blackbox.net;
1515

1616
import java.io.ByteArrayInputStream;
1717
import java.io.ByteArrayOutputStream;
1818
import java.io.IOException;
1919
import java.io.InputStream;
2020
import java.util.concurrent.TimeUnit;
2121

22+
import ch.qos.logback.classic.blackbox.BlackboxClassicTestConstants;
23+
import ch.qos.logback.classic.net.SMTPAppender;
2224
import org.dom4j.DocumentException;
2325
import org.dom4j.io.SAXReader;
2426
import org.junit.jupiter.api.AfterEach;
@@ -32,12 +34,12 @@
3234
import com.icegreen.greenmail.util.GreenMailUtil;
3335
import com.icegreen.greenmail.util.ServerSetup;
3436

35-
import ch.qos.logback.classic.ClassicTestConstants;
37+
//import ch.qos.logback.classic.ClassicTestConstants;
3638
import ch.qos.logback.classic.Logger;
3739
import ch.qos.logback.classic.LoggerContext;
3840
import ch.qos.logback.classic.PatternLayout;
3941
import ch.qos.logback.classic.html.HTMLLayout;
40-
import ch.qos.logback.classic.html.XHTMLEntityResolver;
42+
import ch.qos.logback.classic.blackbox.html.XHTMLEntityResolver;
4143
import ch.qos.logback.classic.joran.JoranConfigurator;
4244
import ch.qos.logback.classic.spi.ILoggingEvent;
4345
import ch.qos.logback.core.Layout;
@@ -297,7 +299,7 @@ private void configure(String file) throws JoranException {
297299
@Test
298300
public void testCustomEvaluator() throws Exception {
299301
startSMTPServer(NO_SSL);
300-
configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "smtp/customEvaluator.xml");
302+
configure(BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "smtp/customEvaluator.xml");
301303

302304
logger.debug("test");
303305
String msg2 = "CustomEvaluator";
@@ -313,7 +315,7 @@ public void testCustomEvaluator() throws Exception {
313315
@Test
314316
public void testCustomBufferSize() throws Exception {
315317
startSMTPServer(NO_SSL);
316-
configure(ClassicTestConstants.JORAN_INPUT_PREFIX + "smtp/customBufferSize.xml");
318+
configure(BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "smtp/customBufferSize.xml");
317319

318320
logger.debug("invisible1");
319321
logger.debug("invisible2");

logback-classic-blackbox/src/test/java/module-info.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@
55
requires jakarta.mail;
66
requires janino;
77

8+
requires dom4j;
9+
requires greenmail;
10+
811
requires org.junit.jupiter.api;
912
requires org.junit.jupiter.engine;
1013
requires org.slf4j;
1114

1215
exports ch.qos.logback.classic.blackbox.boolex;
16+
1317
exports ch.qos.logback.classic.blackbox.joran;
1418
exports ch.qos.logback.classic.blackbox.joran.conditional;
19+
exports ch.qos.logback.classic.blackbox.html;
20+
exports ch.qos.logback.classic.blackbox.net;
1521
}

logback-classic/pom.xml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
<version>1.2.18.4</version>
7272
<scope>test</scope>
7373
</dependency>
74+
7475
<dependency>
7576
<groupId>org.dom4j</groupId>
7677
<artifactId>dom4j</artifactId>
@@ -102,6 +103,7 @@
102103
<artifactId>janino</artifactId>
103104
<optional>true</optional>
104105
</dependency>
106+
105107
<dependency>
106108
<groupId>ch.qos.logback</groupId>
107109
<artifactId>logback-core</artifactId>
@@ -114,22 +116,6 @@
114116
<scope>provided</scope>
115117
</dependency>
116118

117-
<dependency>
118-
<groupId>com.icegreen</groupId>
119-
<artifactId>greenmail</artifactId>
120-
<scope>test</scope>
121-
<exclusions>
122-
<exclusion>
123-
<groupId>junit</groupId>
124-
<artifactId>junit</artifactId>
125-
</exclusion>
126-
<exclusion>
127-
<groupId>com.sun.mail</groupId>
128-
<artifactId>jakarta.mail</artifactId>
129-
</exclusion>
130-
</exclusions>
131-
</dependency>
132-
133119
<dependency>
134120
<groupId>org.apache.felix</groupId>
135121
<artifactId>org.apache.felix.main</artifactId>
@@ -294,9 +280,6 @@
294280
<exclude>org.slf4j.implTest.InitializationOutputTest.java</exclude>
295281
<exclude>ch.qos.logback.classic.util.ContextInitializerTest.java</exclude>
296282
<exclude>ch.qos.logback.classic.spi.InvocationTest.java</exclude>
297-
<!--- temporary -->
298-
<exclude>**/JaninoEventEvaluatorTest.java</exclude>
299-
<exclude>**/ConditionalTest.java</exclude>
300283
</excludes>
301284
</configuration>
302285
</execution>

logback-classic/src/test/input/fqcn.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ ch.qos.logback.classic.multiJVM.FileAppenderPerf
373373
ch.qos.logback.classic.multiJVM.LoggingThread
374374
ch.qos.logback.classic.multiJVM.SafeModeFileAppender
375375
ch.qos.logback.classic.multiJVM.SafeModeRollingFileAppender
376-
ch.qos.logback.classic.net.CounterBasedEvaluator
376+
ch.qos.logback.classic.blackbox.net.CounterBasedEvaluator
377377
ch.qos.logback.classic.net.DilutedSMTPAppenderTest
378378
ch.qos.logback.classic.net.ExternalMockSocketServer
379379
ch.qos.logback.classic.net.mock.MockAppender
@@ -387,7 +387,7 @@ ch.qos.logback.classic.net.server.RemoteAppenderStreamClientTest
387387
ch.qos.logback.classic.net.server.ServerSocketReceiverFunctionalTest
388388
ch.qos.logback.classic.net.server.ServerSocketReceiverTest
389389
ch.qos.logback.classic.net.server.SSLServerSocketReceiverTest
390-
ch.qos.logback.classic.net.SMTPAppender_GreenTest
390+
ch.qos.logback.classic.blackbox.net.SMTPAppender_GreenTest
391391
ch.qos.logback.classic.net.SocketAppenderMessageLossTest
392392
ch.qos.logback.classic.net.SocketMin
393393
ch.qos.logback.classic.net.SocketReceiverTest

0 commit comments

Comments
 (0)