Repository: logging-log4j2 Updated Branches: refs/heads/master 2c15220f1 -> 7f3ac8e9b
[LOG4J2-1993] Fix compiler warnings in LoggerConfigTest. Apply patch. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/7f3ac8e9 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/7f3ac8e9 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/7f3ac8e9 Branch: refs/heads/master Commit: 7f3ac8e9bf1fb7cf4c4fa2b295981af21ce6dd73 Parents: 2c15220 Author: Kenneth McFarland <notificati...@github.com> Authored: Fri Jul 28 11:59:10 2017 -0700 Committer: Gary Gregory <ggreg...@apache.org> Committed: Fri Jul 28 11:59:10 2017 -0700 ---------------------------------------------------------------------- .../log4j/core/config/LoggerConfigTest.java | 25 ++++++++++++-------- src/changes/changes.xml | 3 +++ 2 files changed, 18 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7f3ac8e9/log4j-core/src/test/java/org/apache/logging/log4j/core/config/LoggerConfigTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/LoggerConfigTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/LoggerConfigTest.java index 6eb04a3..087952f 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/LoggerConfigTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/LoggerConfigTest.java @@ -15,20 +15,23 @@ package org.apache.logging.log4j.core.config;/* * limitations under the license. */ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; + import java.util.HashSet; import java.util.List; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.core.LogEvent; -import org.apache.logging.log4j.core.impl.Log4jLogEvent; +import org.apache.logging.log4j.core.impl.Log4jLogEvent.Builder; import org.apache.logging.log4j.core.impl.LogEventFactory; import org.apache.logging.log4j.message.Message; import org.apache.logging.log4j.message.SimpleMessage; import org.junit.Test; -import static org.junit.Assert.*; - /** * Tests for LoggerConfig. */ @@ -39,7 +42,7 @@ public class LoggerConfigTest { new NullConfiguration(), null); } - @SuppressWarnings({"deprecation", "unchecked"}) + @SuppressWarnings({"deprecation"}) @Test public void testPropertiesWithoutSubstitution() { assertNull("null propertiesList", createForProperties(null).getPropertyList()); @@ -51,7 +54,8 @@ public class LoggerConfigTest { }; final LoggerConfig loggerConfig = createForProperties(all); final List<Property> list = loggerConfig.getPropertyList(); - assertEquals("map and list contents equal", new HashSet(list), loggerConfig.getProperties().keySet()); + assertEquals("map and list contents equal", new HashSet<Property>(list), + new HashSet<Property>(loggerConfig.getPropertyList())); final Object[] actualList = new Object[1]; loggerConfig.setLogEventFactory(new LogEventFactory() { @@ -60,14 +64,13 @@ public class LoggerConfigTest { final Level level, final Message data, final List<Property> properties, final Throwable t) { actualList[0] = properties; - return new Log4jLogEvent(System.currentTimeMillis()); + return new Builder().setTimeMillis(System.currentTimeMillis()).build(); } }); loggerConfig.log("name", "fqcn", null, Level.INFO, new SimpleMessage("msg"), null); assertSame("propertiesList passed in as is if no substitutions required", list, actualList[0]); } - @SuppressWarnings({"deprecation", "unchecked"}) @Test public void testPropertiesWithSubstitution() { final Property[] all = new Property[] { @@ -76,7 +79,8 @@ public class LoggerConfigTest { }; final LoggerConfig loggerConfig = createForProperties(all); final List<Property> list = loggerConfig.getPropertyList(); - assertEquals("map and list contents equal", new HashSet(list), loggerConfig.getProperties().keySet()); + assertEquals("map and list contents equal", new HashSet<Property>(list), + new HashSet<Property>(loggerConfig.getPropertyList())); final Object[] actualListHolder = new Object[1]; loggerConfig.setLogEventFactory(new LogEventFactory() { @@ -85,13 +89,14 @@ public class LoggerConfigTest { final Level level, final Message data, final List<Property> properties, final Throwable t) { actualListHolder[0] = properties; - return new Log4jLogEvent(System.currentTimeMillis()); + return new Builder().setTimeMillis(System.currentTimeMillis()).build(); } }); loggerConfig.log("name", "fqcn", null, Level.INFO, new SimpleMessage("msg"), null); assertNotSame("propertiesList with substitutions", list, actualListHolder[0]); - final List<Property> actualList = (List<Property>) actualListHolder[0]; + @SuppressWarnings("unchecked") + final List<Property> actualList = (List<Property>) actualListHolder[0]; for (int i = 0; i < list.size(); i++) { assertEquals("name[" + i + "]", list.get(i).getName(), actualList.get(i).getName()); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7f3ac8e9/src/changes/changes.xml ---------------------------------------------------------------------- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 211ffd1..8cf1d43 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -190,6 +190,9 @@ <action issue="LOG4J2-1989" dev="ggregory" type="fix" due-to="Kenneth McFarland"> Clarify Javadoc for AbstractTriggeringPolicy. </action> + <action issue="LOG4J2-1993" dev="ggregory" type="fix" due-to="Kenneth McFarland"> + Fix compiler warnings in LoggerConfigTest. + </action> <action issue="LOG4J2-1851" dev="mikes" type="update"> Move server components from log4j-core to new log4-server module. </action>