You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2022/01/05 22:21:04 UTC
[logging-log4j2] branch master updated: Redo test for to avoid using an existing system property.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/master by this push:
new a9ce963 Redo test for to avoid using an existing system property.
a9ce963 is described below
commit a9ce963478cc3de15d7ad39eb040ef4ada93e0a1
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jan 5 17:14:17 2022 -0500
Redo test for to avoid using an existing system property.
---
.../java/org/apache/log4j/config/PropertiesConfigurationTest.java | 8 +++++++-
.../resources/config-1.2/log4j-FileAppender-with-props.properties | 2 +-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationTest.java
index 29ef8f2..b197367 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationTest.java
@@ -43,6 +43,8 @@ import org.junit.Test;
*/
public class PropertiesConfigurationTest {
+ private static final String TEST_KEY = "log4j.test.tmpdir";
+
@Test
public void testConfigureNullPointerException() throws Exception {
try (LoggerContext loggerContext = TestConfigurator.configure("target/test-classes/LOG4J2-3247.properties")) {
@@ -125,6 +127,8 @@ public class PropertiesConfigurationTest {
@Test
public void testSystemProperties() throws Exception {
+ final String testPathLocation = "target";
+ System.setProperty(TEST_KEY, testPathLocation);
try (LoggerContext loggerContext = TestConfigurator.configure("target/test-classes/config-1.2/log4j-FileAppender-with-props.properties")) {
// [LOG4J2-3312] Bridge does not convert properties.
final Configuration configuration = loggerContext.getConfiguration();
@@ -135,7 +139,9 @@ public class PropertiesConfigurationTest {
assertTrue(appender instanceof FileAppender);
final FileAppender fileAppender = (FileAppender) appender;
// Two slashes because that's how the config file is setup.
- assertEquals(SystemUtils.getJavaIoTmpDir() + File.separator + "/hadoop.log", fileAppender.getFileName());
+ assertEquals(testPathLocation + "/hadoop.log", fileAppender.getFileName());
+ } finally {
+ System.clearProperty(TEST_KEY);
}
}
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-FileAppender-with-props.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-FileAppender-with-props.properties
index b98c194..073ac14 100644
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-FileAppender-with-props.properties
+++ b/log4j-1.2-api/src/test/resources/config-1.2/log4j-FileAppender-with-props.properties
@@ -13,7 +13,7 @@ log4j.rootLogger=TRACE, FILE_APPENDER
hadoop.log.maxfilesize=256MB
hadoop.log.maxbackupindex=20
log4j.appender.FILE_APPENDER=org.apache.log4j.FileAppender
-log4j.appender.FILE_APPENDER.file=${java.io.tmpdir}/${hadoop.log.file}
+log4j.appender.FILE_APPENDER.file=${log4j.test.tmpdir}/${hadoop.log.file}
log4j.appender.FILE_APPENDER.layout=org.apache.log4j.PatternLayout
# Pattern format: Date LogLevel LoggerName LogMessage