logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1582171 - in /logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling: AbstractRollingAppenderSizeTest.java RollingAppenderSizeGzTest.java RollingAppenderSizeTest.java RollingAppenderSizeZipTest.java
Date Thu, 27 Mar 2014 03:29:45 GMT
Author: mattsicker
Date: Thu Mar 27 03:29:44 2014
New Revision: 1582171

URL: http://svn.apache.org/r1582171
Log:
Combine tests into a parametrised one.

Added:
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
      - copied, changed from r1582147, logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/AbstractRollingAppenderSizeTest.java
Removed:
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/AbstractRollingAppenderSizeTest.java
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeGzTest.java
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeZipTest.java

Copied: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
(from r1582147, logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/AbstractRollingAppenderSizeTest.java)
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java?p2=logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java&p1=logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/AbstractRollingAppenderSizeTest.java&r1=1582147&r2=1582171&rev=1582171&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/AbstractRollingAppenderSizeTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderSizeTest.java
Thu Mar 27 03:29:44 2014
@@ -19,45 +19,54 @@ package org.apache.logging.log4j.core.ap
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
 
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.AfterClass;
-import org.junit.Test;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.junit.*;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 
 /**
  *
  */
-public abstract class AbstractRollingAppenderSizeTest {
-
-    protected AbstractRollingAppenderSizeTest(String fileExtension) {
-        super();
-        this.fileExtension = fileExtension;
-    }
+@RunWith(Parameterized.class)
+public class RollingAppenderSizeTest {
 
     private static final String DIR = "target/rolling1";
-    
+
     private final String fileExtension;
 
-    org.apache.logging.log4j.Logger logger = LogManager.getLogger(AbstractRollingAppenderSizeTest.class.getName());
+    private Logger logger;
+
+    @Parameterized.Parameters
+    public static Collection<Object[]> data() {
+        return Arrays.asList(
+                new Object[][]{
+                        { "log4j-rolling-gz.xml", ".gz" },
+                        { "log4j-rolling-zip.xml", ".zip" }
+                }
+        );
+    }
+
+    @Rule
+    public InitialLoggerContext init;
+
+    public RollingAppenderSizeTest(final String configFile, final String fileExtension) {
+        this.fileExtension = fileExtension;
+        this.init = new InitialLoggerContext(configFile);
+    }
 
-    protected static void setupClass(String configPath) {
+    @Before
+    public void setUp() throws Exception {
         deleteDir();
-        System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, configPath);
-        final LoggerContext ctx = (LoggerContext) LogManager.getContext();
-        final Configuration config = ctx.getConfiguration();
+        this.logger = this.init.getLogger(RollingAppenderSizeTest.class.getName());
     }
 
-    @AfterClass
-    public static void cleanupClass() {
+    @After
+    public void tearDown() throws Exception {
         deleteDir();
-        System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
-        final LoggerContext ctx = (LoggerContext) LogManager.getContext();
-        ctx.reconfigure();
-        StatusLogger.getLogger().reset();
     }
 
     @Test



Mime
View raw message