This is an automated email from the ASF dual-hosted git repository.
vy pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/2.x by this push:
new fe6d7f2ba9 Repair or remove ineffective tests (#2266)
fe6d7f2ba9 is described below
commit fe6d7f2ba904cbf47d71e1679ef67a8e1d4a8ba6
Author: Volkan Yazıcı <[email protected]>
AuthorDate: Thu Feb 8 13:36:13 2024 +0100
Repair or remove ineffective tests (#2266)
---
.../org/apache/log4j/defaultInit/TestCase1.java | 50 ------
.../org/apache/log4j/defaultInit/TestCase2.java | 55 -------
.../org/apache/log4j/defaultInit/TestCase3.java | 50 ------
.../org/apache/log4j/defaultInit/TestCase4.java | 56 -------
.../log4j/helpers/OptionConverterTestCase.java | 169 ---------------------
.../log4j/helpers/PatternParserTestCase.java | 129 ----------------
.../log4j1-1.2.17/input/defaultInit3.properties | 23 ---
.../status/StatusLoggerSerializationTest.java | 37 -----
...ollingRandomAccessFileAppenderRolloverTest.java | 107 -------------
.../XmlCompactFileAppenderValidationTest.java | 104 -------------
.../XmlCompactFileAsyncAppenderValidationTest.java | 80 ----------
.../appender/XmlRandomAccessFileAppenderTest.java | 88 -----------
...ingRandomAccessFileManagerHeaderFooterTest.java | 110 --------------
...va => AsyncLoggerArgumentFreedOnErrorTest.java} | 2 +-
.../log4j/core/async/AsyncLoggerConfigTest3.java | 71 ---------
.../log4j/core/async/AsyncLoggerConfigTest4.java | 87 -----------
...tNanoTime.java => AsyncLoggerNanoTimeTest.java} | 2 +-
...estConfigurator.java => Configurator1Test.java} | 2 +-
...onfiguratorTest.java => Configurator2Test.java} | 2 +-
...uratorError.java => ConfiguratorErrorTest.java} | 6 +-
...ssingLanguage.java => MissingLanguageTest.java} | 4 +-
.../{TestNoLanguages.java => NoLanguagesTest.java} | 7 +-
.../log4j/core/pattern/PatternParserTest2.java | 91 -----------
.../XmlCompactFileAppenderValidationTest.xml | 30 ----
.../XmlCompactFileAsyncAppenderValidationTest.xml | 30 ----
.../resources/XmlRandomAccessFileAppenderTest.xml | 30 ----
26 files changed, 13 insertions(+), 1409 deletions(-)
diff --git
a/log4j-1.2-api/src/test/java/org/apache/log4j/defaultInit/TestCase1.java
b/log4j-1.2-api/src/test/java/org/apache/log4j/defaultInit/TestCase1.java
deleted file mode 100644
index 30aeafeb7a..0000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/defaultInit/TestCase1.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.defaultInit;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.junit.Ignore;
-
-@Ignore
-public class TestCase1 extends TestCase {
-
- public TestCase1(final String name) {
- super(name);
- }
-
- public void setUp() {}
-
- public void tearDown() {
- LogManager.shutdown();
- }
-
- public void noneTest() {
- final Logger root = Logger.getRootLogger();
- final boolean rootIsConfigured =
root.getAllAppenders().hasMoreElements();
- assertTrue(!rootIsConfigured);
- }
-
- public static Test suite() {
- final TestSuite suite = new TestSuite();
- suite.addTest(new TestCase1("noneTest"));
- return suite;
- }
-}
diff --git
a/log4j-1.2-api/src/test/java/org/apache/log4j/defaultInit/TestCase2.java
b/log4j-1.2-api/src/test/java/org/apache/log4j/defaultInit/TestCase2.java
deleted file mode 100644
index c41634fb1e..0000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/defaultInit/TestCase2.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.defaultInit;
-
-import java.util.Enumeration;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.apache.log4j.Appender;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.junit.Ignore;
-
-@Ignore
-public class TestCase2 extends TestCase {
-
- public TestCase2(final String name) {
- super(name);
- }
-
- public void setUp() {}
-
- public void tearDown() {
- LogManager.shutdown();
- }
-
- public void xmlTest() {
- final Logger root = Logger.getRootLogger();
- final boolean rootIsConfigured =
root.getAllAppenders().hasMoreElements();
- assertTrue(rootIsConfigured);
- final Enumeration e = root.getAllAppenders();
- final Appender appender = (Appender) e.nextElement();
- assertEquals(appender.getName(), "D1");
- }
-
- public static Test suite() {
- final TestSuite suite = new TestSuite();
- suite.addTest(new TestCase2("xmlTest"));
- return suite;
- }
-}
diff --git
a/log4j-1.2-api/src/test/java/org/apache/log4j/defaultInit/TestCase3.java
b/log4j-1.2-api/src/test/java/org/apache/log4j/defaultInit/TestCase3.java
deleted file mode 100644
index 6978b7223a..0000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/defaultInit/TestCase3.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.defaultInit;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.io.IOException;
-import java.util.Enumeration;
-import org.apache.log4j.Appender;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.log4j.config.TestConfigurator;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-
-@Disabled
-public class TestCase3 {
-
- @AfterAll
- public static void tearDown() {
- LogManager.shutdown();
- }
-
- @Test
- public void propertiesTest() throws IOException {
-
TestConfigurator.configure("src/test/resources/log4j1-1.2.17/input/defaultInit3.properties");
- final Logger root = Logger.getRootLogger();
- final boolean rootIsConfigured =
root.getAllAppenders().hasMoreElements();
- assertTrue(rootIsConfigured);
- final Enumeration e = root.getAllAppenders();
- final Appender appender = (Appender) e.nextElement();
- assertEquals(appender.getName(), "D3");
- }
-}
diff --git
a/log4j-1.2-api/src/test/java/org/apache/log4j/defaultInit/TestCase4.java
b/log4j-1.2-api/src/test/java/org/apache/log4j/defaultInit/TestCase4.java
deleted file mode 100644
index 7bf4364faa..0000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/defaultInit/TestCase4.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.defaultInit;
-
-import java.util.Enumeration;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.apache.log4j.Appender;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.junit.Ignore;
-
-@Ignore
-public class TestCase4 extends TestCase {
-
- public TestCase4(final String name) {
- super(name);
- }
-
- public void setUp() {}
-
- public void tearDown() {
- LogManager.shutdown();
- }
-
- public void combinedTest() {
- final Logger root = Logger.getRootLogger();
- final boolean rootIsConfigured =
root.getAllAppenders().hasMoreElements();
- assertTrue(rootIsConfigured);
- final Enumeration e = root.getAllAppenders();
- final Appender appender = (Appender) e.nextElement();
- assertEquals(appender.getName(), "D1");
- assertEquals(e.hasMoreElements(), false);
- }
-
- public static Test suite() {
- final TestSuite suite = new TestSuite();
- suite.addTest(new TestCase4("combinedTest"));
- return suite;
- }
-}
diff --git
a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/OptionConverterTestCase.java
b/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/OptionConverterTestCase.java
deleted file mode 100644
index c2e29b7824..0000000000
---
a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/OptionConverterTestCase.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Properties;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.apache.log4j.Level;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.PropertyConfiguratorTest;
-import org.apache.log4j.xml.XLevel;
-import org.junit.Ignore;
-
-/**
- * Test variable substitution code.
- *
- * @since 1.0
- */
-@Ignore("WIP")
-public class OptionConverterTestCase extends TestCase {
-
- Properties props;
-
- public OptionConverterTestCase(final String name) {
- super(name);
- }
-
- public void setUp() {
- props = new Properties();
- props.put("TOTO", "wonderful");
- props.put("key1", "value1");
- props.put("key2", "value2");
- // Log4J will NPE without this:
- props.put("line.separator", System.getProperty("line.separator"));
- // Log4J will throw an Error without this:
- props.put("java.home", System.getProperty("java.home"));
- System.setProperties(props);
- }
-
- public void tearDown() {
- props = null;
- LogManager.resetConfiguration();
- }
-
- public void varSubstTest1() {
- String r;
-
- r = OptionConverter.substVars("hello world.", null);
- assertEquals("hello world.", r);
-
- r = OptionConverter.substVars("hello ${TOTO} world.", null);
-
- assertEquals("hello wonderful world.", r);
- }
-
- public void varSubstTest2() {
- String r;
-
- r = OptionConverter.substVars("Test2 ${key1} mid ${key2} end.", null);
- assertEquals("Test2 value1 mid value2 end.", r);
- }
-
- public void varSubstTest3() {
- String r;
-
- r = OptionConverter.substVars("Test3 ${unset} mid ${key1} end.", null);
- assertEquals("Test3 mid value1 end.", r);
- }
-
- public void varSubstTest4() {
- final String val = "Test4 ${incomplete ";
- try {
- OptionConverter.substVars(val, null);
- } catch (IllegalArgumentException e) {
- final String errorMsg = e.getMessage();
- // System.out.println('['+errorMsg+']');
- assertEquals('"' + val + "\" has no closing brace. Opening brace
at position 6.", errorMsg);
- }
- }
-
- public void varSubstTest5() {
- final Properties props = new Properties();
- props.put("p1", "x1");
- props.put("p2", "${p1}");
- final String res = OptionConverter.substVars("${p2}", props);
- System.out.println("Result is [" + res + "].");
- assertEquals(res, "x1");
- }
-
- /**
- * Tests configuring Log4J from an InputStream.
- *
- * @since 1.2.17
- */
- public void testInputStream() throws IOException {
- final File file = new
File("src/test/resources/log4j1-1.2.17/input/filter1.properties");
- assertTrue(file.exists());
- try (final FileInputStream inputStream = new FileInputStream(file)) {
- OptionConverter.selectAndConfigure(inputStream, null,
LogManager.getLoggerRepository());
- }
- new PropertyConfiguratorTest().validateNested();
- }
-
- public void toLevelTest1() {
- final String val = "INFO";
- final Level p = OptionConverter.toLevel(val, null);
- assertEquals(p, Level.INFO);
- }
-
- public void toLevelTest2() {
- final String val = "INFO#org.apache.log4j.xml.XLevel";
- final Level p = OptionConverter.toLevel(val, null);
- assertEquals(p, Level.INFO);
- }
-
- public void toLevelTest3() {
- final String val = "TRACE#org.apache.log4j.xml.XLevel";
- final Level p = OptionConverter.toLevel(val, null);
- assertEquals(p, XLevel.TRACE);
- }
-
- public void toLevelTest4() {
- final String val = "TR#org.apache.log4j.xml.XLevel";
- final Level p = OptionConverter.toLevel(val, null);
- assertEquals(p, null);
- }
-
- public void toLevelTest5() {
- final String val = "INFO#org.apache.log4j.xml.TOTO";
- final Level p = OptionConverter.toLevel(val, null);
- assertEquals(p, null);
- }
-
- public static Test suite() {
- final TestSuite suite = new TestSuite();
- suite.addTest(new OptionConverterTestCase("varSubstTest5"));
- suite.addTest(new OptionConverterTestCase("varSubstTest1"));
- suite.addTest(new OptionConverterTestCase("varSubstTest2"));
- suite.addTest(new OptionConverterTestCase("varSubstTest3"));
- suite.addTest(new OptionConverterTestCase("varSubstTest4"));
-
- suite.addTest(new OptionConverterTestCase("testInputStream"));
-
- suite.addTest(new OptionConverterTestCase("toLevelTest1"));
- suite.addTest(new OptionConverterTestCase("toLevelTest2"));
- suite.addTest(new OptionConverterTestCase("toLevelTest3"));
- suite.addTest(new OptionConverterTestCase("toLevelTest4"));
- suite.addTest(new OptionConverterTestCase("toLevelTest5"));
- return suite;
- }
-}
diff --git
a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/PatternParserTestCase.java
b/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/PatternParserTestCase.java
deleted file mode 100644
index 83587139e3..0000000000
---
a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/PatternParserTestCase.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.apache.log4j.Appender;
-import org.apache.log4j.FileAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.MDC;
-import org.apache.log4j.PatternLayout;
-import org.apache.log4j.util.Compare;
-import org.junit.Ignore;
-
-/**
- * Test case for helpers/PatternParser.java. Tests the various conversion
patterns supported by PatternParser. This test
- * class tests PatternParser via the PatternLayout class which uses it.
- */
-@Ignore("WIP")
-public class PatternParserTestCase extends TestCase {
-
- static String OUTPUT_FILE = "target/PatternParser";
- static String WITNESS_FILE = "target/witness/PatternParser";
-
- static String msgPattern = "%m%n";
-
- public static Test suite() {
- final TestSuite suite = new TestSuite();
- suite.addTest(new PatternParserTestCase("mdcPattern"));
- return suite;
- }
-
- Logger root;
-
- Logger logger;
-
- public PatternParserTestCase(final String name) {
- super(name);
- }
-
- /**
- * Test case for MDC conversion pattern.
- */
- public void mdcPattern() throws Exception {
-
- final String mdcMsgPattern1 = "%m : %X%n";
- final String mdcMsgPattern2 = "%m : %X{key1}%n";
- final String mdcMsgPattern3 = "%m : %X{key2}%n";
- final String mdcMsgPattern4 = "%m : %X{key3}%n";
- final String mdcMsgPattern5 = "%m : %X{key1},%X{key2},%X{key3}%n";
-
- // set up appender
- final PatternLayout layout = new PatternLayout(msgPattern);
- final Appender appender = new FileAppender(layout, OUTPUT_FILE +
"_mdc", false);
-
- // set appender on root and set level to debug
- root.addAppender(appender);
- root.setLevel(Level.DEBUG);
-
- // output starting message
- root.debug("starting mdc pattern test");
-
- layout.setConversionPattern(mdcMsgPattern1);
- root.debug("empty mdc, no key specified in pattern");
-
- layout.setConversionPattern(mdcMsgPattern2);
- root.debug("empty mdc, key1 in pattern");
-
- layout.setConversionPattern(mdcMsgPattern3);
- root.debug("empty mdc, key2 in pattern");
-
- layout.setConversionPattern(mdcMsgPattern4);
- root.debug("empty mdc, key3 in pattern");
-
- layout.setConversionPattern(mdcMsgPattern5);
- root.debug("empty mdc, key1, key2, and key3 in pattern");
-
- MDC.put("key1", "value1");
- MDC.put("key2", "value2");
-
- layout.setConversionPattern(mdcMsgPattern1);
- root.debug("filled mdc, no key specified in pattern");
-
- layout.setConversionPattern(mdcMsgPattern2);
- root.debug("filled mdc, key1 in pattern");
-
- layout.setConversionPattern(mdcMsgPattern3);
- root.debug("filled mdc, key2 in pattern");
-
- layout.setConversionPattern(mdcMsgPattern4);
- root.debug("filled mdc, key3 in pattern");
-
- layout.setConversionPattern(mdcMsgPattern5);
- root.debug("filled mdc, key1, key2, and key3 in pattern");
-
- MDC.remove("key1");
- MDC.remove("key2");
-
- layout.setConversionPattern(msgPattern);
- root.debug("finished mdc pattern test");
-
- assertTrue(Compare.compare(OUTPUT_FILE + "_mdc", WITNESS_FILE +
"_mdc"));
- }
-
- public void setUp() {
- root = Logger.getRootLogger();
- root.removeAllAppenders();
- }
-
- public void tearDown() {
- root.getLoggerRepository().resetConfiguration();
- }
-}
diff --git
a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/defaultInit3.properties
b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/defaultInit3.properties
deleted file mode 100644
index d9191bea10..0000000000
---
a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/defaultInit3.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=DEBUG, D3
-log4j.appender.D3=org.apache.log4j.FileAppender
-log4j.appender.D3.File=output/temp
-log4j.appender.D3.Append=false
-log4j.appender.D3.layout=org.apache.log4j.PatternLayout
-log4j.appender.D3.layout.ConversionPattern=%d [%t] %-5p %.16c - %m%n
diff --git
a/log4j-api-test/src/test/java/org/apache/logging/log4j/status/StatusLoggerSerializationTest.java
b/log4j-api-test/src/test/java/org/apache/logging/log4j/status/StatusLoggerSerializationTest.java
deleted file mode 100644
index d6e050d408..0000000000
---
a/log4j-api-test/src/test/java/org/apache/logging/log4j/status/StatusLoggerSerializationTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.status;
-
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.Collection;
-import org.apache.logging.log4j.test.AbstractSerializationTest;
-import org.junit.Ignore;
-import org.junit.runners.Parameterized.Parameters;
-
-@Ignore
-public class StatusLoggerSerializationTest extends AbstractSerializationTest {
-
- @Parameters
- public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][] {{StatusLogger.getLogger()}});
- }
-
- public StatusLoggerSerializationTest(final Serializable serializable) {
- super(serializable);
- }
-}
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/RollingRandomAccessFileAppenderRolloverTest.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/RollingRandomAccessFileAppenderRolloverTest.java
deleted file mode 100644
index 741ca37cda..0000000000
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/RollingRandomAccessFileAppenderRolloverTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.core.appender;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.util.Arrays;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class RollingRandomAccessFileAppenderRolloverTest {
-
- @BeforeClass
- public static void beforeClass() {
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
"RollingRandomAccessFileAppenderTest.xml");
- }
-
- @Test
- @Ignore
- public void testRollover() throws Exception {
- final File file = new File("target",
"RollingRandomAccessFileAppenderTest.log");
- // System.out.println(f.getAbsolutePath());
- final File after1 = new File("target", "afterRollover-1.log");
- file.delete();
- after1.delete();
-
- final Logger log = LogManager.getLogger("com.foo.Bar");
- final String msg = "First a short message that does not trigger
rollover";
- log.info(msg);
- Thread.sleep(50);
-
- BufferedReader reader = new BufferedReader(new FileReader(file));
- final String line1 = reader.readLine();
- assertTrue(line1.contains(msg));
- reader.close();
-
- assertFalse("afterRollover-1.log not created yet", after1.exists());
-
- String exceed = "Long message that exceeds rollover size... ";
- final char[] padding = new char[250];
- Arrays.fill(padding, 'X');
- exceed += new String(padding);
- log.warn(exceed);
- assertFalse("exceeded size but afterRollover-1.log not created yet",
after1.exists());
-
- final String trigger = "This message triggers rollover.";
- log.warn(trigger);
- Thread.sleep(100);
- log.warn(trigger);
-
- CoreLoggerContexts.stopLoggerContext(); // stop async thread
- CoreLoggerContexts.stopLoggerContext(false); // stop async thread
-
- final int MAX_ATTEMPTS = 50;
- int count = 0;
- while (!after1.exists() && count++ < MAX_ATTEMPTS) {
- Thread.sleep(50);
- }
-
- assertTrue("afterRollover-1.log created", after1.exists());
-
- reader = new BufferedReader(new FileReader(file));
- final String new1 = reader.readLine();
- assertTrue("after rollover only new msg", new1.contains(trigger));
- assertNull("No more lines", reader.readLine());
- reader.close();
- file.delete();
-
- reader = new BufferedReader(new FileReader(after1));
- final String old1 = reader.readLine();
- assertTrue("renamed file line 1", old1.contains(msg));
- final String old2 = reader.readLine();
- assertTrue("renamed file line 2", old2.contains(exceed));
- String line = reader.readLine();
- if (line != null) {
- assertTrue("strange...", line.contains("This message triggers
rollover."));
- line = reader.readLine();
- }
- assertNull("No more lines", line);
- reader.close();
- after1.delete();
- }
-}
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAppenderValidationTest.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAppenderValidationTest.java
deleted file mode 100644
index 070debf51c..0000000000
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAppenderValidationTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.core.appender;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import javax.xml.XMLConstants;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import javax.xml.validation.Validator;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configurator;
-import org.apache.logging.log4j.core.test.categories.Layouts;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.xml.sax.SAXException;
-
-/**
- * Tests XML validation for a "compact" XML file, no extra spaces or end of
lines.
- */
-@Ignore
-@Category(Layouts.Xml.class)
-public class XmlCompactFileAppenderValidationTest {
-
- private LoggerContext loggerContext;
-
- @Before
- public void before() {
- this.loggerContext = Configurator.initialize(
- XmlCompactFileAppenderValidationTest.class.getName(),
-
"target/test-classes/XmlCompactFileAppenderValidationTest.xml");
- }
-
- @After
- public void after() {
- // Just in case, an @Test blew up
- Configurator.shutdown(this.loggerContext);
- }
-
- @Test
- public void validateXmlSchemaThrowable() throws Exception {
- final File file = new File("target",
"XmlCompactFileAppenderValidationTest.log.xml");
- file.delete();
- final Logger log = LogManager.getLogger("com.foo.Bar");
- try {
- throw new IllegalArgumentException("IAE");
- } catch (final IllegalArgumentException e) {
- log.warn("Message 1", e);
- }
- Configurator.shutdown(this.loggerContext);
- this.validateXmlSchema(file);
- }
-
- @Test
- public void validateXmlSchema() throws Exception {
- final File file = new File("target",
"XmlCompactFileAppenderValidationTest.log.xml");
- file.delete();
- final Logger log = LogManager.getLogger("com.foo.Bar");
- log.warn("Message 1");
- log.info("Message 2");
- log.debug("Message 3");
- Configurator.shutdown(this.loggerContext);
- this.validateXmlSchema(file);
- }
-
- @Test
- public void validateXmlNoEvents() throws Exception {
- final File file = new File("target",
"XmlCompactFileAppenderValidationTest.log.xml");
- file.delete();
- Configurator.shutdown(this.loggerContext);
- this.validateXmlSchema(file);
- }
-
- private void validateXmlSchema(final File file) throws SAXException,
IOException {
- final URL schemaFile =
this.getClass().getClassLoader().getResource("Log4j-events.xsd");
- final Source xmlFile = new StreamSource(file);
- final SchemaFactory schemaFactory =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- final Schema schema = schemaFactory.newSchema(schemaFile);
- final Validator validator = schema.newValidator();
- validator.validate(xmlFile);
- }
-}
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAsyncAppenderValidationTest.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAsyncAppenderValidationTest.java
deleted file mode 100644
index 290b6af6a0..0000000000
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAsyncAppenderValidationTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.core.appender;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import javax.xml.XMLConstants;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import javax.xml.validation.Validator;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.Layouts;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.xml.sax.SAXException;
-
-/**
- * Tests XML validation for a "compact" XML file, no extra spaces or end of
lines.
- */
-@Ignore
-@Category(Layouts.Xml.class)
-public class XmlCompactFileAsyncAppenderValidationTest {
-
- @BeforeClass
- public static void beforeClass() {
- System.setProperty(
- ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
"XmlCompactFileAsyncAppenderValidationTest.xml");
- }
-
- @Test
- public void validateXmlSchemaSimple() throws Exception {
- final File file = new File("target",
"XmlCompactFileAsyncAppenderValidationTest.log.xml");
- file.delete();
- final Logger log = LogManager.getLogger("com.foo.Bar");
- log.warn("Message 1");
- log.info("Message 2");
- log.debug("Message 3");
- CoreLoggerContexts.stopLoggerContext(file); // stop async thread
- this.validateXmlSchema(file);
- }
-
- @Test
- public void validateXmlSchemaNoEvents() throws Exception {
- final File file = new File("target",
"XmlCompactFileAsyncAppenderValidationTest.log.xml");
- file.delete();
- CoreLoggerContexts.stopLoggerContext(file); // stop async thread
- this.validateXmlSchema(file);
- }
-
- private void validateXmlSchema(final File file) throws SAXException,
IOException {
- final URL schemaFile =
this.getClass().getClassLoader().getResource("Log4j-events.xsd");
- final Source xmlFile = new StreamSource(file);
- final SchemaFactory schemaFactory =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- final Schema schema = schemaFactory.newSchema(schemaFile);
- final Validator validator = schema.newValidator();
- validator.validate(xmlFile);
- }
-}
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlRandomAccessFileAppenderTest.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlRandomAccessFileAppenderTest.java
deleted file mode 100644
index 6c0e82bd05..0000000000
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/XmlRandomAccessFileAppenderTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.core.appender;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.Layouts;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-/**
- * Tests a "complete" XML file a.k.a. a well-formed XML file.
- */
-@Category(Layouts.Xml.class)
-public class XmlRandomAccessFileAppenderTest {
-
- @BeforeClass
- public static void beforeClass() {
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
"XmlRandomAccessFileAppenderTest.xml");
- }
-
- @Test
- @Ignore
- public void testFlushAtEndOfBatch() throws Exception {
- final File file = new File("target",
"XmlRandomAccessFileAppenderTest.log");
- // System.out.println(f.getAbsolutePath());
- file.delete();
- final Logger log = LogManager.getLogger("com.foo.Bar");
- final String logMsg = "Message flushed with immediate flush=false";
- log.info(logMsg);
- CoreLoggerContexts.stopLoggerContext(false, file); // stop async thread
-
- String line1;
- String line2;
- String line3;
- String line4;
- try (final BufferedReader reader = new BufferedReader(new
FileReader(file))) {
- line1 = reader.readLine();
- line2 = reader.readLine();
- line3 = reader.readLine();
- line4 = reader.readLine();
- } finally {
- file.delete();
- }
- assertNotNull("line1", line1);
- final String msg1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
- assertTrue("line1 incorrect: [" + line1 + "], does not contain: [" +
msg1 + ']', line1.equals(msg1));
-
- assertNotNull("line2", line2);
- final String msg2 = "<log4j:events
xmlns:log4j=\"http://logging.apache.org/log4j/\">";
- assertTrue("line2 incorrect: [" + line2 + "], does not contain: [" +
msg2 + ']', line2.equals(msg2));
-
- assertNotNull("line3", line3);
- final String msg3 = "<log4j:event ";
- assertTrue("line3 incorrect: [" + line3 + "], does not contain: [" +
msg3 + ']', line3.contains(msg3));
-
- assertNotNull("line4", line4);
- final String msg4 = logMsg;
- assertTrue("line4 incorrect: [" + line4 + "], does not contain: [" +
msg4 + ']', line4.contains(msg4));
-
- final String location = "testFlushAtEndOfBatch";
- assertTrue("no location", !line1.contains(location));
- }
-}
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerHeaderFooterTest.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerHeaderFooterTest.java
deleted file mode 100644
index c0db1a331e..0000000000
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManagerHeaderFooterTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.core.appender.rolling;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.nio.charset.Charset;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.layout.HtmlLayout;
-import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
-import org.apache.logging.log4j.core.util.Closer;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.RuleChain;
-
-/**
- *
- */
-public class RollingRandomAccessFileManagerHeaderFooterTest {
-
- private static final String CONFIG =
"RollingRandomAccessFileAppenderHeaderFooterTest.xml";
- private static final String DIR =
"target/RollingRandomAccessFileAppenderHeaderFooterTest/";
- private static final String LOGFILE =
"target/RollingRandomAccessFileAppenderHeaderFooterTest.log";
-
- public LoggerContextRule loggerContextRule =
LoggerContextRule.createShutdownTimeoutLoggerContextRule(CONFIG);
-
- @Rule
- public RuleChain chain = loggerContextRule.withCleanFoldersRule(DIR);
-
- private Logger logger;
-
- @Before
- public void setUp() throws Exception {
- this.logger =
loggerContextRule.getLogger(RollingRandomAccessFileManagerHeaderFooterTest.class.getName());
- }
-
- @Ignore // FIXME
- @Test
- public void testAppender() throws Exception {
- for (int i = 0; i < 8; ++i) {
- logger.debug("This is test message number " + i);
- }
- Thread.sleep(50);
- final File dir = new File(DIR);
- assertTrue("Directory not created: " + dir, dir.exists());
- assertTrue("Directory empty: " + dir, dir.listFiles().length > 0);
- final File[] files = dir.listFiles();
- assertNotNull(files);
- for (final File file : files) {
- assertHeader(file);
- assertFooter(file);
- }
- final File logFile = new File(LOGFILE);
- assertTrue("Expected logfile to exist: " + LOGFILE, logFile.exists());
- assertHeader(logFile);
- }
-
- private void assertHeader(final File file) throws Exception {
- final HtmlLayout layout = HtmlLayout.createDefaultLayout();
- final String header = new String(layout.getHeader(),
Charset.defaultCharset());
- final String withoutTimestamp = header.substring(0, 435);
- final String contents = new String(slurp(file),
Charset.defaultCharset());
- final String contentsInitialChunk = contents.substring(0, 435);
- assertEquals(file.getName(), withoutTimestamp, contentsInitialChunk);
- }
-
- private void assertFooter(final File file) throws Exception {
- final HtmlLayout layout = HtmlLayout.createDefaultLayout();
- final String footer = new String(layout.getFooter(),
Charset.defaultCharset());
- final String contents = new String(slurp(file),
Charset.defaultCharset());
- assertTrue(file.getName(), contents.endsWith(footer));
- }
-
- private byte[] slurp(final File file) throws Exception {
- FileInputStream in = null;
- try {
- in = new FileInputStream(file);
- final byte[] result = new byte[(int) file.length()];
- int pos = 0;
- int length = in.read(result);
- while (length > 0) {
- pos += length;
- length = in.read(result, pos, result.length - pos);
- }
- return result;
- } finally {
- Closer.closeSilently(in);
- }
- }
-}
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestArgumentFreedOnError.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerArgumentFreedOnErrorTest.java
similarity index 98%
rename from
log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestArgumentFreedOnError.java
rename to
log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerArgumentFreedOnErrorTest.java
index c8eb51ec63..cd0b998c92 100644
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestArgumentFreedOnError.java
+++
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerArgumentFreedOnErrorTest.java
@@ -33,7 +33,7 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
@Category(AsyncLoggers.class)
-public class AsyncLoggerTestArgumentFreedOnError {
+public class AsyncLoggerArgumentFreedOnErrorTest {
@BeforeClass
public static void beforeClass() {
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest3.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest3.java
deleted file mode 100644
index 7fd51ee7ca..0000000000
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest3.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.core.async;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.ParameterizedMessage;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-@Category(AsyncLoggers.class)
-public class AsyncLoggerConfigTest3 {
-
- @Test
- public void testNoConcurrentModificationException() throws Exception {
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
"AsyncLoggerConfigTest2.xml");
- final File file = new File("target", "AsyncLoggerConfigTest2.log");
- assertTrue("Deleted old file before test", !file.exists() ||
file.delete());
-
- final Logger log = LogManager.getLogger("com.foo.Bar");
- log.info("initial message");
- Thread.sleep(500);
-
- final Map<String, String> map = new HashMap<>();
- for (int j = 0; j < 3000; j++) {
- map.put(String.valueOf(j), String.valueOf(System.nanoTime()));
- }
-
- final Message msg = new ParameterizedMessage("{}", map);
- final Log4jLogEvent event = Log4jLogEvent.newBuilder()
- .setLevel(Level.WARN)
- .setLoggerName(getClass().getName())
- .setMessage(msg)
- .setTimeMillis(0)
- .build();
-
- for (int i = 0; i < 100; i++) {
- ((AsyncLoggerConfig) ((org.apache.logging.log4j.core.Logger)
log).get()).callAppenders(event);
- for (int j = 0; j < 3000; j++) {
- map.remove(String.valueOf(j));
- }
- for (int j = 0; j < 3000; j++) {
- map.put(String.valueOf(j), String.valueOf(System.nanoTime()));
- }
- }
- }
-}
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest4.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest4.java
deleted file mode 100644
index 09ebf67eb8..0000000000
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest4.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.core.async;
-
-import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-@Category(AsyncLoggers.class)
-public class AsyncLoggerConfigTest4 {
-
- @BeforeClass
- public static void beforeClass() {
- System.setProperty("log4j2.is.webapp", "false");
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
"AsyncLoggerConfigTest4.xml");
- }
-
- @AfterClass
- public static void afterClass() {
- System.clearProperty("log4j2.is.webapp");
- }
-
- @Test
- public void testParameters() throws Exception {
- final File file = new File("target", "AsyncLoggerConfigTest4.log");
- assertTrue("Deleted old file before test", !file.exists() ||
file.delete());
-
- final Logger log = LogManager.getLogger("com.foo.Bar");
- log.info("Additive logging: {} for the price of {}!", 2, 1);
- CoreLoggerContexts.stopLoggerContext(file); // stop async thread
-
- final BufferedReader reader = new BufferedReader(new FileReader(file));
- final String line1 = reader.readLine();
- final String line2 = reader.readLine();
- final String line3 = reader.readLine();
- final String line4 = reader.readLine();
- final String line5 = reader.readLine();
- reader.close();
- file.delete();
-
- assertThat(
- line1,
- containsString(
- "Additive logging: {} for the price of {}! [2,1]
Additive logging: 2 for the price of 1!"));
- assertThat(
- line2,
- containsString(
- "Additive logging: {} for the price of {}! [2,1]
Additive logging: 2 for the price of 1!"));
- assertThat(
- line3,
- containsString(
- "Additive logging: {} for the price of {}! [2,1]
Additive logging: 2 for the price of 1!"));
- assertThat(
- line4,
- containsString(
- "Additive logging: {} for the price of {}! [2,1]
Additive logging: 2 for the price of 1!"));
- assertNull("Expected only two lines to be logged", line5);
- }
-}
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestNanoTime.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerNanoTimeTest.java
similarity index 99%
rename from
log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestNanoTime.java
rename to
log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerNanoTimeTest.java
index a27ea86a28..617090804e 100644
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestNanoTime.java
+++
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerNanoTimeTest.java
@@ -38,7 +38,7 @@ import org.junit.Test;
import org.junit.experimental.categories.Category;
@Category(AsyncLoggers.class)
-public class AsyncLoggerTestNanoTime {
+public class AsyncLoggerNanoTimeTest {
@BeforeClass
public static void beforeClass() {
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/Configurator1Test.java
similarity index 99%
rename from
log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
rename to
log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/Configurator1Test.java
index 91b6af950d..be2c6fd199 100644
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
+++
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/Configurator1Test.java
@@ -66,7 +66,7 @@ import org.junitpioneer.jupiter.SetSystemProperty;
@SetSystemProperty(key = Constants.SCRIPT_LANGUAGES, value = "beanshell,
Groovy, Javascript")
@Tag("functional")
-public class TestConfigurator {
+public class Configurator1Test {
private static final String CONFIG_NAME = "TestConfigurator";
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorTest.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/Configurator2Test.java
similarity index 99%
rename from
log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorTest.java
rename to
log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/Configurator2Test.java
index 39fd82c890..d1459aea78 100644
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorTest.java
+++
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/Configurator2Test.java
@@ -28,7 +28,7 @@ import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
@Tag("functional")
-public class ConfiguratorTest {
+public class Configurator2Test {
@Test
public void testInitializeFromAbsoluteFilePath() {
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/TestConfiguratorError.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorErrorTest.java
similarity index 92%
rename from
log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/TestConfiguratorError.java
rename to
log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorErrorTest.java
index 0ea3722694..a558e4992d 100644
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/TestConfiguratorError.java
+++
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ConfiguratorErrorTest.java
@@ -26,21 +26,21 @@ import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.parallel.ResourceLock;
@ResourceLock("log4j2.LoggerContextFactory")
-public class TestConfiguratorError {
+public class ConfiguratorErrorTest {
@RegisterExtension
static final LoggerContextFactoryExtension EXTENSION =
new
LoggerContextFactoryExtension(SimpleLoggerContextFactory.INSTANCE);
@Test
- public void testErrorNoClassLoader() throws Exception {
+ public void testErrorNoClassLoader() {
try (final LoggerContext ctx = Configurator.initialize("Test1",
"target/test-classes/log4j2-config.xml")) {
assertNull(ctx, "No LoggerContext should have been returned");
}
}
@Test
- public void testErrorNullClassLoader() throws Exception {
+ public void testErrorNullClassLoader() {
try (final LoggerContext ctx =
Configurator.initialize("Test1", null,
"target/test-classes/log4j2-config.xml")) {
assertNull(ctx, "No LoggerContext should have been returned");
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/TestMissingLanguage.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/MissingLanguageTest.java
similarity index 98%
rename from
log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/TestMissingLanguage.java
rename to
log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/MissingLanguageTest.java
index 7525007b84..9018c42acb 100644
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/TestMissingLanguage.java
+++
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/MissingLanguageTest.java
@@ -34,7 +34,7 @@ import org.junitpioneer.jupiter.SetSystemProperty;
@SetSystemProperty(key = Constants.SCRIPT_LANGUAGES, value = "beanshell,
Javascript")
@Tag("functional")
-public class TestMissingLanguage {
+public class MissingLanguageTest {
private LoggerContext ctx = null;
@@ -48,7 +48,7 @@ public class TestMissingLanguage {
}
@org.junit.jupiter.api.Test
- public void testBuilderWithScripts() throws Exception {
+ public void testBuilderWithScripts() {
final String script =
"if (logEvent.getLoggerName().equals(\"NoLocation\")) {\n" + "
return \"NoLocation\";\n"
+ " } else if (logEvent.getMarker() != null
&& logEvent.getMarker().isInstanceOf(\"FLOW\")) {\n"
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/TestNoLanguages.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/NoLanguagesTest.java
similarity index 97%
rename from
log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/TestNoLanguages.java
rename to
log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/NoLanguagesTest.java
index e111df8e3f..b7bf58961e 100644
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/TestNoLanguages.java
+++
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/NoLanguagesTest.java
@@ -28,9 +28,10 @@ import
org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFact
import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
@Tag("functional")
-public class TestNoLanguages {
+public class NoLanguagesTest {
private LoggerContext ctx = null;
@@ -43,8 +44,8 @@ public class TestNoLanguages {
}
}
- @org.junit.jupiter.api.Test
- public void testBuilderWithScripts() throws Exception {
+ @Test
+ public void testBuilderWithScripts() {
final String script =
"if (logEvent.getLoggerName().equals(\"NoLocation\")) {\n" + "
return \"NoLocation\";\n"
+ " } else if (logEvent.getMarker() != null
&& logEvent.getMarker().isInstanceOf(\"FLOW\")) {\n"
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest2.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest2.java
deleted file mode 100644
index 29bcb4ca04..0000000000
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest2.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.core.pattern;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import org.junit.jupiter.api.Test;
-
-public class PatternParserTest2 {
-
- @Test
- public void testParseConvertBackslashes() {
- final boolean convert = true;
- final StringBuilder buf = new StringBuilder();
- final String pattern = "%d{HH-mm-ss} \\t ...";
-
- final Calendar cal = Calendar.getInstance();
- cal.set(Calendar.HOUR_OF_DAY, 23);
- cal.set(Calendar.MINUTE, 53);
- cal.set(Calendar.SECOND, 01);
- parse(pattern, convert, buf, cal.getTime(), 123);
-
- assertEquals("23-53-01 \t ...", buf.toString());
- }
-
- @Test
- public void testParseDontConvertBackslashes() {
- final boolean convert = false;
- final StringBuilder buf = new StringBuilder();
- final String pattern = "%d{HH-mm-ss} \\t---";
-
- final Calendar cal = Calendar.getInstance();
- cal.set(Calendar.HOUR_OF_DAY, 13);
- cal.set(Calendar.MINUTE, 24);
- cal.set(Calendar.SECOND, 59);
- parse(pattern, convert, buf, cal.getTime(), 3);
-
- assertEquals("13-24-59 \\t---", buf.toString());
- }
-
- private void parse(
- final String pattern, final boolean convert, final StringBuilder
buf, final Date date, final int i) {
- final PatternParser parser0 = new PatternParser(null, "Converter",
null);
- final List<PatternConverter> converters = new ArrayList<>();
- final List<FormattingInfo> fields = new ArrayList<>();
- parser0.parse(pattern, converters, fields, false, false, convert);
- final FormattingInfo[] patternFields =
fields.toArray(FormattingInfo.EMPTY_ARRAY);
- final ArrayPatternConverter[] converterArray = new
ArrayPatternConverter[converters.size()];
- final ArrayPatternConverter[] patternConverters =
converters.toArray(converterArray);
- formatFileName(patternConverters, patternFields, buf, date, i);
- }
-
- /**
- * Format file name.
- *
- * @param buf string buffer to which formatted file name is appended, may
not be null.
- * @param objects objects to be evaluated in formatting, may not be null.
- */
- protected final void formatFileName(
- final ArrayPatternConverter[] patternConverters,
- final FormattingInfo[] patternFields,
- final StringBuilder buf,
- final Object... objects) {
- for (int i = 0; i < patternConverters.length; i++) {
- final int fieldStart = buf.length();
- patternConverters[i].format(buf, objects);
-
- if (patternFields[i] != null) {
- patternFields[i].format(fieldStart, buf);
- }
- }
- }
-}
diff --git
a/log4j-core-test/src/test/resources/XmlCompactFileAppenderValidationTest.xml
b/log4j-core-test/src/test/resources/XmlCompactFileAppenderValidationTest.xml
deleted file mode 100644
index 059c54c154..0000000000
---
a/log4j-core-test/src/test/resources/XmlCompactFileAppenderValidationTest.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to you under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<Configuration status="OFF">
- <Appenders>
- <File name="XmlFile"
fileName="target/XmlCompactFileAppenderValidationTest.log.xml"
immediateFlush="false" append="false">
- <XmlLayout complete="true" compact="true" charset="UTF-8"/>
- </File>
- </Appenders>
-
- <Loggers>
- <Root level="info" includeLocation="false">
- <AppenderRef ref="XmlFile"/>
- </Root>
- </Loggers>
-</Configuration>
diff --git
a/log4j-core-test/src/test/resources/XmlCompactFileAsyncAppenderValidationTest.xml
b/log4j-core-test/src/test/resources/XmlCompactFileAsyncAppenderValidationTest.xml
deleted file mode 100644
index 3bf389e4b3..0000000000
---
a/log4j-core-test/src/test/resources/XmlCompactFileAsyncAppenderValidationTest.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to you under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<Configuration status="OFF">
- <Appenders>
- <File name="XmlFile"
fileName="target/XmlCompactFileAsyncAppenderValidationTest.log.xml"
immediateFlush="false" append="false">
- <XmlLayout complete="true" compact="true" charset="UTF-8"/>
- </File>
- </Appenders>
-
- <Loggers>
- <AsyncRoot level="info" includeLocation="false">
- <AppenderRef ref="XmlFile"/>
- </AsyncRoot>
- </Loggers>
-</Configuration>
diff --git
a/log4j-core-test/src/test/resources/XmlRandomAccessFileAppenderTest.xml
b/log4j-core-test/src/test/resources/XmlRandomAccessFileAppenderTest.xml
deleted file mode 100644
index c687144c5d..0000000000
--- a/log4j-core-test/src/test/resources/XmlRandomAccessFileAppenderTest.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to you under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<Configuration status="OFF">
- <Appenders>
- <RandomAccessFile name="XmlRandomAccessFile"
fileName="target/XmlRandomAccessFileAppenderTest.log" immediateFlush="false"
append="false">
- <XmlLayout complete="true"/>
- </RandomAccessFile>
- </Appenders>
-
- <Loggers>
- <AsyncRoot level="info" includeLocation="false">
- <AppenderRef ref="XmlRandomAccessFile"/>
- </AsyncRoot>
- </Loggers>
-</Configuration>