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 2017/01/07 23:29:05 UTC

[2/4] logging-log4j2 git commit: [LOG4J2-1774]: Refactor RoutingAppenderWithJndiTest to use JndiRule

[LOG4J2-1774]: Refactor RoutingAppenderWithJndiTest to use JndiRule


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

Branch: refs/heads/master
Commit: 3c7a91fd119348ccba3c78313302c609122ed53f
Parents: b1cabb9
Author: Matt Sicker <ma...@spr.com>
Authored: Sat Jan 7 16:38:51 2017 -0600
Committer: Matt Sicker <ma...@spr.com>
Committed: Sat Jan 7 16:38:51 2017 -0600

----------------------------------------------------------------------
 .../routing/RoutingAppenderWithJndiTest.java       | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3c7a91fd/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithJndiTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithJndiTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithJndiTest.java
index 71ebb67..02a8a79 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithJndiTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/RoutingAppenderWithJndiTest.java
@@ -16,16 +16,14 @@
  */
 package org.apache.logging.log4j.core.appender.routing;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
 import java.io.File;
-
+import java.util.Collections;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
 import org.apache.logging.log4j.EventLogger;
+import org.apache.logging.log4j.junit.JndiRule;
 import org.apache.logging.log4j.junit.LoggerContextRule;
 import org.apache.logging.log4j.message.StructuredDataMessage;
 import org.apache.logging.log4j.test.appender.ListAppender;
@@ -33,7 +31,9 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Test;
-import org.mockejb.jndi.MockContextFactory;
+import org.junit.rules.RuleChain;
+
+import static org.junit.Assert.*;
 
 /**
  * RoutingAppenderWithJndiTest
@@ -44,12 +44,14 @@ public class RoutingAppenderWithJndiTest {
     private ListAppender listAppender1;
     private ListAppender listAppender2;
 
-    @ClassRule
     public static LoggerContextRule loggerContextRule = new LoggerContextRule("log4j-routing-by-jndi.xml");
 
+    @ClassRule
+    public static RuleChain rules = RuleChain.outerRule(new JndiRule(Collections.<String, Object>emptyMap()))
+        .around(loggerContextRule);
+
     @Before
     public void before() throws NamingException {
-        MockContextFactory.setAsInitial();
         listAppender1 = RoutingAppenderWithJndiTest.loggerContextRule.getListAppender("List1");
         listAppender2 = RoutingAppenderWithJndiTest.loggerContextRule.getListAppender("List2");
     }
@@ -58,7 +60,6 @@ public class RoutingAppenderWithJndiTest {
     public void after() {
         listAppender1.clear();
         listAppender2.clear();
-        MockContextFactory.revertSetAsInitial();
     }
 
     @Test