You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/05/21 07:18:01 UTC

svn commit: r1596465 - /logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/PerformanceRun.java

Author: mattsicker
Date: Wed May 21 05:18:01 2014
New Revision: 1596465

URL: http://svn.apache.org/r1596465
Log:
Refactor test to use InitialLoggerContext.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/PerformanceRun.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/PerformanceRun.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/PerformanceRun.java?rev=1596465&r1=1596464&r2=1596465&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/PerformanceRun.java (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/PerformanceRun.java Wed May 21 05:18:01 2014
@@ -25,9 +25,8 @@ import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 
 import org.apache.logging.log4j.categories.PerformanceTests;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.junit.ClassRule;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -42,22 +41,15 @@ import org.junit.experimental.categories
 @Category(PerformanceTests.class)
 public class PerformanceRun {
 
-    private final Logger logger = LogManager.getLogger(PerformanceRun.class.getName());
-
-    // How many times should we try to log:
-    private static final int COUNT = 1000000;
-
     private static final String CONFIG = "log4j2-perf.xml";
 
-    @BeforeClass
-    public static void setupClass() {
-        System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
-    }
+    @ClassRule
+    public static InitialLoggerContext context = new InitialLoggerContext(CONFIG);
 
-    @AfterClass
-    public static void cleanupClass() {
-        System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
-    }
+    private final Logger logger = context.getLogger(PerformanceRun.class.getName());
+
+    // How many times should we try to log:
+    private static final int COUNT = 1000000;
 
     @Test
     public void testPerformance() throws Exception {