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 2017/08/31 21:01:27 UTC

logging-log4j2 git commit: [LOG4J2-2023] Use a class' canonical name instead of name to create its logger name. If the canonical name is null, then use the class name. More tests getLogger() vs. getLogger(Class).

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 9940e75f6 -> e67bf824b


[LOG4J2-2023] Use a class' canonical name instead of name to create its
logger name. If the canonical name is null, then use the class name.
More tests getLogger() vs. getLogger(Class).

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/e67bf824
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/e67bf824
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/e67bf824

Branch: refs/heads/master
Commit: e67bf824bd8e9a6d3c796c53a359c89f2fbdc4e1
Parents: 9940e75
Author: Gary Gregory <ga...@gmail.com>
Authored: Thu Aug 31 15:01:24 2017 -0600
Committer: Gary Gregory <ga...@gmail.com>
Committed: Thu Aug 31 15:01:24 2017 -0600

----------------------------------------------------------------------
 .../apache/logging/log4j/LogManagerTest.java    | 49 ++++++++++++++------
 1 file changed, 34 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e67bf824/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
index 2f898ba..a3164d1 100644
--- a/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
+++ b/log4j-api/src/test/java/org/apache/logging/log4j/LogManagerTest.java
@@ -16,27 +16,36 @@
  */
 package org.apache.logging.log4j;
 
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.Closeable;
+import java.io.IOException;
+
 import org.apache.logging.log4j.message.ParameterizedMessageFactory;
 import org.apache.logging.log4j.spi.LoggerContext;
 import org.junit.Assert;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
-
-import java.io.Closeable;
-import java.io.IOException;
-
 /**
  *
  */
 public class LogManagerTest {
 
-    static class InnerClass {
-        final static Logger LOGGER = LogManager.getLogger(InnerClass.class);
+    class Inner {
+        final Logger LOGGER = LogManager.getLogger();
+    }
+    
+    class InnerByClass {
+        final Logger LOGGER = LogManager.getLogger(InnerByClass.class);
+    }
+    
+    static class StaticInner {
+        final static Logger LOGGER = LogManager.getLogger();
     }
     
-    static class StaticInnerClass {
-        final static Logger LOGGER = LogManager.getLogger(StaticInnerClass.class);
+    static class StaticInnerByClass {
+        final static Logger LOGGER = LogManager.getLogger(StaticInnerByClass.class);
     }
     
     @Test
@@ -69,7 +78,7 @@ public class LogManagerTest {
 
     @Test
     public void testGetLoggerForAnonymousInnerClass1() throws IOException {
-        Closeable closeable = new Closeable() {
+        final Closeable closeable = new Closeable() {
             
             Logger LOGGER = LogManager.getLogger();
             
@@ -83,7 +92,7 @@ public class LogManagerTest {
 
     @Test
     public void testGetLoggerForAnonymousInnerClass2() throws IOException {
-        Closeable closeable = new Closeable() {
+        final Closeable closeable = new Closeable() {
             
             Logger LOGGER = LogManager.getLogger(getClass());
             
@@ -96,13 +105,23 @@ public class LogManagerTest {
     }
 
     @Test
-    public void testGetLoggerForInnerClass() {
-        Assert.assertEquals("org.apache.logging.log4j.LogManagerTest.InnerClass", InnerClass.LOGGER.getName());
+    public void testGetLoggerForInner() {
+        Assert.assertEquals("org.apache.logging.log4j.LogManagerTest.Inner", new Inner().LOGGER.getName());
+    }
+
+    @Test
+    public void testGetLoggerForInnerByClass() {
+        Assert.assertEquals("org.apache.logging.log4j.LogManagerTest.InnerByClass", new InnerByClass().LOGGER.getName());
+    }
+
+    @Test
+    public void testGetLoggerForStaticInner() {
+        Assert.assertEquals("org.apache.logging.log4j.LogManagerTest.StaticInner", StaticInner.LOGGER.getName());
     }
 
     @Test
-    public void testGetLoggerForStaticInnerClass() {
-        Assert.assertEquals("org.apache.logging.log4j.LogManagerTest.StaticInnerClass", StaticInnerClass.LOGGER.getName());
+    public void testGetLoggerForStaticInnerByClass() {
+        Assert.assertEquals("org.apache.logging.log4j.LogManagerTest.StaticInnerByClass", StaticInnerByClass.LOGGER.getName());
     }
 
     @Test