logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1137303 - in /logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test: java/org/apache/logging/log4j/core/ java/org/apache/logging/log4j/core/appender/ resources/
Date Sun, 19 Jun 2011 06:42:36 GMT
Author: rgoers
Date: Sun Jun 19 06:42:35 2011
New Revision: 1137303

URL: http://svn.apache.org/viewvc?rev=1137303&view=rev
Log:
Reduce the noise from tests

Modified:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/StrictXMLConfigTest.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/ListAppender.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling1.xml
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling2.xml
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling3.xml
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-strict1.xml
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-test1.xml
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-test2.xml

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java?rev=1137303&r1=1137302&r2=1137303&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
Sun Jun 19 06:42:35 2011
@@ -19,6 +19,7 @@ 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.core.appender.ListAppender;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
 import org.apache.logging.log4j.internal.StatusLogger;
@@ -28,7 +29,11 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 
 import java.util.Date;
+import java.util.List;
 import java.util.Locale;
+import java.util.Map;
+
+import static org.junit.Assert.assertTrue;
 
 /**
  *
@@ -36,12 +41,20 @@ import java.util.Locale;
 public class LoggerTest {
 
     private static final String CONFIG = "log4j-test2.xml";
+    private static Configuration config;
+    private static ListAppender app;
 
     @BeforeClass
     public static void setupClass() {
         System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
         LoggerContext ctx = (LoggerContext) LogManager.getContext();
-        Configuration config = ctx.getConfiguration();
+        config = ctx.getConfiguration();
+        for (Map.Entry<String, Appender> entry : config.getAppenders().entrySet())
{
+            if (entry.getKey().equals("List")) {
+                app = (ListAppender) entry.getValue();
+                break;
+            }
+        }
     }
 
     @AfterClass
@@ -58,17 +71,26 @@ public class LoggerTest {
     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
@@ -78,21 +100,33 @@ public class LoggerTest {
         } 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
@@ -102,6 +136,9 @@ public class LoggerTest {
         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
@@ -115,6 +152,9 @@ public class LoggerTest {
         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();
     }
 }
 

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/StrictXMLConfigTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/StrictXMLConfigTest.java?rev=1137303&r1=1137302&r2=1137303&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/StrictXMLConfigTest.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/StrictXMLConfigTest.java
Sun Jun 19 06:42:35 2011
@@ -19,6 +19,7 @@ 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.core.appender.ListAppender;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
 import org.apache.logging.log4j.internal.StatusLogger;
@@ -28,7 +29,12 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 
 import java.util.Date;
+import java.util.List;
 import java.util.Locale;
+import java.util.Map;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 /**
  *
@@ -36,12 +42,20 @@ import java.util.Locale;
 public class StrictXMLConfigTest {
 
     private static final String CONFIG = "log4j-strict1.xml";
+    private static Configuration config;
+    private static ListAppender app;
 
     @BeforeClass
     public static void setupClass() {
         System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
         LoggerContext ctx = (LoggerContext) LogManager.getContext();
-        Configuration config = ctx.getConfiguration();
+        config = ctx.getConfiguration();
+        for (Map.Entry<String, Appender> entry : config.getAppenders().entrySet())
{
+            if (entry.getKey().equals("List")) {
+                app = (ListAppender) entry.getValue();
+                break;
+            }
+        }
     }
 
     @AfterClass
@@ -58,17 +72,26 @@ public class StrictXMLConfigTest {
     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
@@ -78,21 +101,33 @@ public class StrictXMLConfigTest {
         } 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
@@ -102,6 +137,9 @@ public class StrictXMLConfigTest {
         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
@@ -115,6 +153,9 @@ public class StrictXMLConfigTest {
         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();
     }
 }
 

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/ListAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/ListAppender.java?rev=1137303&r1=1137302&r2=1137303&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/ListAppender.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/java/org/apache/logging/log4j/core/appender/ListAppender.java
Sun Jun 19 06:42:35 2011
@@ -125,6 +125,7 @@ public class ListAppender extends Append
     public synchronized void clear() {
         events.clear();
         messages.clear();
+        data.clear();
     }
 
     public synchronized List<LogEvent> getEvents() {

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling1.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling1.xml?rev=1137303&r1=1137302&r2=1137303&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling1.xml
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling1.xml
Sun Jun 19 06:42:35 2011
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<configuration packages="" status="debug" name="XMLConfigTest">
+<configuration packages="" status="warn" name="XMLConfigTest">
   <properties>
     <property name="filename">target/rolling1/rollingtest.log</property>
   </properties>

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling2.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling2.xml?rev=1137303&r1=1137302&r2=1137303&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling2.xml
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling2.xml
Sun Jun 19 06:42:35 2011
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<configuration packages="" status="debug" name="XMLConfigTest">
+<configuration packages="" status="warn" name="XMLConfigTest">
   <properties>
     <property name="filename">target/rolling2/rollingtest.log</property>
   </properties>

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling3.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling3.xml?rev=1137303&r1=1137302&r2=1137303&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling3.xml
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-rolling3.xml
Sun Jun 19 06:42:35 2011
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<configuration packages="" status="debug" name="XMLConfigTest">
+<configuration packages="" status="warn" name="XMLConfigTest">
   <properties>
     <property name="filename">target/rolling3/rollingtest.log</property>
   </properties>

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-strict1.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-strict1.xml?rev=1137303&r1=1137302&r2=1137303&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-strict1.xml
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-strict1.xml
Sun Jun 19 06:42:35 2011
@@ -28,9 +28,6 @@
       </layout>
     </appender>
     <appender type="List" name="List">
-      <filters>
-        <filter type="Threshold" level="error"/>
-      </filters>
     </appender>
   </appenders>
 
@@ -49,8 +46,7 @@
     </logger>>
 
     <root level="trace">
-      <appender-ref ref="STDOUT"/>
-      <appender-ref ref="FLOW"/>
+      <appender-ref ref="List"/>
     </root>
   </loggers>
 

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-test1.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-test1.xml?rev=1137303&r1=1137302&r2=1137303&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-test1.xml
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-test1.xml
Sun Jun 19 06:42:35 2011
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<configuration packages="" status="debug" name="XMLConfigTest">
+<configuration packages="" status="warn" name="XMLConfigTest">
   <properties>
     <property name="filename">target/test.log</property>
   </properties>

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-test2.xml
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-test2.xml?rev=1137303&r1=1137302&r2=1137303&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-test2.xml
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/test/resources/log4j-test2.xml
Sun Jun 19 06:42:35 2011
@@ -28,9 +28,6 @@
       </PatternLayout>
     </File>
     <List name="List">
-      <filters>
-        <Threshold level="error"/>
-      </filters>
     </List>
   </appenders>
 
@@ -49,8 +46,7 @@
     </logger>>
 
     <root level="trace">
-      <appender-ref ref="STDOUT"/>
-      <appender-ref ref="FLOW"/>
+      <appender-ref ref="List"/>
     </root>
   </loggers>
 



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message