logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1599428 - in /logging/log4j/log4j2/trunk: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/ log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/ log4j-core/src/main/java/org/apache/logging/log4j/c...
Date Tue, 03 Jun 2014 06:54:40 GMT
Author: ggregory
Date: Tue Jun  3 06:54:39 2014
New Revision: 1599428

URL: http://svn.apache.org/r1599428
Log:
Refactor duplicate code with the help of a new Core API org.apache.logging.log4j.core.config.Configuration.getAppender(String).

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppender.java
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderTest.java
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderTest.java
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/AbstractJpaAppenderTest.java
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/JsonRoutingAppender2Test.java
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/JsonRoutingAppenderTest.java
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/MapFilterTest.java
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/net/jms/JmsQueueFailoverTest.java
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/net/jms/JmsTopicFailoverTest.java
    logging/log4j/log4j2/trunk/log4j-jcl/src/test/java/org/apache/logging/log4j/jcl/LoggerTest.java
    logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
    logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OptionalTest.java
    logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/CatchingTagTest.java
    logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/EntryTagTest.java
    logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/ExitTagTest.java
    logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupportTest.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppender.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppender.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rewrite/RewriteAppender.java
Tue Jun  3 06:54:39 2014
@@ -55,10 +55,9 @@ public final class RewriteAppender exten
 
     @Override
     public void start() {
-        final Map<String, Appender> map = config.getAppenders();
         for (final AppenderRef ref : appenderRefs) {
             final String name = ref.getRef();
-            final Appender appender = map.get(name);
+            final Appender appender = config.getAppender(name);
             if (appender != null) {
                 final Filter filter = appender instanceof AbstractAppender ?
                     ((AbstractAppender) appender).getFilter() : null;

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/RoutingAppender.java
Tue Jun  3 06:54:39 2014
@@ -74,11 +74,10 @@ public final class RoutingAppender exten
 
     @Override
     public void start() {
-        final Map<String, Appender> map = config.getAppenders();
         // Register all the static routes.
         for (final Route route : routes.getRoutes()) {
             if (route.getAppenderRef() != null) {
-                final Appender appender = map.get(route.getAppenderRef());
+                final Appender appender = config.getAppender(route.getAppenderRef());
                 if (appender != null) {
                     final String key = route == defaultRoute ? DEFAULT_KEY : route.getKey();
                     appenders.put(key, new AppenderControl(appender, null, null));

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
Tue Jun  3 06:54:39 2014
@@ -434,6 +434,7 @@ public abstract class AbstractConfigurat
      * @param name The name of the Appender.
      * @return the Appender with the specified name or null if the Appender cannot be located.
      */
+    @Override
     public Appender getAppender(final String name) {
         return appenders.get(name);
     }
@@ -777,4 +778,5 @@ public abstract class AbstractConfigurat
 
         return buffer.toByteArray();
     }
+
 }

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java
Tue Jun  3 06:54:39 2014
@@ -49,6 +49,13 @@ public interface Configuration extends F
     LoggerConfig getLoggerConfig(String name);
 
     /**
+     * Returns the Appender with the specified name.
+     * @param name The name of the Appender.
+     * @return the Appender with the specified name or null if the Appender cannot be located.
+     */
+    Appender getAppender(String name);
+
+    /**
      * Returns a Map containing all the Appenders and their name.
      * @return A Map containing each Appender's name and the Appender object.
      */

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderTest.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderTest.java
Tue Jun  3 06:54:39 2014
@@ -41,7 +41,7 @@ import static org.junit.Assert.*;
 public class AsyncAppenderTest {
     private static final String CONFIG = "log4j-asynch.xml";
     private static Configuration config;
-    private static ListAppender app;
+    private static ListAppender listAppender;
     private static LoggerContext ctx;
 
     @BeforeClass
@@ -49,12 +49,7 @@ public class AsyncAppenderTest {
         System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
         ctx = (LoggerContext) LogManager.getContext(false);
         config = ctx.getConfiguration();
-        for (final Map.Entry<String, Appender> entry : config.getAppenders().entrySet())
{
-            if (entry.getKey().equals("List")) {
-                app = (ListAppender) entry.getValue();
-                break;
-            }
-        }
+        listAppender = (ListAppender) config.getAppender("List");
     }
 
     @AfterClass
@@ -66,7 +61,7 @@ public class AsyncAppenderTest {
 
     @After
     public void after() {
-        app.clear();
+        listAppender.clear();
     }
 
     @Test
@@ -75,7 +70,7 @@ public class AsyncAppenderTest {
         logger.error("This is a test");
         logger.warn("Hello world!");
         Thread.sleep(100);
-        final List<String> list = app.getMessages();
+        final List<String> list = listAppender.getMessages();
         assertNotNull("No events generated", list);
         assertTrue("Incorrect number of events. Expected 2, got " + list.size(), list.size()
== 2);
         String msg = list.get(0);
@@ -93,7 +88,7 @@ public class AsyncAppenderTest {
         final Throwable child = new LoggingException("This is a test", parent);
         logger.error("This is a test", child);
         Thread.sleep(100);
-        final List<String> list = app.getMessages();
+        final List<String> list = listAppender.getMessages();
         assertNotNull("No events generated", list);
         assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size()
== 1);
         final String msg = list.get(0);

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderTest.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jdbc/AbstractJdbcAppenderTest.java
Tue Jun  3 06:54:39 2014
@@ -80,8 +80,7 @@ public abstract class AbstractJdbcAppend
     public void tearDown() throws SQLException {
         final LoggerContext context = (LoggerContext) LogManager.getContext(false);
         try {
-            final Map<String, Appender> map = context.getConfiguration().getAppenders();
-            final Appender appender = map.get("databaseAppender");
+            final Appender appender = context.getConfiguration().getAppender("databaseAppender");
             assertNotNull("The appender should not be null.", appender);
             assertTrue("The appender should be a JdbcAppender.", appender instanceof JdbcAppender);
             ((JdbcAppender) appender).getManager().release();

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/AbstractJpaAppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/AbstractJpaAppenderTest.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/AbstractJpaAppenderTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/AbstractJpaAppenderTest.java
Tue Jun  3 06:54:39 2014
@@ -62,8 +62,7 @@ public abstract class AbstractJpaAppende
     public void tearDown() throws SQLException {
         final LoggerContext context = (LoggerContext) LogManager.getContext(false);
         try {
-            final Map<String, Appender> map = context.getConfiguration().getAppenders();
-            final Appender appender = map.get("databaseAppender");
+            final Appender appender = context.getConfiguration().getAppender("databaseAppender");
             assertNotNull("The appender should not be null.", appender);
             assertTrue("The appender should be a JpaAppender.", appender instanceof JpaAppender);
             ((JpaAppender) appender).getManager().release();

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/JsonRoutingAppender2Test.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/JsonRoutingAppender2Test.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/JsonRoutingAppender2Test.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/JsonRoutingAppender2Test.java
Tue Jun  3 06:54:39 2014
@@ -42,7 +42,7 @@ import static org.junit.Assert.*;
 public class JsonRoutingAppender2Test {
     private static final String CONFIG = "log4j-routing2.json";
     private static Configuration config;
-    private static ListAppender app;
+    private static ListAppender listAppender;
     private static LoggerContext ctx;
 
     @BeforeClass
@@ -50,12 +50,7 @@ public class JsonRoutingAppender2Test {
         System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
         ctx = (LoggerContext) LogManager.getContext(false);
         config = ctx.getConfiguration();
-        for (final Map.Entry<String, Appender> entry : config.getAppenders().entrySet())
{
-            if (entry.getKey().equals("List")) {
-                app = (ListAppender) entry.getValue();
-                break;
-            }
-        }
+        listAppender = (ListAppender) config.getAppender("List");
         final File file = new File("target/rolling1/rollingtest-Unknown.log");
         file.delete();
     }
@@ -73,7 +68,7 @@ public class JsonRoutingAppender2Test {
     public void routingTest() {
         StructuredDataMessage msg = new StructuredDataMessage("Test", "This is a test", "Service");
         EventLogger.logEvent(msg);
-        final List<LogEvent> list = app.getEvents();
+        final List<LogEvent> list = listAppender.getEvents();
         assertNotNull("No events generated", list);
         assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size()
== 1);
         msg = new StructuredDataMessage("Test", "This is a test", "Unknown");

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/JsonRoutingAppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/JsonRoutingAppenderTest.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/JsonRoutingAppenderTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/routing/JsonRoutingAppenderTest.java
Tue Jun  3 06:54:39 2014
@@ -42,7 +42,7 @@ import static org.junit.Assert.*;
 public class JsonRoutingAppenderTest {
     private static final String CONFIG = "log4j-routing.json";
     private static Configuration config;
-    private static ListAppender app;
+    private static ListAppender listAppender;
     private static LoggerContext ctx;
 
     @BeforeClass
@@ -50,12 +50,7 @@ public class JsonRoutingAppenderTest {
         System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
         ctx = (LoggerContext) LogManager.getContext(false);
         config = ctx.getConfiguration();
-        for (final Map.Entry<String, Appender> entry : config.getAppenders().entrySet())
{
-            if (entry.getKey().equals("List")) {
-                app = (ListAppender) entry.getValue();
-                break;
-            }
-        }
+        listAppender = (ListAppender) config.getAppender("List");
         final File file = new File("target/rolling1/rollingtest-Unknown.log");
         file.delete();
     }
@@ -73,7 +68,7 @@ public class JsonRoutingAppenderTest {
     public void routingTest() {
         StructuredDataMessage msg = new StructuredDataMessage("Test", "This is a test", "Service");
         EventLogger.logEvent(msg);
-        final List<LogEvent> list = app.getEvents();
+        final List<LogEvent> list = listAppender.getEvents();
         assertNotNull("No events generated", list);
         assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size()
== 1);
         msg = new StructuredDataMessage("Test", "This is a test", "Unknown");

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java
Tue Jun  3 06:54:39 2014
@@ -40,7 +40,7 @@ public class XmlLoggerPropsTest {
 
     private static final String CONFIG = "log4j-loggerprops.xml";
     private static Configuration config;
-    private static ListAppender app;
+    private static ListAppender listAppender;
     private static LoggerContext ctx;
 
     @BeforeClass
@@ -49,12 +49,7 @@ public class XmlLoggerPropsTest {
         System.setProperty("test", "test");
         ctx = (LoggerContext) LogManager.getContext(false);
         config = ctx.getConfiguration();
-        for (final Map.Entry<String, Appender> entry : config.getAppenders().entrySet())
{
-            if (entry.getKey().equals("List")) {
-                app = (ListAppender) entry.getValue();
-                break;
-            }
-        }
+        listAppender = (ListAppender) config.getAppender("List");
     }
 
     @AfterClass
@@ -66,7 +61,7 @@ public class XmlLoggerPropsTest {
 
     @Test
     public void testWithProps() {
-        assertNotNull("No List Appender", app);
+        assertNotNull("No List Appender", listAppender);
 
         try {
             assertTrue("Configuration is not an XmlConfiguration", config instanceof XmlConfiguration);
@@ -74,7 +69,7 @@ public class XmlLoggerPropsTest {
             logger.debug("Test with props");
             logger = LogManager.getLogger("tiny.bubbles");
             logger.debug("Test on root");
-            final List<String> events = app.getMessages();
+            final List<String> events = listAppender.getMessages();
             assertTrue("No events", events.size() > 0);
             assertTrue("Incorrect number of events", events.size() == 2);
             assertTrue("Incorrect value", events.get(0).contains("test=test"));

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/MapFilterTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/MapFilterTest.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/MapFilterTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/MapFilterTest.java
Tue Jun  3 06:54:39 2014
@@ -94,8 +94,7 @@ public class MapFilterTest {
         final Map<String, String> eventMap = new HashMap<String, String>();
         eventMap.put("eventId", "Login");
         logger.debug(new MapMessage(eventMap));
-        final Map<String,Appender> appenders = config.getAppenders();
-        final Appender app = appenders.get("LIST");
+        final Appender app = config.getAppender("LIST");
         assertNotNull("No List appender", app);
         final List<String> msgs = ((ListAppender) app).getMessages();
         assertNotNull("No messages", msgs);

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/net/jms/JmsQueueFailoverTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/net/jms/JmsQueueFailoverTest.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/net/jms/JmsQueueFailoverTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/net/jms/JmsQueueFailoverTest.java
Tue Jun  3 06:54:39 2014
@@ -58,7 +58,7 @@ public class JmsQueueFailoverTest {
     private static final String CONFIG = "log4j-jmsqueue-failover.xml";
 
     private static Configuration config;
-    private static ListAppender app;
+    private static ListAppender listAppender;
     private static LoggerContext ctx;
 
     @BeforeClass
@@ -78,14 +78,9 @@ public class JmsQueueFailoverTest {
     @Before
     public void before() {
         config = ctx.getConfiguration();
-        for (final Map.Entry<String, Appender> entry : config.getAppenders().entrySet())
{
-            if (entry.getKey().equals("List")) {
-                app = (ListAppender) entry.getValue();
-                break;
-            }
-        }
-        assertNotNull("No Appender", app);
-        app.clear();
+        listAppender = (ListAppender) config.getAppender("List");
+        assertNotNull("No Appender", listAppender);
+        listAppender.clear();
         ThreadContext.clearMap();
     }
 
@@ -106,7 +101,7 @@ public class JmsQueueFailoverTest {
         ThreadContext.put("appender", "Failover");
         final Logger logger = LogManager.getLogger(JmsQueueFailoverTest.class);
         logger.debug("Test Message");
-        final List<LogEvent> events = app.getEvents();
+        final List<LogEvent> events = listAppender.getEvents();
         assertNotNull("No events returned", events);
         assertTrue("No events returned", events.size() > 0);
         assertTrue("Incorrect event", "Test Message".equals(events.get(0).getMessage().getFormattedMessage()));
@@ -119,7 +114,7 @@ public class JmsQueueFailoverTest {
         ThreadContext.put("appender", "Failover");
         final Logger logger = LogManager.getLogger(JmsQueueFailoverTest.class);
         logger.debug("Test Message");
-        final List<LogEvent> events = app.getEvents();
+        final List<LogEvent> events = listAppender.getEvents();
         assertNotNull("No events returned", events);
         assertTrue("No events returned", events.size() > 0);
         assertTrue("Incorrect event", "Test Message".equals(events.get(0).getMessage().getFormattedMessage()));

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/net/jms/JmsTopicFailoverTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/net/jms/JmsTopicFailoverTest.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/net/jms/JmsTopicFailoverTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/net/jms/JmsTopicFailoverTest.java
Tue Jun  3 06:54:39 2014
@@ -57,7 +57,7 @@ public class JmsTopicFailoverTest {
     private static final String CONFIG = "log4j-jmstopic-failover.xml";
 
     private static Configuration config;
-    private static ListAppender app;
+    private static ListAppender listAppender;
     private static LoggerContext ctx;
 
     @BeforeClass
@@ -77,14 +77,9 @@ public class JmsTopicFailoverTest {
     @Before
     public void before() {
         config = ctx.getConfiguration();
-        for (final Map.Entry<String, Appender> entry : config.getAppenders().entrySet())
{
-            if (entry.getKey().equals("List")) {
-                app = (ListAppender) entry.getValue();
-                break;
-            }
-        }
-        assertNotNull("No Appender", app);
-        app.clear();
+        listAppender = (ListAppender) config.getAppender("List");
+        assertNotNull("No Appender", listAppender);
+        listAppender.clear();
         ThreadContext.clearMap();
     }
 
@@ -105,7 +100,7 @@ public class JmsTopicFailoverTest {
         ThreadContext.put("appender", "Failover");
         final Logger logger = LogManager.getLogger(JmsTopicFailoverTest.class);
         logger.debug("Test Message");
-        final List<LogEvent> events = app.getEvents();
+        final List<LogEvent> events = listAppender.getEvents();
         assertNotNull("No events returned", events);
         assertTrue("No events returned", events.size() > 0);
         assertTrue("Incorrect event", "Test Message".equals(events.get(0).getMessage().getFormattedMessage()));
@@ -118,7 +113,7 @@ public class JmsTopicFailoverTest {
         ThreadContext.put("appender", "Failover");
         final Logger logger = LogManager.getLogger(JmsTopicFailoverTest.class);
         logger.debug("Test Message");
-        final List<LogEvent> events = app.getEvents();
+        final List<LogEvent> events = listAppender.getEvents();
         assertNotNull("No events returned", events);
         assertTrue("No events returned", events.size() > 0);
         assertTrue("Incorrect event", "Test Message".equals(events.get(0).getMessage().getFormattedMessage()));

Modified: logging/log4j/log4j2/trunk/log4j-jcl/src/test/java/org/apache/logging/log4j/jcl/LoggerTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-jcl/src/test/java/org/apache/logging/log4j/jcl/LoggerTest.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-jcl/src/test/java/org/apache/logging/log4j/jcl/LoggerTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-jcl/src/test/java/org/apache/logging/log4j/jcl/LoggerTest.java
Tue Jun  3 06:54:39 2014
@@ -72,8 +72,7 @@ public class LoggerTest {
 
     private void verify(final String name, final String expected) {
         final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
-        final Map<String, Appender> map = ctx.getConfiguration().getAppenders();
-        final Appender listApp = map.get(name);
+        final Appender listApp = ctx.getConfiguration().getAppender(name);
         assertNotNull("Missing Appender", listApp);
         assertTrue("Not a ListAppender", listApp instanceof ListAppender);
         final List<String> events = ((ListAppender) listApp).getMessages();

Modified: logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
Tue Jun  3 06:54:39 2014
@@ -169,8 +169,7 @@ public class LoggerTest {
 
     private void verify(final String name, final String expected) {
         //LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
-        final Map<String, Appender> list = ctx.getConfiguration().getAppenders();
-        final Appender listApp = list.get(name);
+        final Appender listApp = ctx.getConfiguration().getAppender(name);
         assertNotNull("Missing Appender", listApp);
         assertTrue("Not a ListAppender", listApp instanceof ListAppender);
         final List<String> events = ((ListAppender) listApp).getMessages();

Modified: logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OptionalTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OptionalTest.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OptionalTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/OptionalTest.java
Tue Jun  3 06:54:39 2014
@@ -73,8 +73,7 @@ public class OptionalTest {
 
     private void verify(final String name, final String expected) {
         //LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
-        final Map<String, Appender> list = ctx.getConfiguration().getAppenders();
-        final Appender listApp = list.get(name);
+        final Appender listApp = ctx.getConfiguration().getAppender(name);
         assertNotNull("Missing Appender", listApp);
         assertTrue("Not a ListAppender", listApp instanceof ListAppender);
         final List<String> events = ((ListAppender) listApp).getMessages();
@@ -86,10 +85,10 @@ public class OptionalTest {
 
     @Before
     public void cleanup() {
-        final Map<String, Appender> list = ctx.getConfiguration().getAppenders();
-        final Appender listApp = list.get("List");
+        final Map<String, Appender> map = ctx.getConfiguration().getAppenders();
+        final Appender listApp = map.get("List");
         ((ListAppender) listApp).clear();
-        final Appender eventApp = list.get("EventLogger");
+        final Appender eventApp = map.get("EventLogger");
         ((ListAppender) eventApp).clear();
     }
 }

Modified: logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/CatchingTagTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/CatchingTagTest.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/CatchingTagTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/CatchingTagTest.java
Tue Jun  3 06:54:39 2014
@@ -96,8 +96,7 @@ public class CatchingTagTest {
 
     private void verify(final String expected) {
         final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
-        final Map<String, Appender> list = ctx.getConfiguration().getAppenders();
-        final Appender listApp = list.get("List");
+        final Appender listApp = ctx.getConfiguration().getAppender("List");
         assertNotNull("Missing Appender", listApp);
         assertTrue("Not a ListAppender", listApp instanceof ListAppender);
         final List<String> events = ((ListAppender) listApp).getMessages();

Modified: logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/EntryTagTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/EntryTagTest.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/EntryTagTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/EntryTagTest.java
Tue Jun  3 06:54:39 2014
@@ -84,8 +84,7 @@ public class EntryTagTest {
 
     private void verify(final String expected) {
         final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
-        final Map<String, Appender> list = ctx.getConfiguration().getAppenders();
-        final Appender listApp = list.get("List");
+        final Appender listApp = ctx.getConfiguration().getAppender("List");
         assertNotNull("Missing Appender", listApp);
         assertTrue("Not a ListAppender", listApp instanceof ListAppender);
         final List<String> events = ((ListAppender) listApp).getMessages();

Modified: logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/ExitTagTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/ExitTagTest.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/ExitTagTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/ExitTagTest.java
Tue Jun  3 06:54:39 2014
@@ -91,8 +91,7 @@ public class ExitTagTest {
 
     private void verify(final String expected) {
         final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
-        final Map<String, Appender> list = ctx.getConfiguration().getAppenders();
-        final Appender listApp = list.get("List");
+        final Appender listApp = ctx.getConfiguration().getAppender("List");
         assertNotNull("Missing Appender", listApp);
         assertTrue("Not a ListAppender", listApp instanceof ListAppender);
         final List<String> events = ((ListAppender) listApp).getMessages();

Modified: logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupportTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupportTest.java?rev=1599428&r1=1599427&r2=1599428&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupportTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-taglib/src/test/java/org/apache/logging/log4j/taglib/LoggingMessageTagSupportTest.java
Tue Jun  3 06:54:39 2014
@@ -297,8 +297,7 @@ public class LoggingMessageTagSupportTes
     @SuppressWarnings("unchecked")
     private void verify(final String expected) {
         final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
-        final Map<String, Appender> list = ctx.getConfiguration().getAppenders();
-        final Appender listApp = list.get("List");
+        final Appender listApp = ctx.getConfiguration().getAppender("List");
         assertNotNull("Missing Appender", listApp);
         assertTrue("Not a ListAppender", listApp instanceof ListAppender);
         final List<String> events = ((ListAppender) listApp).getMessages();



Mime
View raw message