logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1504346 - in /logging/log4j/log4j2/trunk/core/src/test: java/org/apache/logging/log4j/core/appender/ resources/
Date Thu, 18 Jul 2013 02:18:30 GMT
Author: ggregory
Date: Thu Jul 18 02:18:29 2013
New Revision: 1504346

URL: http://svn.apache.org/r1504346
Log:
Clone test for async vs. sync appenders for XML layouts. Still trying to figure out why XmlCompactFileAsyncAppenderValidationTest
does not work.

Added:
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAsyncAppenderValidationTest.java
      - copied, changed from r1504299, logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAppenderValidationTest.java
    logging/log4j/log4j2/trunk/core/src/test/resources/XmlCompactFileAsyncAppenderValidationTest.xml
  (with props)
Modified:
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAppenderValidationTest.java
    logging/log4j/log4j2/trunk/core/src/test/resources/XmlCompactFileAppenderValidationTest.xml

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAppenderValidationTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAppenderValidationTest.java?rev=1504346&r1=1504345&r2=1504346&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAppenderValidationTest.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAppenderValidationTest.java
Thu Jul 18 02:18:29 2013
@@ -29,23 +29,44 @@ import javax.xml.validation.Validator;
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LifeCycle;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.Configurator;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 import org.xml.sax.SAXException;
 
 /**
  * Tests XML validation for a "compact" XML file, no extra spaces or end of lines.
  */
-@Ignore
 public class XmlCompactFileAppenderValidationTest {
 
-    @BeforeClass
-    public static void beforeClass() {
-        System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, 
-                "XmlCompactFileAppenderValidationTest.xml");
+    private LoggerContext loggerContext;
+
+    @Before
+    public void before() {
+        this.loggerContext = Configurator.initialize(XmlCompactFileAppenderValidationTest.class.getName(),
+                "target/test-classes/XmlCompactFileAppenderValidationTest.xml");
+    }
+
+    @After
+    public void after() {
+        // Just in case, an @Test blew up
+        Configurator.shutdown(this.loggerContext);
+    }
+
+    @Test
+    public void validateXmlSchemaThrowable() throws Exception {
+        final File file = new File("target", "XmlCompactFileAppenderValidationTest.log.xml");
+        file.delete();
+        final Logger log = LogManager.getLogger("com.foo.Bar");
+        try {
+            throw new IllegalArgumentException("IAE");
+        } catch (final IllegalArgumentException e) {
+            log.warn("Message 1", e);
+        }
+        Configurator.shutdown(this.loggerContext);
+        this.validateXmlSchema(file);
     }
 
     @Test
@@ -56,7 +77,7 @@ public class XmlCompactFileAppenderValid
         log.warn("Message 1");
         log.info("Message 2");
         log.debug("Message 3");
-        ((LifeCycle) LogManager.getContext()).stop(); // stop async thread
+        Configurator.shutdown(this.loggerContext);
         this.validateXmlSchema(file);
     }
 
@@ -64,7 +85,7 @@ public class XmlCompactFileAppenderValid
     public void validateXmlNoEvents() throws Exception {
         final File file = new File("target", "XmlCompactFileAppenderValidationTest.log.xml");
         file.delete();
-        ((LifeCycle) LogManager.getContext()).stop(); // stop async thread
+        Configurator.shutdown(this.loggerContext);
         this.validateXmlSchema(file);
     }
 

Copied: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAsyncAppenderValidationTest.java
(from r1504299, logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAppenderValidationTest.java)
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAsyncAppenderValidationTest.java?p2=logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAsyncAppenderValidationTest.java&p1=logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAppenderValidationTest.java&r1=1504299&r2=1504346&rev=1504346&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAppenderValidationTest.java
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/XmlCompactFileAsyncAppenderValidationTest.java
Thu Jul 18 02:18:29 2013
@@ -40,17 +40,17 @@ import org.xml.sax.SAXException;
  * Tests XML validation for a "compact" XML file, no extra spaces or end of lines.
  */
 @Ignore
-public class XmlCompactFileAppenderValidationTest {
+public class XmlCompactFileAsyncAppenderValidationTest {
 
     @BeforeClass
     public static void beforeClass() {
-        System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, 
-                "XmlCompactFileAppenderValidationTest.xml");
+        System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
+                "XmlCompactFileAsyncAppenderValidationTest.xml");
     }
 
     @Test
-    public void validateXmlSchema() throws Exception {
-        final File file = new File("target", "XmlCompactFileAppenderValidationTest.log.xml");
+    public void validateXmlSchemaSimple() throws Exception {
+        final File file = new File("target", "XmlCompactFileAsyncAppenderValidationTest.log.xml");
         file.delete();
         final Logger log = LogManager.getLogger("com.foo.Bar");
         log.warn("Message 1");
@@ -61,8 +61,8 @@ public class XmlCompactFileAppenderValid
     }
 
     @Test
-    public void validateXmlNoEvents() throws Exception {
-        final File file = new File("target", "XmlCompactFileAppenderValidationTest.log.xml");
+    public void validateXmlSchemaNoEvents() throws Exception {
+        final File file = new File("target", "XmlCompactFileAsyncAppenderValidationTest.log.xml");
         file.delete();
         ((LifeCycle) LogManager.getContext()).stop(); // stop async thread
         this.validateXmlSchema(file);

Modified: logging/log4j/log4j2/trunk/core/src/test/resources/XmlCompactFileAppenderValidationTest.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/resources/XmlCompactFileAppenderValidationTest.xml?rev=1504346&r1=1504345&r2=1504346&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/resources/XmlCompactFileAppenderValidationTest.xml
(original)
+++ logging/log4j/log4j2/trunk/core/src/test/resources/XmlCompactFileAppenderValidationTest.xml
Thu Jul 18 02:18:29 2013
@@ -7,8 +7,8 @@
   </Appenders>
   
   <Loggers>
-    <AsyncRoot level="info" includeLocation="false">
+    <Root level="info" includeLocation="false">
       <appender-ref ref="XmlFile"/>
-    </AsyncRoot>
+    </Root>
   </Loggers>
 </Configuration>

Added: logging/log4j/log4j2/trunk/core/src/test/resources/XmlCompactFileAsyncAppenderValidationTest.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/resources/XmlCompactFileAsyncAppenderValidationTest.xml?rev=1504346&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/resources/XmlCompactFileAsyncAppenderValidationTest.xml
(added)
+++ logging/log4j/log4j2/trunk/core/src/test/resources/XmlCompactFileAsyncAppenderValidationTest.xml
Thu Jul 18 02:18:29 2013
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="OFF">
+  <Appenders>
+    <File name="XmlFile" fileName="target/XmlCompactFileAsyncAppenderValidationTest.log.xml"
immediateFlush="false" append="false">
+      <XMLLayout complete="true" compact="true" charset="UTF-8"/>
+    </File>
+  </Appenders>
+  
+  <Loggers>
+    <AsyncRoot level="info" includeLocation="false">
+      <appender-ref ref="XmlFile"/>
+    </AsyncRoot>
+  </Loggers>
+</Configuration>

Propchange: logging/log4j/log4j2/trunk/core/src/test/resources/XmlCompactFileAsyncAppenderValidationTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/log4j2/trunk/core/src/test/resources/XmlCompactFileAsyncAppenderValidationTest.xml
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message