timoninmaxim commented on code in PR #11615:
URL: https://github.com/apache/ignite/pull/11615#discussion_r1856850659


##########
modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java:
##########
@@ -17,39 +17,130 @@
 
 package org.apache.ignite.logger.java;
 
+import java.io.File;
 import java.util.UUID;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.logger.IgniteLoggerEx;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.apache.ignite.testframework.junits.common.GridCommonTest;
 import org.junit.Test;
 
-import static org.junit.Assert.assertTrue;
+import static org.apache.ignite.logger.java.JavaLogger.DFLT_CONFIG_PATH;
 
 /**
  * Java logger test.
  */
 @GridCommonTest(group = "Logger")
-public class JavaLoggerTest {
-    /** */
-    @SuppressWarnings({"FieldCanBeLocal"})
-    private IgniteLogger log;
+public class JavaLoggerTest extends GridCommonAbstractTest {
+    /**
+     * Path to jul configuration with DEBUG enabled.
+     */
+    private static final String LOG_CONFIG_DEBUG = 
"modules/core/src/test/config/jul-debug.properties";
+
+    /**
+     * Reset JavaLogger.
+     */
+    @Override protected void afterTest() throws Exception {
+        GridTestUtils.setFieldValue(JavaLogger.class, JavaLogger.class, 
"inited", false);
+    }
+
+    /**
+     * Check JavaLogger default constructor.
+     */
+    @Test
+    public void testDefaultConstructorWithDefaultConfig() {
+        IgniteLogger log1 = new JavaLogger();
+        IgniteLogger log2 = log1.getLogger(getClass());
+
+        assertTrue(log1.toString().contains("JavaLogger"));
+        assertTrue(log1.toString().contains(DFLT_CONFIG_PATH));
+
+        assertTrue(log2.toString().contains("JavaLogger"));
+        assertTrue(log2.toString().contains(DFLT_CONFIG_PATH));
+    }
+
+    /**
+     * Check non-configured constructor of JavaLogger.
+     */
+    @Test
+    public void testNotInitializedLogger() {
+        IgniteLogger log1 = new JavaLogger(Logger.getAnonymousLogger(), false);
+        assertTrue(log1.toString().contains("JavaLogger"));
+        assertTrue(log1.toString().contains("null"));
+
+        IgniteLogger log2 = log1.getLogger(getClass());
+        assertTrue(log2.toString().contains("JavaLogger"));
+        assertTrue(log2.toString().contains(DFLT_CONFIG_PATH));
+    }
+
+    /**
+     * Check JavaLogger constructor from java.util.logging.config.file 
property.
+     */
+    @Test
+    public void testDefaultConstructorWithProperty() throws Exception {
+        String cfgPathProp = "java.util.logging.config.file";
+        String oldPropVal = System.getProperty(cfgPathProp);
+        try {
+            File file = new File(U.getIgniteHome(), LOG_CONFIG_DEBUG);
+            System.setProperty(cfgPathProp, file.getPath());
+            // Call readConfiguration explicitly because Logger.getLogger was 
already called during IgniteUtils initialization.
+            LogManager.getLogManager().readConfiguration();
+
+            IgniteLogger log1 = new JavaLogger();
+            assertTrue(log1.toString().contains("JavaLogger"));
+            assertTrue(log1.toString().contains(LOG_CONFIG_DEBUG));
+            assertTrue(log1.isDebugEnabled());
+
+            IgniteLogger log2 = log1.getLogger(getClass());
+            assertTrue(log2.toString().contains("JavaLogger"));
+            assertTrue(log2.toString().contains(LOG_CONFIG_DEBUG));
+            assertTrue(log1.isDebugEnabled());

Review Comment:
   log2?



##########
modules/core/src/main/java/org/apache/ignite/logger/java/JavaLogger.java:
##########
@@ -214,13 +206,25 @@ public JavaLogger(final Logger impl, boolean configure) {
         quiet = quiet0;
     }
 
+    /**
+     * Creates new logger with given parameters.
+     *
+     * @param impl Java Logging implementation to use.
+     * @param cfg Path to configuration.
+     */
+    private JavaLogger(Logger impl, String cfg) {
+        this(impl, true);
+        if (cfg != null)

Review Comment:
   Please, add a blank line before this if



##########
modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java:
##########
@@ -17,39 +17,130 @@
 
 package org.apache.ignite.logger.java;
 
+import java.io.File;
 import java.util.UUID;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.logger.IgniteLoggerEx;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.apache.ignite.testframework.junits.common.GridCommonTest;
 import org.junit.Test;
 
-import static org.junit.Assert.assertTrue;
+import static org.apache.ignite.logger.java.JavaLogger.DFLT_CONFIG_PATH;
 
 /**
  * Java logger test.
  */
 @GridCommonTest(group = "Logger")
-public class JavaLoggerTest {
-    /** */
-    @SuppressWarnings({"FieldCanBeLocal"})
-    private IgniteLogger log;
+public class JavaLoggerTest extends GridCommonAbstractTest {
+    /**
+     * Path to jul configuration with DEBUG enabled.
+     */
+    private static final String LOG_CONFIG_DEBUG = 
"modules/core/src/test/config/jul-debug.properties";
+
+    /**
+     * Reset JavaLogger.
+     */
+    @Override protected void afterTest() throws Exception {
+        GridTestUtils.setFieldValue(JavaLogger.class, JavaLogger.class, 
"inited", false);
+    }
+
+    /**
+     * Check JavaLogger default constructor.
+     */
+    @Test
+    public void testDefaultConstructorWithDefaultConfig() {
+        IgniteLogger log1 = new JavaLogger();
+        IgniteLogger log2 = log1.getLogger(getClass());
+
+        assertTrue(log1.toString().contains("JavaLogger"));
+        assertTrue(log1.toString().contains(DFLT_CONFIG_PATH));
+
+        assertTrue(log2.toString().contains("JavaLogger"));
+        assertTrue(log2.toString().contains(DFLT_CONFIG_PATH));
+    }
+
+    /**
+     * Check non-configured constructor of JavaLogger.
+     */
+    @Test
+    public void testNotInitializedLogger() {
+        IgniteLogger log1 = new JavaLogger(Logger.getAnonymousLogger(), false);
+        assertTrue(log1.toString().contains("JavaLogger"));
+        assertTrue(log1.toString().contains("null"));
+
+        IgniteLogger log2 = log1.getLogger(getClass());
+        assertTrue(log2.toString().contains("JavaLogger"));
+        assertTrue(log2.toString().contains(DFLT_CONFIG_PATH));
+    }
+
+    /**
+     * Check JavaLogger constructor from java.util.logging.config.file 
property.
+     */
+    @Test
+    public void testDefaultConstructorWithProperty() throws Exception {
+        String cfgPathProp = "java.util.logging.config.file";
+        String oldPropVal = System.getProperty(cfgPathProp);
+        try {
+            File file = new File(U.getIgniteHome(), LOG_CONFIG_DEBUG);
+            System.setProperty(cfgPathProp, file.getPath());
+            // Call readConfiguration explicitly because Logger.getLogger was 
already called during IgniteUtils initialization.
+            LogManager.getLogManager().readConfiguration();
+
+            IgniteLogger log1 = new JavaLogger();
+            assertTrue(log1.toString().contains("JavaLogger"));
+            assertTrue(log1.toString().contains(LOG_CONFIG_DEBUG));
+            assertTrue(log1.isDebugEnabled());
+
+            IgniteLogger log2 = log1.getLogger(getClass());
+            assertTrue(log2.toString().contains("JavaLogger"));
+            assertTrue(log2.toString().contains(LOG_CONFIG_DEBUG));
+            assertTrue(log1.isDebugEnabled());
+        }
+        finally {
+            if (oldPropVal == null)
+                System.clearProperty(cfgPathProp);
+            else
+                System.setProperty(cfgPathProp, oldPropVal);
+        }
+    }
+
+    /**
+     * Check Grid logging.
+     */
+    @Test
+    public void testGridLoggingWithDefaultLogger() throws Exception {
+        LogListener lsn = LogListener.matches("JavaLogger [quiet=true,")
+            .andMatches(DFLT_CONFIG_PATH)
+            .build();
+        ListeningTestLogger log = new ListeningTestLogger(new JavaLogger(), 
lsn);
+
+        IgniteConfiguration cfg = 
getConfiguration(getTestIgniteInstanceName());
+        cfg.setGridLogger(log);
+        try (Ignite ign = startGrid(cfg)) {

Review Comment:
   Add a blank line before this line



##########
modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java:
##########
@@ -17,39 +17,130 @@
 
 package org.apache.ignite.logger.java;
 
+import java.io.File;
 import java.util.UUID;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.logger.IgniteLoggerEx;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.apache.ignite.testframework.junits.common.GridCommonTest;
 import org.junit.Test;
 
-import static org.junit.Assert.assertTrue;
+import static org.apache.ignite.logger.java.JavaLogger.DFLT_CONFIG_PATH;
 
 /**
  * Java logger test.
  */
 @GridCommonTest(group = "Logger")
-public class JavaLoggerTest {
-    /** */
-    @SuppressWarnings({"FieldCanBeLocal"})
-    private IgniteLogger log;
+public class JavaLoggerTest extends GridCommonAbstractTest {
+    /**
+     * Path to jul configuration with DEBUG enabled.
+     */
+    private static final String LOG_CONFIG_DEBUG = 
"modules/core/src/test/config/jul-debug.properties";
+
+    /**
+     * Reset JavaLogger.
+     */
+    @Override protected void afterTest() throws Exception {
+        GridTestUtils.setFieldValue(JavaLogger.class, JavaLogger.class, 
"inited", false);
+    }
+
+    /**
+     * Check JavaLogger default constructor.
+     */
+    @Test
+    public void testDefaultConstructorWithDefaultConfig() {
+        IgniteLogger log1 = new JavaLogger();
+        IgniteLogger log2 = log1.getLogger(getClass());
+
+        assertTrue(log1.toString().contains("JavaLogger"));
+        assertTrue(log1.toString().contains(DFLT_CONFIG_PATH));
+
+        assertTrue(log2.toString().contains("JavaLogger"));
+        assertTrue(log2.toString().contains(DFLT_CONFIG_PATH));
+    }
+
+    /**
+     * Check non-configured constructor of JavaLogger.
+     */
+    @Test
+    public void testNotInitializedLogger() {
+        IgniteLogger log1 = new JavaLogger(Logger.getAnonymousLogger(), false);
+        assertTrue(log1.toString().contains("JavaLogger"));
+        assertTrue(log1.toString().contains("null"));
+
+        IgniteLogger log2 = log1.getLogger(getClass());
+        assertTrue(log2.toString().contains("JavaLogger"));
+        assertTrue(log2.toString().contains(DFLT_CONFIG_PATH));
+    }
+
+    /**
+     * Check JavaLogger constructor from java.util.logging.config.file 
property.
+     */
+    @Test
+    public void testDefaultConstructorWithProperty() throws Exception {
+        String cfgPathProp = "java.util.logging.config.file";
+        String oldPropVal = System.getProperty(cfgPathProp);
+        try {
+            File file = new File(U.getIgniteHome(), LOG_CONFIG_DEBUG);
+            System.setProperty(cfgPathProp, file.getPath());
+            // Call readConfiguration explicitly because Logger.getLogger was 
already called during IgniteUtils initialization.
+            LogManager.getLogManager().readConfiguration();
+
+            IgniteLogger log1 = new JavaLogger();
+            assertTrue(log1.toString().contains("JavaLogger"));
+            assertTrue(log1.toString().contains(LOG_CONFIG_DEBUG));
+            assertTrue(log1.isDebugEnabled());
+
+            IgniteLogger log2 = log1.getLogger(getClass());
+            assertTrue(log2.toString().contains("JavaLogger"));
+            assertTrue(log2.toString().contains(LOG_CONFIG_DEBUG));
+            assertTrue(log1.isDebugEnabled());
+        }
+        finally {
+            if (oldPropVal == null)
+                System.clearProperty(cfgPathProp);
+            else
+                System.setProperty(cfgPathProp, oldPropVal);
+        }
+    }
+
+    /**
+     * Check Grid logging.
+     */
+    @Test
+    public void testGridLoggingWithDefaultLogger() throws Exception {
+        LogListener lsn = LogListener.matches("JavaLogger [quiet=true,")
+            .andMatches(DFLT_CONFIG_PATH)
+            .build();
+        ListeningTestLogger log = new ListeningTestLogger(new JavaLogger(), 
lsn);

Review Comment:
   Add a blank line before this line



##########
modules/core/src/test/java/org/apache/ignite/testframework/junits/logger/GridTestLog4jLoggerSelfTest.java:
##########
@@ -17,81 +17,156 @@
 
 package org.apache.ignite.testframework.junits.logger;
 
+import java.io.File;
+import java.net.URL;
+import java.util.UUID;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.logger.IgniteLoggerEx;
 import org.apache.ignite.internal.util.lang.RunnableX;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.Configurator;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 
 import static java.lang.String.format;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 /**
  * Checks that assertion error will be thrown, if logging for the level 
disabled and log message on this level was invoked.
  */
 @RunWith(JUnit4.class)
 public class GridTestLog4jLoggerSelfTest {
+    /** Path to test configuration. */
+    private static final String LOG_PATH_TEST = 
"modules/log4j2/src/test/config/log4j2-test.xml";
+
     /** Logger message. */
     private static final String LOG_MESSAGE = "TEST MESSAGE";
 
     /** Assertion message formatter. */
     private static final String ASSERTION_FORMAT_MSG = "Logging at %s level 
without checking if %s level is enabled: " + LOG_MESSAGE;
 
-    /** Logger. */
-    private static final GridTestLog4jLogger LOGGER = new 
GridTestLog4jLogger();
-
     /** Default root level. */
     private static final Level defaultRootLevel = 
LogManager.getRootLogger().getLevel();
 
     /** */
-    @BeforeClass
-    public static void beforeTests() {
+    @Before
+    public void beforeTest() {
+        System.clearProperty("appId");
+        LogManager.shutdown();
+        GridTestUtils.setFieldValue(GridTestLog4jLogger.class, 
GridTestLog4jLogger.class, "inited", false);
         Configurator.setRootLevel(Level.WARN);
     }
 
     /** */
-    @AfterClass
-    public static void afterTests() {
+    @After
+    public void afterTest() {
         Configurator.setRootLevel(defaultRootLevel);
-
         assertEquals(defaultRootLevel, 
LoggerContext.getContext(false).getConfiguration().getRootLogger().getLevel());
     }
 
+    /** */
+    @Test
+    public void testFileConstructor() throws Exception {
+        File xml = GridTestUtils.resolveIgnitePath(LOG_PATH_TEST);
+
+        assert xml != null;
+
+        IgniteLoggerEx log = new 
GridTestLog4jLogger(xml).getLogger(getClass());
+
+        assertTrue(log.toString().contains("GridTestLog4jLogger"));
+        assertTrue(log.toString().contains(xml.getPath()));
+
+        log.setApplicationAndNode(null, UUID.randomUUID());

Review Comment:
   Why do you need it?



##########
modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java:
##########
@@ -17,39 +17,130 @@
 
 package org.apache.ignite.logger.java;
 
+import java.io.File;
 import java.util.UUID;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.logger.IgniteLoggerEx;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.apache.ignite.testframework.junits.common.GridCommonTest;
 import org.junit.Test;
 
-import static org.junit.Assert.assertTrue;
+import static org.apache.ignite.logger.java.JavaLogger.DFLT_CONFIG_PATH;
 
 /**
  * Java logger test.
  */
 @GridCommonTest(group = "Logger")
-public class JavaLoggerTest {
-    /** */
-    @SuppressWarnings({"FieldCanBeLocal"})
-    private IgniteLogger log;
+public class JavaLoggerTest extends GridCommonAbstractTest {
+    /**
+     * Path to jul configuration with DEBUG enabled.
+     */
+    private static final String LOG_CONFIG_DEBUG = 
"modules/core/src/test/config/jul-debug.properties";
+
+    /**
+     * Reset JavaLogger.
+     */
+    @Override protected void afterTest() throws Exception {
+        GridTestUtils.setFieldValue(JavaLogger.class, JavaLogger.class, 
"inited", false);
+    }
+
+    /**
+     * Check JavaLogger default constructor.
+     */
+    @Test
+    public void testDefaultConstructorWithDefaultConfig() {
+        IgniteLogger log1 = new JavaLogger();
+        IgniteLogger log2 = log1.getLogger(getClass());
+
+        assertTrue(log1.toString().contains("JavaLogger"));
+        assertTrue(log1.toString().contains(DFLT_CONFIG_PATH));
+
+        assertTrue(log2.toString().contains("JavaLogger"));
+        assertTrue(log2.toString().contains(DFLT_CONFIG_PATH));
+    }
+
+    /**
+     * Check non-configured constructor of JavaLogger.
+     */
+    @Test
+    public void testNotInitializedLogger() {
+        IgniteLogger log1 = new JavaLogger(Logger.getAnonymousLogger(), false);
+        assertTrue(log1.toString().contains("JavaLogger"));
+        assertTrue(log1.toString().contains("null"));
+
+        IgniteLogger log2 = log1.getLogger(getClass());
+        assertTrue(log2.toString().contains("JavaLogger"));
+        assertTrue(log2.toString().contains(DFLT_CONFIG_PATH));
+    }
+
+    /**
+     * Check JavaLogger constructor from java.util.logging.config.file 
property.
+     */
+    @Test
+    public void testDefaultConstructorWithProperty() throws Exception {
+        String cfgPathProp = "java.util.logging.config.file";
+        String oldPropVal = System.getProperty(cfgPathProp);
+        try {
+            File file = new File(U.getIgniteHome(), LOG_CONFIG_DEBUG);
+            System.setProperty(cfgPathProp, file.getPath());
+            // Call readConfiguration explicitly because Logger.getLogger was 
already called during IgniteUtils initialization.
+            LogManager.getLogManager().readConfiguration();
+
+            IgniteLogger log1 = new JavaLogger();
+            assertTrue(log1.toString().contains("JavaLogger"));
+            assertTrue(log1.toString().contains(LOG_CONFIG_DEBUG));
+            assertTrue(log1.isDebugEnabled());
+
+            IgniteLogger log2 = log1.getLogger(getClass());
+            assertTrue(log2.toString().contains("JavaLogger"));
+            assertTrue(log2.toString().contains(LOG_CONFIG_DEBUG));
+            assertTrue(log1.isDebugEnabled());
+        }
+        finally {
+            if (oldPropVal == null)
+                System.clearProperty(cfgPathProp);
+            else
+                System.setProperty(cfgPathProp, oldPropVal);
+        }
+    }
+
+    /**
+     * Check Grid logging.
+     */
+    @Test
+    public void testGridLoggingWithDefaultLogger() throws Exception {
+        LogListener lsn = LogListener.matches("JavaLogger [quiet=true,")
+            .andMatches(DFLT_CONFIG_PATH)
+            .build();
+        ListeningTestLogger log = new ListeningTestLogger(new JavaLogger(), 
lsn);
+
+        IgniteConfiguration cfg = 
getConfiguration(getTestIgniteInstanceName());
+        cfg.setGridLogger(log);
+        try (Ignite ign = startGrid(cfg)) {

Review Comment:
   Name ign -> ignore, to avoid a warning about unused variable in IDEA



##########
modules/core/src/test/java/org/apache/ignite/testframework/junits/logger/GridTestLog4jLoggerSelfTest.java:
##########
@@ -17,81 +17,156 @@
 
 package org.apache.ignite.testframework.junits.logger;
 
+import java.io.File;
+import java.net.URL;
+import java.util.UUID;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.logger.IgniteLoggerEx;
 import org.apache.ignite.internal.util.lang.RunnableX;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.Configurator;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 
 import static java.lang.String.format;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 /**
  * Checks that assertion error will be thrown, if logging for the level 
disabled and log message on this level was invoked.
  */
 @RunWith(JUnit4.class)
 public class GridTestLog4jLoggerSelfTest {
+    /** Path to test configuration. */
+    private static final String LOG_PATH_TEST = 
"modules/log4j2/src/test/config/log4j2-test.xml";
+
     /** Logger message. */
     private static final String LOG_MESSAGE = "TEST MESSAGE";
 
     /** Assertion message formatter. */
     private static final String ASSERTION_FORMAT_MSG = "Logging at %s level 
without checking if %s level is enabled: " + LOG_MESSAGE;
 
-    /** Logger. */
-    private static final GridTestLog4jLogger LOGGER = new 
GridTestLog4jLogger();
-
     /** Default root level. */
     private static final Level defaultRootLevel = 
LogManager.getRootLogger().getLevel();
 
     /** */
-    @BeforeClass
-    public static void beforeTests() {
+    @Before
+    public void beforeTest() {
+        System.clearProperty("appId");
+        LogManager.shutdown();
+        GridTestUtils.setFieldValue(GridTestLog4jLogger.class, 
GridTestLog4jLogger.class, "inited", false);
         Configurator.setRootLevel(Level.WARN);
     }
 
     /** */
-    @AfterClass
-    public static void afterTests() {
+    @After
+    public void afterTest() {
         Configurator.setRootLevel(defaultRootLevel);
-

Review Comment:
   Please, return a blank line



##########
modules/core/src/test/java/org/apache/ignite/logger/java/JavaLoggerTest.java:
##########
@@ -17,39 +17,130 @@
 
 package org.apache.ignite.logger.java;
 
+import java.io.File;
 import java.util.UUID;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.logger.IgniteLoggerEx;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.apache.ignite.testframework.junits.common.GridCommonTest;
 import org.junit.Test;
 
-import static org.junit.Assert.assertTrue;
+import static org.apache.ignite.logger.java.JavaLogger.DFLT_CONFIG_PATH;
 
 /**
  * Java logger test.
  */
 @GridCommonTest(group = "Logger")
-public class JavaLoggerTest {
-    /** */
-    @SuppressWarnings({"FieldCanBeLocal"})
-    private IgniteLogger log;
+public class JavaLoggerTest extends GridCommonAbstractTest {
+    /**
+     * Path to jul configuration with DEBUG enabled.
+     */
+    private static final String LOG_CONFIG_DEBUG = 
"modules/core/src/test/config/jul-debug.properties";
+
+    /**
+     * Reset JavaLogger.
+     */
+    @Override protected void afterTest() throws Exception {
+        GridTestUtils.setFieldValue(JavaLogger.class, JavaLogger.class, 
"inited", false);
+    }
+
+    /**
+     * Check JavaLogger default constructor.
+     */
+    @Test
+    public void testDefaultConstructorWithDefaultConfig() {
+        IgniteLogger log1 = new JavaLogger();
+        IgniteLogger log2 = log1.getLogger(getClass());
+
+        assertTrue(log1.toString().contains("JavaLogger"));
+        assertTrue(log1.toString().contains(DFLT_CONFIG_PATH));
+
+        assertTrue(log2.toString().contains("JavaLogger"));
+        assertTrue(log2.toString().contains(DFLT_CONFIG_PATH));
+    }
+
+    /**
+     * Check non-configured constructor of JavaLogger.
+     */
+    @Test
+    public void testNotInitializedLogger() {
+        IgniteLogger log1 = new JavaLogger(Logger.getAnonymousLogger(), false);
+        assertTrue(log1.toString().contains("JavaLogger"));
+        assertTrue(log1.toString().contains("null"));
+
+        IgniteLogger log2 = log1.getLogger(getClass());
+        assertTrue(log2.toString().contains("JavaLogger"));
+        assertTrue(log2.toString().contains(DFLT_CONFIG_PATH));
+    }
+
+    /**
+     * Check JavaLogger constructor from java.util.logging.config.file 
property.
+     */
+    @Test
+    public void testDefaultConstructorWithProperty() throws Exception {
+        String cfgPathProp = "java.util.logging.config.file";
+        String oldPropVal = System.getProperty(cfgPathProp);
+        try {

Review Comment:
   Add a blank line before this line



##########
modules/core/src/test/java/org/apache/ignite/testframework/junits/logger/GridTestLog4jLoggerSelfTest.java:
##########
@@ -17,81 +17,156 @@
 
 package org.apache.ignite.testframework.junits.logger;
 
+import java.io.File;
+import java.net.URL;
+import java.util.UUID;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.logger.IgniteLoggerEx;
 import org.apache.ignite.internal.util.lang.RunnableX;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.Configurator;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 
 import static java.lang.String.format;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 /**
  * Checks that assertion error will be thrown, if logging for the level 
disabled and log message on this level was invoked.
  */
 @RunWith(JUnit4.class)
 public class GridTestLog4jLoggerSelfTest {
+    /** Path to test configuration. */
+    private static final String LOG_PATH_TEST = 
"modules/log4j2/src/test/config/log4j2-test.xml";
+
     /** Logger message. */
     private static final String LOG_MESSAGE = "TEST MESSAGE";
 
     /** Assertion message formatter. */
     private static final String ASSERTION_FORMAT_MSG = "Logging at %s level 
without checking if %s level is enabled: " + LOG_MESSAGE;
 
-    /** Logger. */
-    private static final GridTestLog4jLogger LOGGER = new 
GridTestLog4jLogger();
-
     /** Default root level. */
     private static final Level defaultRootLevel = 
LogManager.getRootLogger().getLevel();
 
     /** */
-    @BeforeClass
-    public static void beforeTests() {
+    @Before
+    public void beforeTest() {
+        System.clearProperty("appId");

Review Comment:
   make GridTestLog4jLogger#APP_ID package private and use this variable



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to