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:25:08 UTC

svn commit: r1596468 - /logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowableTest.java

Author: mattsicker
Date: Wed May 21 05:25:08 2014
New Revision: 1596468

URL: http://svn.apache.org/r1596468
Log:
Simplify test with newer ILC methods.

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

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowableTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowableTest.java?rev=1596468&r1=1596467&r2=1596468&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowableTest.java (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowableTest.java Wed May 21 05:25:08 2014
@@ -21,9 +21,8 @@ import java.util.List;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.junit.InitialLoggerContext;
 import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.After;
 import org.junit.Before;
-import org.junit.Rule;
+import org.junit.ClassRule;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
@@ -34,28 +33,23 @@ import static org.junit.Assert.*;
 public class ExtendedThrowableTest {
     private ListAppender app;
 
-    @Rule
-    public InitialLoggerContext init = new InitialLoggerContext("log4j-throwablefilter.xml");
+    @ClassRule
+    public static InitialLoggerContext context = new InitialLoggerContext("log4j-throwablefilter.xml");
 
     @Before
     public void setUp() throws Exception {
-        this.app = (ListAppender) this.init.getContext().getConfiguration().getAppenders().get("List");
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        this.app.clear();
+        this.app = context.getListAppender("List").clear();
     }
 
     @Test
     public void testException() {
-        final Logger logger = this.init.getContext().getLogger("LoggerTest");
+        final Logger logger = context.getLogger("LoggerTest");
         final Throwable cause = new NullPointerException("null pointer");
         final Throwable parent = new IllegalArgumentException("IllegalArgument", cause);
         logger.error("Exception", parent);
         final List<String> msgs = app.getMessages();
         assertNotNull(msgs);
-        assertEquals("Incorrect number of messages. Should be 1 is " + msgs.size(), msgs.size(), 1);
+        assertEquals("Incorrect number of messages. Should be 1 is " + msgs.size(), 1, msgs.size());
         assertTrue("No suppressed lines", msgs.get(0).contains("suppressed"));
     }
 }