logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1405304 - in /logging/log4j/log4j2/trunk/core/src/test: java/org/apache/logging/log4j/core/FileConfigTest.java resources/log4j-test2.xml
Date Sat, 03 Nov 2012 07:44:07 GMT
Author: rgoers
Date: Sat Nov  3 07:44:06 2012
New Revision: 1405304

URL: http://svn.apache.org/viewvc?rev=1405304&view=rev
Log:
Add test to validate configuring from a File not the classpath.

Added:
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/FileConfigTest.java
      - copied, changed from r1405298, logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
Modified:
    logging/log4j/log4j2/trunk/core/src/test/resources/log4j-test2.xml

Copied: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/FileConfigTest.java
(from r1405298, logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java)
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/FileConfigTest.java?p2=logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/FileConfigTest.java&p1=logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java&r1=1405298&r2=1405304&rev=1405304&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/FileConfigTest.java
Sat Nov  3 07:44:06 2012
@@ -19,11 +19,11 @@ package org.apache.logging.log4j.core;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.MarkerManager;
 import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.test.appender.ListAppender;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
 import org.apache.logging.log4j.message.StructuredDataMessage;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.test.appender.ListAppender;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -35,19 +35,21 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 /**
  *
  */
-public class LoggerTest {
+public class FileConfigTest {
 
-    private static final String CONFIG = "log4j-test2.xml";
+    private static final String CONFIG = "target/test-classes/log4j-test2.xml";
     private static Configuration config;
     private static ListAppender app;
     private static LoggerContext ctx;
 
+    private org.apache.logging.log4j.Logger logger = LogManager.getLogger("LoggerTest");
+
     @BeforeClass
     public static void setupClass() {
         System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
@@ -74,102 +76,9 @@ public class LoggerTest {
         app.clear();
     }
 
-
-    org.apache.logging.log4j.Logger logger = LogManager.getLogger("LoggerTest");
-
-    @Test
-    public void basicFlow() {
-        logger.entry();
-        logger.exit();
-        List<LogEvent> events = app.getEvents();
-        assertTrue("Incorrect number of events. Expected 2, actual " + events.size(), events.size()
== 2);
-        app.clear();
-    }
-
-    @Test
-    public void simpleFlow() {
-        logger.entry(CONFIG);
-        logger.exit(0);
-        List<LogEvent> events = app.getEvents();
-        assertTrue("Incorrect number of events. Expected 2, actual " + events.size(), events.size()
== 2);
-        app.clear();
-    }
-
-    @Test
-    public void throwing() {
-        logger.throwing(new IllegalArgumentException("Test Exception"));
-        List<LogEvent> events = app.getEvents();
-        assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size()
== 1);
-        app.clear();
-    }
-
-    @Test
-    public void catching() {
-        try {
-            throw new NullPointerException();
-        } catch (Exception e) {
-            logger.catching(e);
-        }
-        List<LogEvent> events = app.getEvents();
-        assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size()
== 1);
-        app.clear();
-    }
-
-    @Test
-    public void debug() {
-        logger.debug("Debug message");
-        List<LogEvent> events = app.getEvents();
-        assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size()
== 1);
-        app.clear();
-    }
-
-    @Test
-    public void debugObject() {
-        logger.debug(new Date());
-        List<LogEvent> events = app.getEvents();
-        assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size()
== 1);
-        app.clear();
-    }
-
-    @Test
-    public void debugWithParms() {
-        logger.debug("Hello, {}", "World");
-        List<LogEvent> events = app.getEvents();
-        assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size()
== 1);
-        app.clear();
-    }
-
-    @Test
-    public void mdc() {
-
-        ThreadContext.put("TestYear", new Integer(2010).toString());
-        logger.debug("Debug message");
-        ThreadContext.clear();
-        logger.debug("Debug message");
-        List<LogEvent> events = app.getEvents();
-        assertTrue("Incorrect number of events. Expected 2, actual " + events.size(), events.size()
== 2);
-        app.clear();
-    }
-
-    @Test
-    public void structuredData() {
-        ThreadContext.put("loginId", "JohnDoe");
-        ThreadContext.put("ipAddress", "192.168.0.120");
-        ThreadContext.put("locale", Locale.US.getDisplayName());
-        StructuredDataMessage msg = new StructuredDataMessage("Audit@18060", "Transfer Complete",
"Transfer");
-        msg.put("ToAccount", "123456");
-        msg.put("FromAccount", "123457");
-        msg.put("Amount", "200.00");
-        logger.info(MarkerManager.getMarker("EVENT"), msg);
-        ThreadContext.clear();
-        List<LogEvent> events = app.getEvents();
-        assertTrue("Incorrect number of events. Expected 1, actual " + events.size(), events.size()
== 1);
-        app.clear();
-    }
-
     @Test
     public void testReconfiguration() throws Exception {
-        File file = new File("target/test-classes/" + CONFIG);
+        File file = new File(CONFIG);
         long orig = file.lastModified();
         long newTime = orig + 10000;
         file.setLastModified(newTime);

Modified: logging/log4j/log4j2/trunk/core/src/test/resources/log4j-test2.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/resources/log4j-test2.xml?rev=1405304&r1=1405303&r2=1405304&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/resources/log4j-test2.xml (original)
+++ logging/log4j/log4j2/trunk/core/src/test/resources/log4j-test2.xml Sat Nov  3 07:44:06
2012
@@ -16,7 +16,7 @@
  limitations under the License.
 
 -->
-<configuration status="debug" name="XMLConfigTest" monitorInterval="5" packages="org.apache.logging.log4j.test">
+<configuration status="ERROR" name="XMLConfigTest" monitorInterval="5" packages="org.apache.logging.log4j.test">
   <properties>
     <property name="filename">target/test.log</property>
   </properties>



Mime
View raw message