Skip to content

Commit 1fc3913

Browse files
committed
Fix failing tests
1 parent a3cf42d commit 1fc3913

File tree

27 files changed

+249
-258
lines changed

27 files changed

+249
-258
lines changed

log4j-async-logger/pom.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</parent>
2626

2727
<artifactId>log4j-async-logger</artifactId>
28-
<name>Log4j Async Logger</name>
28+
<name>Apache Log4j Async Logger</name>
2929
<description>Alternative implementation of logger that uses LMAX Disruptor.</description>
3030

3131
<dependencies>
@@ -65,4 +65,22 @@
6565
</dependency>
6666

6767
</dependencies>
68+
69+
<build>
70+
<plugins>
71+
<plugin>
72+
<groupId>org.apache.maven.plugins</groupId>
73+
<artifactId>maven-compiler-plugin</artifactId>
74+
<configuration>
75+
<annotationProcessorPaths combine.children="append">
76+
<path>
77+
<groupId>org.apache.logging.log4j</groupId>
78+
<artifactId>log4j-plugin-processor</artifactId>
79+
<version>${project.version}</version>
80+
</path>
81+
</annotationProcessorPaths>
82+
</configuration>
83+
</plugin>
84+
</plugins>
85+
</build>
6886
</project>

log4j-async-logger/src/test/java/org/apache/logging/log4j/async/logger/AsyncLoggerEventTranslationExceptionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
@ContextSelectorType(AsyncLoggerContextSelector.class)
4747
@SetSystemProperty(
4848
key = Log4jPropertyKey.Constant.ASYNC_LOGGER_EXCEPTION_HANDLER_CLASS_NAME,
49-
value = "org.apache.logging.log4j.core.async.AsyncLoggerEventTranslationExceptionTest$TestExceptionHandler")
49+
value = "org.apache.logging.log4j.async.logger.AsyncLoggerEventTranslationExceptionTest$TestExceptionHandler")
5050
class AsyncLoggerEventTranslationExceptionTest {
5151

5252
@Test
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to you under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.logging.log4j.async.logger;
18+
19+
import java.util.stream.Stream;
20+
import org.apache.logging.log4j.core.LoggerContext;
21+
import org.apache.logging.log4j.core.config.Configuration;
22+
import org.apache.logging.log4j.core.config.LoggerConfig;
23+
import org.apache.logging.log4j.core.config.NullConfiguration;
24+
import org.apache.logging.log4j.util.PropertiesUtil;
25+
import org.assertj.core.api.Assertions;
26+
import org.junit.jupiter.params.ParameterizedTest;
27+
import org.junit.jupiter.params.provider.Arguments;
28+
import org.junit.jupiter.params.provider.MethodSource;
29+
30+
class DefaultIncludeLocationTest {
31+
32+
private static final String LOGGER_NAME = DefaultIncludeLocationTest.class.getName();
33+
34+
private static Stream<Arguments> loggerConfigs(final Configuration config) {
35+
return Stream.of(
36+
Arguments.of(
37+
LoggerConfig.newBuilder()
38+
.setConfig(config)
39+
.setLoggerName(LOGGER_NAME)
40+
.build(),
41+
true),
42+
Arguments.of(
43+
LoggerConfig.RootLogger.newRootBuilder()
44+
.setConfig(config)
45+
.build(),
46+
true),
47+
Arguments.of(
48+
AsyncLoggerConfig.newAsyncBuilder()
49+
.setConfig(config)
50+
.setLoggerName(LOGGER_NAME)
51+
.build(),
52+
false),
53+
Arguments.of(
54+
AsyncLoggerConfig.RootLogger.newAsyncRootBuilder()
55+
.setConfig(config)
56+
.build(),
57+
false));
58+
}
59+
60+
static Stream<Arguments> loggerContextDefaultLocation() {
61+
final LoggerContext ctx = new LoggerContext("sync");
62+
ctx.setProperties(PropertiesUtil.getProperties());
63+
final NullConfiguration config = new NullConfiguration(ctx);
64+
ctx.setConfiguration(config);
65+
return loggerConfigs(config);
66+
}
67+
68+
@ParameterizedTest
69+
@MethodSource
70+
void loggerContextDefaultLocation(final LoggerConfig loggerConfig, final boolean expected) {
71+
Assertions.assertThat(loggerConfig.isIncludeLocation())
72+
.as("Default `includeLocation` value")
73+
.isEqualTo(expected);
74+
}
75+
76+
static Stream<LoggerConfig> asyncLoggerContextDefaultLocation() {
77+
final AsyncLoggerContext ctx = new AsyncLoggerContext("async");
78+
ctx.setProperties(PropertiesUtil.getProperties());
79+
final NullConfiguration config = new NullConfiguration(ctx);
80+
ctx.setConfiguration(config);
81+
return loggerConfigs(config).map(args -> (LoggerConfig) args.get()[0]);
82+
}
83+
84+
@ParameterizedTest
85+
@MethodSource
86+
void asyncLoggerContextDefaultLocation(final LoggerConfig loggerConfig) {
87+
Assertions.assertThat(loggerConfig.isIncludeLocation())
88+
.as("Default `includeLocation` value")
89+
.isFalse();
90+
}
91+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to you under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.logging.log4j.async.logger;
18+
19+
import org.apache.logging.log4j.core.test.config.AbstractNestedLoggerConfigTest;
20+
21+
public class NestedAsyncLoggerConfigTest extends AbstractNestedLoggerConfigTest {}

log4j-async-logger/src/test/java/org/apache/logging/log4j/async/logger/QueueFullAsyncAbstractTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
import org.apache.logging.log4j.Level;
2727
import org.apache.logging.log4j.Logger;
2828
import org.apache.logging.log4j.core.LoggerContext;
29-
import org.apache.logging.log4j.core.async.QueueFullAbstractTest;
3029
import org.apache.logging.log4j.core.config.Configuration;
3130
import org.apache.logging.log4j.core.config.LoggerConfig;
3231
import org.apache.logging.log4j.core.test.async.BlockingAppender;
32+
import org.apache.logging.log4j.core.test.async.QueueFullAbstractTest;
3333
import org.apache.logging.log4j.status.StatusData;
3434
import org.apache.logging.log4j.test.ListStatusListener;
3535

log4j-async-logger/src/test/java/org/apache/logging/log4j/async/logger/QueueFullAsyncLogger3Test.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.apache.logging.log4j.core.async.AsyncQueueFullPolicyFactory;
2727
import org.apache.logging.log4j.core.async.DiscardingAsyncQueueFullPolicy;
2828
import org.apache.logging.log4j.core.test.async.BlockingAppender;
29+
import org.apache.logging.log4j.core.test.junit.ContextSelectorType;
2930
import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
3031
import org.apache.logging.log4j.core.test.junit.Named;
3132
import org.apache.logging.log4j.message.Message;
@@ -37,9 +38,7 @@
3738
/**
3839
* Tests queue full scenarios with pure AsyncLoggers (all loggers async).
3940
*/
40-
@SetTestProperty(
41-
key = "LoggerContext.selector",
42-
value = "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector")
41+
@ContextSelectorType(AsyncLoggerContextSelector.class)
4342
@SetTestProperty(key = "AsyncLogger.ringBufferSize", value = "128")
4443
@SetTestProperty(key = "AsyncLogger.formatMsg", value = "true")
4544
@SetTestProperty(key = "AsyncLogger.queueFullPolicy", value = "Discard")

log4j-async-logger/src/test/java/org/apache/logging/log4j/async/logger/QueueFullAsyncLoggerLoggingFromToStringTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.apache.logging.log4j.core.LoggerContext;
2020
import org.apache.logging.log4j.core.test.async.BlockingAppender;
21+
import org.apache.logging.log4j.core.test.junit.ContextSelectorType;
2122
import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
2223
import org.apache.logging.log4j.core.test.junit.Named;
2324
import org.apache.logging.log4j.test.junit.SetTestProperty;
@@ -26,9 +27,7 @@
2627
/**
2728
* Tests queue full scenarios with pure AsyncLoggers (all loggers async).
2829
*/
29-
@SetTestProperty(
30-
key = "LoggerContext.selector",
31-
value = "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector")
30+
@ContextSelectorType(AsyncLoggerContextSelector.class)
3231
@SetTestProperty(key = "AsyncLogger.ringBufferSize", value = "128")
3332
public class QueueFullAsyncLoggerLoggingFromToStringTest extends QueueFullAsyncAbstractTest {
3433

log4j-async-logger/src/test/java/org/apache/logging/log4j/async/logger/QueueFullAsyncLoggerTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.apache.logging.log4j.core.LoggerContext;
2020
import org.apache.logging.log4j.core.test.async.BlockingAppender;
21+
import org.apache.logging.log4j.core.test.junit.ContextSelectorType;
2122
import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
2223
import org.apache.logging.log4j.core.test.junit.Named;
2324
import org.apache.logging.log4j.test.junit.SetTestProperty;
@@ -26,9 +27,7 @@
2627
/**
2728
* Tests queue full scenarios with pure AsyncLoggers (all loggers async).
2829
*/
29-
@SetTestProperty(
30-
key = "LoggerContext.selector",
31-
value = "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector")
30+
@ContextSelectorType(AsyncLoggerContextSelector.class)
3231
@SetTestProperty(key = "AsyncLogger.ringBufferSize", value = "128")
3332
public class QueueFullAsyncLoggerTest extends QueueFullAsyncAbstractTest {
3433

0 commit comments

Comments
 (0)