Skip to content

Commit b3e3567

Browse files
committed
[LOG4J2-2653] Add initial JUnit 5 support
This adds JUnit 5 support to most of the modules. Unchanged modules either contain no tests or use JUnit 4 specific features that need some adjustments to run in the JUnit vintage engine. Backported from 3.x which includes several pom.xml modernizations as well.
1 parent b9ababc commit b3e3567

File tree

29 files changed

+353
-32
lines changed

29 files changed

+353
-32
lines changed

log4j-1.2-api/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@
3939
<artifactId>junit</artifactId>
4040
<scope>test</scope>
4141
</dependency>
42+
<dependency>
43+
<groupId>org.junit.vintage</groupId>
44+
<artifactId>junit-vintage-engine</artifactId>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.junit.jupiter</groupId>
48+
<artifactId>junit-jupiter-api</artifactId>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.junit.jupiter</groupId>
52+
<artifactId>junit-jupiter-engine</artifactId>
53+
</dependency>
4254
<!-- Place Felix before Equinox because Felix is signed. -->
4355
<dependency>
4456
<groupId>org.apache.felix</groupId>

log4j-api/pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,18 @@
5353
<dependency>
5454
<groupId>junit</groupId>
5555
<artifactId>junit</artifactId>
56-
<scope>test</scope>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.junit.vintage</groupId>
59+
<artifactId>junit-vintage-engine</artifactId>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.junit.jupiter</groupId>
63+
<artifactId>junit-jupiter-api</artifactId>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.junit.jupiter</groupId>
67+
<artifactId>junit-jupiter-engine</artifactId>
5768
</dependency>
5869
<dependency>
5970
<groupId>org.eclipse.tycho</groupId>

log4j-appserver/pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,18 @@
9090
<dependency>
9191
<groupId>junit</groupId>
9292
<artifactId>junit</artifactId>
93-
<scope>test</scope>
93+
</dependency>
94+
<dependency>
95+
<groupId>org.junit.vintage</groupId>
96+
<artifactId>junit-vintage-engine</artifactId>
97+
</dependency>
98+
<dependency>
99+
<groupId>org.junit.jupiter</groupId>
100+
<artifactId>junit-jupiter-api</artifactId>
101+
</dependency>
102+
<dependency>
103+
<groupId>org.junit.jupiter</groupId>
104+
<artifactId>junit-jupiter-engine</artifactId>
94105
</dependency>
95106
<dependency>
96107
<groupId>org.springframework</groupId>

log4j-cassandra/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@
5050
<groupId>junit</groupId>
5151
<artifactId>junit</artifactId>
5252
</dependency>
53+
<dependency>
54+
<groupId>org.junit.vintage</groupId>
55+
<artifactId>junit-vintage-engine</artifactId>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.junit.jupiter</groupId>
59+
<artifactId>junit-jupiter-api</artifactId>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.junit.jupiter</groupId>
63+
<artifactId>junit-jupiter-engine</artifactId>
64+
</dependency>
5365
<dependency>
5466
<groupId>org.mockito</groupId>
5567
<artifactId>mockito-core</artifactId>

log4j-core-its/pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,18 @@
127127
<dependency>
128128
<groupId>junit</groupId>
129129
<artifactId>junit</artifactId>
130-
<scope>test</scope>
130+
</dependency>
131+
<dependency>
132+
<groupId>org.junit.vintage</groupId>
133+
<artifactId>junit-vintage-engine</artifactId>
134+
</dependency>
135+
<dependency>
136+
<groupId>org.junit.jupiter</groupId>
137+
<artifactId>junit-jupiter-api</artifactId>
138+
</dependency>
139+
<dependency>
140+
<groupId>org.junit.jupiter</groupId>
141+
<artifactId>junit-jupiter-engine</artifactId>
131142
</dependency>
132143
<dependency>
133144
<groupId>org.hamcrest</groupId>

log4j-core/pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,18 @@
190190
<dependency>
191191
<groupId>junit</groupId>
192192
<artifactId>junit</artifactId>
193-
<scope>test</scope>
193+
</dependency>
194+
<dependency>
195+
<groupId>org.junit.vintage</groupId>
196+
<artifactId>junit-vintage-engine</artifactId>
197+
</dependency>
198+
<dependency>
199+
<groupId>org.junit.jupiter</groupId>
200+
<artifactId>junit-jupiter-api</artifactId>
201+
</dependency>
202+
<dependency>
203+
<groupId>org.junit.jupiter</groupId>
204+
<artifactId>junit-jupiter-engine</artifactId>
194205
</dependency>
195206
<dependency>
196207
<groupId>org.hamcrest</groupId>

log4j-core/src/test/java/org/apache/logging/log4j/test/appender/EncodingListAppender.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ public EncodingListAppender(final String name, final Filter filter, final Layout
4141
super(name, filter, layout, newline, raw);
4242
}
4343

44-
private class Destination implements ByteBufferDestination {
45-
ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[4096]);
44+
private static class Destination implements ByteBufferDestination {
45+
// JUnit 5 stack traces can start to get looooong
46+
ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[8192]);
47+
4648
@Override
4749
public ByteBuffer getByteBuffer() {
4850
return byteBuffer;

log4j-couchdb/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@
5050
<groupId>junit</groupId>
5151
<artifactId>junit</artifactId>
5252
</dependency>
53+
<dependency>
54+
<groupId>org.junit.vintage</groupId>
55+
<artifactId>junit-vintage-engine</artifactId>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.junit.jupiter</groupId>
59+
<artifactId>junit-jupiter-api</artifactId>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.junit.jupiter</groupId>
63+
<artifactId>junit-jupiter-engine</artifactId>
64+
</dependency>
5365
<dependency>
5466
<groupId>org.mockito</groupId>
5567
<artifactId>mockito-core</artifactId>

log4j-flume-ng/pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,18 @@
7070
<dependency>
7171
<groupId>junit</groupId>
7272
<artifactId>junit</artifactId>
73-
<scope>test</scope>
73+
</dependency>
74+
<dependency>
75+
<groupId>org.junit.vintage</groupId>
76+
<artifactId>junit-vintage-engine</artifactId>
77+
</dependency>
78+
<dependency>
79+
<groupId>org.junit.jupiter</groupId>
80+
<artifactId>junit-jupiter-api</artifactId>
81+
</dependency>
82+
<dependency>
83+
<groupId>org.junit.jupiter</groupId>
84+
<artifactId>junit-jupiter-engine</artifactId>
7485
</dependency>
7586
<dependency>
7687
<groupId>org.apache.flume</groupId>

log4j-iostreams/pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,18 @@
5656
<dependency>
5757
<groupId>junit</groupId>
5858
<artifactId>junit</artifactId>
59-
<scope>test</scope>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.junit.vintage</groupId>
62+
<artifactId>junit-vintage-engine</artifactId>
63+
</dependency>
64+
<dependency>
65+
<groupId>org.junit.jupiter</groupId>
66+
<artifactId>junit-jupiter-api</artifactId>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.junit.jupiter</groupId>
70+
<artifactId>junit-jupiter-engine</artifactId>
6071
</dependency>
6172
<dependency>
6273
<groupId>org.hamcrest</groupId>

0 commit comments

Comments
 (0)