You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by mi...@apache.org on 2016/06/12 11:55:22 UTC

[15/31] logging-log4j2 git commit: LOG4J2-1422 fix failing test

LOG4J2-1422 fix failing test


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/a5cd8c7b
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/a5cd8c7b
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/a5cd8c7b

Branch: refs/heads/LOG4J-1181
Commit: a5cd8c7bd6c49e6a91c2f85a528422b881e0b70c
Parents: 58105fd
Author: rpopma <rp...@apache.org>
Authored: Sat Jun 11 10:05:47 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Sat Jun 11 10:05:47 2016 +0900

----------------------------------------------------------------------
 .../AsyncAppenderQueueFullPolicyTest.java       | 22 ++++++--------------
 1 file changed, 6 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a5cd8c7b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java
index 452bf72..3888acf 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java
@@ -46,15 +46,6 @@ import static org.junit.Assert.*;
  */
 public class AsyncAppenderQueueFullPolicyTest {
     private static final String CONFIG = "log4j-asynch-queue-full.xml";
-    static {
-        // this must be set before the Log4j context initializes
-        System.setProperty("log4j2.AsyncQueueFullPolicy", CountingAsyncQueueFullPolicy.class.getName());
-    }
-
-    @AfterClass
-    public static void afterClass() {
-        System.clearProperty("log4j2.AsyncQueueFullPolicy");
-    }
 
     @ClassRule
     public static LoggerContextRule context = new LoggerContextRule(CONFIG);
@@ -66,23 +57,22 @@ public class AsyncAppenderQueueFullPolicyTest {
     public void before() throws Exception {
         blockingAppender = (BlockingAppender) context.getAppender("Block");
         asyncAppender = (AsyncAppender) context.getAppender("Async");
+
+        Field field = AsyncAppender.class.getDeclaredField("asyncQueueFullPolicy");
+        field.setAccessible(true);
+        field.set(asyncAppender, new CountingAsyncQueueFullPolicy());
     }
 
     @After
     public void after() {
-//        blockingAppender.running = false;
+        blockingAppender.running = false;
+        CountingAsyncQueueFullPolicy.queueFull.set(0L);
     }
 
     @Test
     public void testRouter() throws Exception {
         final Logger logger = LogManager.getLogger(AsyncAppenderQueueFullPolicyTest.class);
 
-        Field field = AsyncAppender.class.getDeclaredField("asyncQueueFullPolicy");
-        field.setAccessible(true);
-        Object policy = field.get(asyncAppender);
-        assertEquals("CountingAsyncQueueFullPolicy installed correctly",
-                CountingAsyncQueueFullPolicy.class, policy.getClass());
-
         assertEquals(3, asyncAppender.getQueueCapacity());
         logger.error("event 1 - gets taken off the queue");
         logger.warn("event 2");