Skip to content

Commit 245da43

Browse files
committed
Refactor log4j-gctests (#2163)
1 parent b8fb8c8 commit 245da43

File tree

12 files changed

+87
-323
lines changed

12 files changed

+87
-323
lines changed

log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/categories/GarbageFree.java

Lines changed: 0 additions & 22 deletions
This file was deleted.

log4j-gc-test/pom.xml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one or more
4+
~ contributor license agreements. See the NOTICE file distributed with
5+
~ this work for additional information regarding copyright ownership.
6+
~ The ASF licenses this file to you under the Apache License, Version 2.0
7+
~ (the "License"); you may not use this file except in compliance with
8+
~ the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
-->
18+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
19+
<modelVersion>4.0.0</modelVersion>
20+
<parent>
21+
<groupId>org.apache.logging.log4j</groupId>
22+
<artifactId>log4j</artifactId>
23+
<version>${revision}</version>
24+
<relativePath>../log4j-parent</relativePath>
25+
</parent>
26+
27+
<artifactId>log4j-gc-test</artifactId>
28+
<packaging>jar</packaging>
29+
<name>Apache Log4j garbage collector tests</name>
30+
<properties>
31+
<maven.deploy.skip>true</maven.deploy.skip>
32+
<maven.install.skip>true</maven.install.skip>
33+
</properties>
34+
<dependencies>
35+
<dependency>
36+
<groupId>org.apache.logging.log4j</groupId>
37+
<artifactId>log4j-core</artifactId>
38+
<scope>test</scope>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.apache.logging.log4j</groupId>
42+
<artifactId>log4j-layout-template-json</artifactId>
43+
<scope>test</scope>
44+
</dependency>
45+
<!-- Required for AsyncLoggers -->
46+
<dependency>
47+
<groupId>com.lmax</groupId>
48+
<artifactId>disruptor</artifactId>
49+
<scope>test</scope>
50+
<optional>true</optional>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.junit.jupiter</groupId>
54+
<artifactId>junit-jupiter-engine</artifactId>
55+
<scope>test</scope>
56+
</dependency>
57+
<dependency>
58+
<groupId>com.google.code.java-allocation-instrumenter</groupId>
59+
<artifactId>java-allocation-instrumenter</artifactId>
60+
<scope>test</scope>
61+
<exclusions>
62+
<exclusion>
63+
<groupId>com.google.guava</groupId>
64+
<artifactId>guava-testlib</artifactId>
65+
</exclusion>
66+
</exclusions>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.assertj</groupId>
70+
<artifactId>assertj-core</artifactId>
71+
<scope>test</scope>
72+
</dependency>
73+
</dependencies>
74+
</project>
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,18 @@
1818

1919
import org.apache.logging.log4j.core.async.AsyncLoggerContextSelector;
2020
import org.apache.logging.log4j.core.impl.Log4jPropertyKey;
21-
import org.apache.logging.log4j.core.test.categories.GarbageFree;
2221
import org.apache.logging.log4j.spi.LoggingSystemProperty;
23-
import org.junit.experimental.categories.Category;
2422
import org.junit.jupiter.api.Tag;
2523
import org.junit.jupiter.api.Test;
2624

2725
/**
2826
* Verifies steady state logging is GC-free.
2927
*
30-
* @see <a href="https://github.com/google/allocation-instrumenter">https://github.com/google/allocation-instrumenter</a>
28+
* @see <a href="https://github.com/google/allocation-instrumenter">Google Allocation Instrumenter</a>
3129
*/
3230
@Tag("allocation")
3331
@Tag("functional")
34-
@Category(GarbageFree.class)
35-
public class GcFreeAsynchronousLoggingTest {
32+
public class GcFreeAsyncLoggingTest {
3633

3734
@Test
3835
public void testNoAllocationDuringSteadyStateLogging() throws Throwable {
@@ -49,6 +46,6 @@ public static void main(final String[] args) throws Exception {
4946
System.setProperty(
5047
Log4jPropertyKey.CONTEXT_SELECTOR_CLASS_NAME.getSystemKey(),
5148
AsyncLoggerContextSelector.class.getName());
52-
GcFreeLoggingTestUtil.executeLogging("gcFreeLogging.xml", GcFreeAsynchronousLoggingTest.class);
49+
GcFreeLoggingTestUtil.executeLogging("gcFreeLogging.xml", GcFreeAsyncLoggingTest.class);
5350
}
5451
}

log4j-gctests/src/test/java/org/apache/logging/log4j/gctests/GcFreeLoggingTestUtil.java renamed to log4j-gc-test/src/test/java/org/apache/logging/log4j/gctests/GcFreeLoggingTestUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
/**
4848
* Utility methods for the GC-free logging tests.
4949
*/
50-
public enum GcFreeLoggingTestUtil {
50+
enum GcFreeLoggingTestUtil {
5151
;
5252

53-
public static void executeLogging(final String configurationFile, final Class<?> testClass) throws Exception {
53+
static void executeLogging(final String configurationFile, final Class<?> testClass) throws Exception {
5454

5555
System.setProperty(Log4jPropertyKey.GC_ENABLE_DIRECT_ENCODERS.getSystemKey(), "true");
5656
System.setProperty(LoggingSystemProperty.IS_WEBAPP.getSystemKey(), "false");
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,17 @@
1616
*/
1717
package org.apache.logging.log4j.gctests;
1818

19-
import org.apache.logging.log4j.core.test.categories.GarbageFree;
2019
import org.apache.logging.log4j.spi.LoggingSystemProperty;
21-
import org.junit.experimental.categories.Category;
2220
import org.junit.jupiter.api.Tag;
2321
import org.junit.jupiter.api.Test;
2422

2523
/**
2624
* Verifies steady state mixed synchronous and asynchronous logging is GC-free.
2725
*
28-
* @see <a href="https://github.com/google/allocation-instrumenter">https://github.com/google/allocation-instrumenter</a>
26+
* @see <a href="https://github.com/google/allocation-instrumenter">Google Allocation Instrumenter</a>
2927
*/
3028
@Tag("allocation")
3129
@Tag("functional")
32-
@Category(GarbageFree.class)
3330
public class GcFreeMixedSyncAsyncLoggingTest {
3431

3532
@Test
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,17 @@
1616
*/
1717
package org.apache.logging.log4j.gctests;
1818

19-
import org.apache.logging.log4j.core.test.categories.GarbageFree;
2019
import org.apache.logging.log4j.spi.LoggingSystemProperty;
21-
import org.junit.experimental.categories.Category;
2220
import org.junit.jupiter.api.Tag;
2321
import org.junit.jupiter.api.Test;
2422

2523
/**
2624
* Verifies steady state synchronous logging is GC-free.
2725
*
28-
* @see <a href="https://github.com/google/allocation-instrumenter">https://github.com/google/allocation-instrumenter</a>
26+
* @see <a href="https://github.com/google/allocation-instrumenter">Google Allocation Instrumenter</a>
2927
*/
3028
@Tag("allocation")
3129
@Tag("functional")
32-
@Category(GarbageFree.class)
3330
public class GcFreeSynchronousLoggingTest {
3431

3532
@Test
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
import org.junit.jupiter.api.Tag;
2121
import org.junit.jupiter.api.Test;
2222

23+
/**
24+
* Verifies steady state logging with JSON Template Layout is GC-free.
25+
*
26+
* @see <a href="https://github.com/google/allocation-instrumenter">Google Allocation Instrumenter</a>
27+
*/
2328
@Tag("allocation")
2429
@Tag("functional")
2530
public class JsonTemplateLayoutGcFreeTest {
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)