You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2014/06/25 06:28:49 UTC
svn commit: r1605260 - in /logging/log4j/log4j2/trunk:
log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/
log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/
log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/
log4j-web/src/main/java/org/...
Author: ggregory
Date: Wed Jun 25 04:28:49 2014
New Revision: 1605260
URL: http://svn.apache.org/r1605260
Log:
Use final consistently. Some APIs had a mix of final and non-final params when all could be final. They now are.
Modified:
logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMarker.java
logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMarkerFactory.java
logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/SerializeTest.java
logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java
logging/log4j/log4j2/trunk/log4j-web/src/main/java/org/apache/logging/log4j/web/Log4jWebInitializerImpl.java
logging/log4j/log4j2/trunk/log4j-web/src/main/java/org/apache/logging/log4j/web/WebLookup.java
logging/log4j/log4j2/trunk/log4j-web/src/main/java/org/apache/logging/log4j/web/appender/ServletAppender.java
logging/log4j/log4j2/trunk/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jWebInitializerImplTest.java
logging/log4j/log4j2/trunk/log4j-web/src/test/java/org/apache/logging/log4j/web/ServletAppenderTest.java
logging/log4j/log4j2/trunk/log4j-web/src/test/java/org/apache/logging/log4j/web/WebLookupTest.java
Modified: logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMarker.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMarker.java?rev=1605260&r1=1605259&r2=1605260&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMarker.java (original)
+++ logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMarker.java Wed Jun 25 04:28:49 2014
@@ -36,7 +36,7 @@ public class Log4jMarker implements Mark
private final org.apache.logging.log4j.Marker marker;
- public Log4jMarker(org.apache.logging.log4j.Marker marker) {
+ public Log4jMarker(final org.apache.logging.log4j.Marker marker) {
this.marker = marker;
}
@@ -45,13 +45,13 @@ public class Log4jMarker implements Mark
}
@Override
- public void add(Marker marker) {
- Marker m = factory.getMarker(marker.getName());
+ public void add(final Marker marker) {
+ final Marker m = factory.getMarker(marker.getName());
this.marker.addParents(((Log4jMarker)m).getLog4jMarker());
}
@Override
- public boolean remove(Marker marker) {
+ public boolean remove(final Marker marker) {
return this.marker.remove(MarkerManager.getMarker(marker.getName()));
}
@@ -73,20 +73,20 @@ public class Log4jMarker implements Mark
@Override
@SuppressWarnings("rawtypes")
public Iterator iterator() {
- List<Marker> parents = new ArrayList<Marker>();
- for (org.apache.logging.log4j.Marker m : this.marker.getParents()) {
+ final List<Marker> parents = new ArrayList<Marker>();
+ for (final org.apache.logging.log4j.Marker m : this.marker.getParents()) {
parents.add(factory.getMarker(m.getName()));
}
return parents.iterator();
}
@Override
- public boolean contains(org.slf4j.Marker marker) {
+ public boolean contains(final org.slf4j.Marker marker) {
return this.marker.isInstanceOf(marker.getName());
}
@Override
- public boolean contains(String s) {
+ public boolean contains(final String s) {
return this.marker.isInstanceOf(s);
}
}
Modified: logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMarkerFactory.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMarkerFactory.java?rev=1605260&r1=1605259&r2=1605260&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMarkerFactory.java (original)
+++ logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jMarkerFactory.java Wed Jun 25 04:28:49 2014
@@ -44,7 +44,7 @@ public class Log4jMarkerFactory implemen
if (marker != null) {
return marker;
}
- org.apache.logging.log4j.Marker log4jMarker = MarkerManager.getMarker(name);
+ final org.apache.logging.log4j.Marker log4jMarker = MarkerManager.getMarker(name);
marker = new Log4jMarker(log4jMarker);
final Marker existing = markerMap.putIfAbsent(name, marker);
return existing == null ? marker : existing;
Modified: logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/SerializeTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/SerializeTest.java?rev=1605260&r1=1605259&r2=1605260&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/SerializeTest.java (original)
+++ logging/log4j/log4j2/trunk/log4j-slf4j-impl/src/test/java/org/apache/logging/slf4j/SerializeTest.java Wed Jun 25 04:28:49 2014
@@ -64,15 +64,15 @@ public class SerializeTest {
@Test
public void testLogger() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(logger);
- byte[] data = baos.toByteArray();
+ final byte[] data = baos.toByteArray();
assertNotNull("No data", data);
assertTrue("No data", data.length > 0);
- ByteArrayInputStream bais = new ByteArrayInputStream(data);
- ObjectInputStream ois = new ObjectInputStream(bais);
- Logger copy = (org.slf4j.Logger) ois.readObject();
+ final ByteArrayInputStream bais = new ByteArrayInputStream(data);
+ final ObjectInputStream ois = new ObjectInputStream(bais);
+ final Logger copy = (org.slf4j.Logger) ois.readObject();
assertNotNull("Unable to restore logger", copy);
}
}
Modified: logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java?rev=1605260&r1=1605259&r2=1605260&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java (original)
+++ logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLogger.java Wed Jun 25 04:28:49 2014
@@ -151,7 +151,7 @@ public class SLF4JLogger extends Abstrac
}
@Override
- public void logMessage(String fqcn, Level level, Marker marker, Message message, Throwable t) {
+ public void logMessage(final String fqcn, final Level level, final Marker marker, final Message message, final Throwable t) {
if (locationAwareLogger != null) {
if (message instanceof LoggerNameAwareMessage) {
((LoggerNameAwareMessage) message).setLoggerName(getName());
Modified: logging/log4j/log4j2/trunk/log4j-web/src/main/java/org/apache/logging/log4j/web/Log4jWebInitializerImpl.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-web/src/main/java/org/apache/logging/log4j/web/Log4jWebInitializerImpl.java?rev=1605260&r1=1605259&r2=1605260&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-web/src/main/java/org/apache/logging/log4j/web/Log4jWebInitializerImpl.java (original)
+++ logging/log4j/log4j2/trunk/log4j-web/src/main/java/org/apache/logging/log4j/web/Log4jWebInitializerImpl.java Wed Jun 25 04:28:49 2014
@@ -96,7 +96,7 @@ final class Log4jWebInitializerImpl exte
}
private void initializeJndi(final String location) {
- URI configLocation = getConfigURI(location);;
+ final URI configLocation = getConfigURI(location);;
if (this.name == null) {
throw new IllegalStateException("A log4jContextName context parameter is required");
@@ -138,7 +138,7 @@ final class Log4jWebInitializerImpl exte
return;
}
- URI uri = getConfigURI(location);
+ final URI uri = getConfigURI(location);
this.loggerContext = Configurator.initialize(this.name, this.getClassLoader(), uri, this.servletContext);
}
@@ -146,13 +146,13 @@ final class Log4jWebInitializerImpl exte
try {
String configLocation = location;
if (configLocation == null) {
- String[] paths = SetUtils.prefixSet(servletContext.getResourcePaths("/WEB-INF/"), "/WEB-INF/log4j2");
+ final String[] paths = SetUtils.prefixSet(servletContext.getResourcePaths("/WEB-INF/"), "/WEB-INF/log4j2");
if (paths.length == 1) {
configLocation = paths[0];
} else if (paths.length > 1) {
final String prefix = "/WEB-INF/log4j2-" + this.name + ".";
- boolean found = false;
- for (String str : paths) {
+ final boolean found = false;
+ for (final String str : paths) {
if (str.startsWith(prefix)) {
configLocation = str;
break;
@@ -164,12 +164,12 @@ final class Log4jWebInitializerImpl exte
}
}
if (configLocation != null) {
- URL url = servletContext.getResource(configLocation);
+ final URL url = servletContext.getResource(configLocation);
if (url != null) {
return url.toURI();
}
}
- } catch (Exception ex) {
+ } catch (final Exception ex) {
// Just try passing the location.
}
if (location != null) {
@@ -218,7 +218,7 @@ final class Log4jWebInitializerImpl exte
}
@Override
- public void wrapExecution(Runnable runnable) {
+ public void wrapExecution(final Runnable runnable) {
this.setLoggerContext();
try {
Modified: logging/log4j/log4j2/trunk/log4j-web/src/main/java/org/apache/logging/log4j/web/WebLookup.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-web/src/main/java/org/apache/logging/log4j/web/WebLookup.java?rev=1605260&r1=1605259&r2=1605260&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-web/src/main/java/org/apache/logging/log4j/web/WebLookup.java (original)
+++ logging/log4j/log4j2/trunk/log4j-web/src/main/java/org/apache/logging/log4j/web/WebLookup.java Wed Jun 25 04:28:49 2014
@@ -39,34 +39,34 @@ public class WebLookup implements StrLoo
lc = (LoggerContext) LogManager.getContext(false);
}
if (lc != null) {
- Object obj = lc.getExternalContext();
+ final Object obj = lc.getExternalContext();
return obj != null && obj instanceof ServletContext ? (ServletContext) obj : null;
}
return null;
}
@Override
- public String lookup(String key) {
- ServletContext ctx = getServletContext();
+ public String lookup(final String key) {
+ final ServletContext ctx = getServletContext();
if (ctx == null) {
return null;
}
if (key.startsWith(ATTR_PREFIX)) {
- String attrName = key.substring(ATTR_PREFIX.length());
- Object attrValue = ctx.getAttribute(attrName);
+ final String attrName = key.substring(ATTR_PREFIX.length());
+ final Object attrValue = ctx.getAttribute(attrName);
return attrValue == null ? null : attrValue.toString();
}
if (key.startsWith(INIT_PARAM_PREFIX)) {
- String paramName = key.substring(INIT_PARAM_PREFIX.length());
+ final String paramName = key.substring(INIT_PARAM_PREFIX.length());
return ctx.getInitParameter(paramName);
}
if ("rootDir".equals(key)) {
- String root = ctx.getRealPath("/");
+ final String root = ctx.getRealPath("/");
if (root == null) {
- String msg = "Failed to resolve web:rootDir -- " +
+ final String msg = "Failed to resolve web:rootDir -- " +
"servlet container unable to translate virtual path " +
" to real path (probably not deployed as exploded";
throw new IllegalStateException(msg);
@@ -115,7 +115,7 @@ public class WebLookup implements StrLoo
}
@Override
- public String lookup(LogEvent event, String key) {
+ public String lookup(final LogEvent event, final String key) {
return lookup(key);
}
}
Modified: logging/log4j/log4j2/trunk/log4j-web/src/main/java/org/apache/logging/log4j/web/appender/ServletAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-web/src/main/java/org/apache/logging/log4j/web/appender/ServletAppender.java?rev=1605260&r1=1605259&r2=1605260&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-web/src/main/java/org/apache/logging/log4j/web/appender/ServletAppender.java (original)
+++ logging/log4j/log4j2/trunk/log4j-web/src/main/java/org/apache/logging/log4j/web/appender/ServletAppender.java Wed Jun 25 04:28:49 2014
@@ -43,13 +43,13 @@ public class ServletAppender extends Abs
private final ServletContext servletContext;
private ServletAppender(final String name, final AbstractStringLayout layout, final Filter filter,
- ServletContext servletContext, boolean ignoreExceptions) {
+ final ServletContext servletContext, final boolean ignoreExceptions) {
super(name, filter, layout, ignoreExceptions);
this.servletContext = servletContext;
}
@Override
- public void append(LogEvent event) {
+ public void append(final LogEvent event) {
servletContext.log(((AbstractStringLayout) getLayout()).toSerializable(event));
}
@@ -72,7 +72,7 @@ public class ServletAppender extends Abs
LOGGER.error("No name provided for ConsoleAppender");
return null;
}
- ServletContext servletContext = getServletContext();
+ final ServletContext servletContext = getServletContext();
if (servletContext == null) {
LOGGER.error("No servlet context is available");
return null;
@@ -93,7 +93,7 @@ public class ServletAppender extends Abs
lc = (LoggerContext) LogManager.getContext(false);
}
if (lc != null) {
- Object obj = lc.getExternalContext();
+ final Object obj = lc.getExternalContext();
return obj != null && obj instanceof ServletContext ? (ServletContext) obj : null;
}
return null;
Modified: logging/log4j/log4j2/trunk/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jWebInitializerImplTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jWebInitializerImplTest.java?rev=1605260&r1=1605259&r2=1605260&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jWebInitializerImplTest.java (original)
+++ logging/log4j/log4j2/trunk/log4j-web/src/test/java/org/apache/logging/log4j/web/Log4jWebInitializerImplTest.java Wed Jun 25 04:28:49 2014
@@ -98,7 +98,7 @@ public class Log4jWebInitializerImplTest
@Test
public void testInitializeWithNoParametersThenSetLoggerContextThenDeinitialize() throws Exception {
- Capture<Object> loggerContextCapture = new Capture<Object>();
+ final Capture<Object> loggerContextCapture = new Capture<Object>();
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONTEXT_NAME)).andReturn(null);
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONFIG_LOCATION)).andReturn(null);
@@ -118,7 +118,7 @@ public class Log4jWebInitializerImplTest
assertNotNull("The context attribute should not be null.", loggerContextCapture.getValue());
assertTrue("The context attribute is not correct.",
loggerContextCapture.getValue() instanceof org.apache.logging.log4j.spi.LoggerContext);
- org.apache.logging.log4j.spi.LoggerContext loggerContext =
+ final org.apache.logging.log4j.spi.LoggerContext loggerContext =
(org.apache.logging.log4j.spi.LoggerContext)loggerContextCapture.getValue();
verify(this.servletContext);
@@ -162,7 +162,7 @@ public class Log4jWebInitializerImplTest
@Test
public void testInitializeWithClassLoaderNoParametersThenSetLoggerContextThenDeinitialize() throws Exception {
- Capture<Object> loggerContextCapture = new Capture<Object>();
+ final Capture<Object> loggerContextCapture = new Capture<Object>();
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONTEXT_NAME)).andReturn(null);
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONFIG_LOCATION)).andReturn(null);
@@ -183,7 +183,7 @@ public class Log4jWebInitializerImplTest
assertNotNull("The context attribute should not be null.", loggerContextCapture.getValue());
assertTrue("The context attribute is not correct.",
loggerContextCapture.getValue() instanceof org.apache.logging.log4j.spi.LoggerContext);
- org.apache.logging.log4j.spi.LoggerContext loggerContext =
+ final org.apache.logging.log4j.spi.LoggerContext loggerContext =
(org.apache.logging.log4j.spi.LoggerContext)loggerContextCapture.getValue();
verify(this.servletContext);
@@ -227,7 +227,7 @@ public class Log4jWebInitializerImplTest
@Test
public void testInitializeIsIdempotent() throws Exception {
- Capture<Object> loggerContextCapture = new Capture<Object>();
+ final Capture<Object> loggerContextCapture = new Capture<Object>();
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONTEXT_NAME)).andReturn(null);
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONFIG_LOCATION)).andReturn(null);
@@ -272,7 +272,7 @@ public class Log4jWebInitializerImplTest
@Test
public void testInitializeFailsAfterDeinitialize() throws Exception {
- Capture<Object> loggerContextCapture = new Capture<Object>();
+ final Capture<Object> loggerContextCapture = new Capture<Object>();
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONTEXT_NAME)).andReturn(null);
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONFIG_LOCATION)).andReturn(null);
@@ -316,7 +316,7 @@ public class Log4jWebInitializerImplTest
@Test
public void testDeinitializeIsIdempotent() throws Exception {
- Capture<Object> loggerContextCapture = new Capture<Object>();
+ final Capture<Object> loggerContextCapture = new Capture<Object>();
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONTEXT_NAME)).andReturn(null);
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONFIG_LOCATION)).andReturn(null);
@@ -374,7 +374,7 @@ public class Log4jWebInitializerImplTest
@Test
public void testInitializeUsingJndiSelector() throws Exception {
- Capture<Object> loggerContextCapture = new Capture<Object>();
+ final Capture<Object> loggerContextCapture = new Capture<Object>();
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONTEXT_NAME)).andReturn("helloWorld6");
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONFIG_LOCATION)).andReturn(null);
@@ -427,7 +427,7 @@ public class Log4jWebInitializerImplTest
@Test
public void testWrapExecutionWithNoParameters() throws Exception {
- Capture<Object> loggerContextCapture = new Capture<Object>();
+ final Capture<Object> loggerContextCapture = new Capture<Object>();
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONTEXT_NAME)).andReturn(null);
expect(this.servletContext.getInitParameter(Log4jWebSupport.LOG4J_CONFIG_LOCATION)).andReturn(null);
@@ -455,7 +455,7 @@ public class Log4jWebInitializerImplTest
assertNull("The context should still be null.", ContextAnchor.THREAD_CONTEXT.get());
- Runnable runnable = createStrictMock(Runnable.class);
+ final Runnable runnable = createStrictMock(Runnable.class);
runnable.run();
expectLastCall().andAnswer(new IAnswer<Void>() {
@Override
Modified: logging/log4j/log4j2/trunk/log4j-web/src/test/java/org/apache/logging/log4j/web/ServletAppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-web/src/test/java/org/apache/logging/log4j/web/ServletAppenderTest.java?rev=1605260&r1=1605259&r2=1605260&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-web/src/test/java/org/apache/logging/log4j/web/ServletAppenderTest.java (original)
+++ logging/log4j/log4j2/trunk/log4j-web/src/test/java/org/apache/logging/log4j/web/ServletAppenderTest.java Wed Jun 25 04:28:49 2014
@@ -40,24 +40,24 @@ public class ServletAppenderTest {
@Test
public void testAppender() throws Exception {
ContextAnchor.THREAD_CONTEXT.remove();
- ServletContext servletContext = new MockServletContext();
+ final ServletContext servletContext = new MockServletContext();
servletContext.setAttribute("TestAttr", "AttrValue");
servletContext.setInitParameter("TestParam", "ParamValue");
servletContext.setAttribute("Name1", "Ben");
servletContext.setInitParameter("Name2", "Jerry");
servletContext.setInitParameter(Log4jWebSupport.LOG4J_CONFIG_LOCATION, CONFIG);
- Log4jWebLifeCycle initializer = Log4jWebInitializerImpl.getLog4jWebInitializer(servletContext);
+ final Log4jWebLifeCycle initializer = Log4jWebInitializerImpl.getLog4jWebInitializer(servletContext);
try {
initializer.start();
initializer.setLoggerContext();
- LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get();
+ final LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get();
assertNotNull("No LoggerContext", ctx);
assertNotNull("No ServletContext", ctx.getExternalContext());
- Configuration configuration = ctx.getConfiguration();
+ final Configuration configuration = ctx.getConfiguration();
assertNotNull("No configuration", configuration);
- Appender appender = configuration.getAppender("Servlet");
+ final Appender appender = configuration.getAppender("Servlet");
assertNotNull("No ServletAppender", appender);
- Logger logger = LogManager.getLogger("Test");
+ final Logger logger = LogManager.getLogger("Test");
logger.info("This is a test");
} catch (final IllegalStateException e) {
Modified: logging/log4j/log4j2/trunk/log4j-web/src/test/java/org/apache/logging/log4j/web/WebLookupTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-web/src/test/java/org/apache/logging/log4j/web/WebLookupTest.java?rev=1605260&r1=1605259&r2=1605260&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-web/src/test/java/org/apache/logging/log4j/web/WebLookupTest.java (original)
+++ logging/log4j/log4j2/trunk/log4j-web/src/test/java/org/apache/logging/log4j/web/WebLookupTest.java Wed Jun 25 04:28:49 2014
@@ -36,21 +36,21 @@ public class WebLookupTest {
@Test
public void testLookup() throws Exception {
ContextAnchor.THREAD_CONTEXT.remove();
- ServletContext servletContext = new MockServletContext();
+ final ServletContext servletContext = new MockServletContext();
servletContext.setAttribute("TestAttr", "AttrValue");
servletContext.setInitParameter("TestParam", "ParamValue");
servletContext.setAttribute("Name1", "Ben");
servletContext.setInitParameter("Name2", "Jerry");
- Log4jWebLifeCycle initializer = Log4jWebInitializerImpl.getLog4jWebInitializer(servletContext);
+ final Log4jWebLifeCycle initializer = Log4jWebInitializerImpl.getLog4jWebInitializer(servletContext);
try {
initializer.start();
initializer.setLoggerContext();
- LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get();
+ final LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get();
assertNotNull("No LoggerContext", ctx);
assertNotNull("No ServletContext", ctx.getExternalContext());
- Configuration config = ctx.getConfiguration();
+ final Configuration config = ctx.getConfiguration();
assertNotNull("No Configuration", config);
- StrSubstitutor substitutor = config.getStrSubstitutor();
+ final StrSubstitutor substitutor = config.getStrSubstitutor();
assertNotNull("No Interpolator", substitutor);
String value = substitutor.replace("${web:initParam.TestParam}");
assertNotNull("No value for TestParam", value);
@@ -74,24 +74,24 @@ public class WebLookupTest {
@Test
public void testLookup2() throws Exception {
ContextAnchor.THREAD_CONTEXT.remove();
- ServletContext servletContext = new MockServletContext();
+ final ServletContext servletContext = new MockServletContext();
servletContext.setAttribute("TestAttr", "AttrValue");
servletContext.setInitParameter("myapp.logdir", "target");
servletContext.setAttribute("Name1", "Ben");
servletContext.setInitParameter("Name2", "Jerry");
servletContext.setInitParameter("log4jConfiguration", "log4j-webvar.xml");
- Log4jWebLifeCycle initializer = Log4jWebInitializerImpl.getLog4jWebInitializer(servletContext);
+ final Log4jWebLifeCycle initializer = Log4jWebInitializerImpl.getLog4jWebInitializer(servletContext);
initializer.start();
initializer.setLoggerContext();
- LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get();
+ final LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get();
assertNotNull("No LoggerContext", ctx);
assertNotNull("No ServletContext", ctx.getExternalContext());
- Configuration config = ctx.getConfiguration();
+ final Configuration config = ctx.getConfiguration();
assertNotNull("No Configuration", config);
- Map<String, Appender> appenders = config.getAppenders();
- for (Map.Entry<String, Appender> entry : appenders.entrySet()) {
+ final Map<String, Appender> appenders = config.getAppenders();
+ for (final Map.Entry<String, Appender> entry : appenders.entrySet()) {
if (entry.getKey().equals("file")) {
- FileAppender fa = (FileAppender) entry.getValue();
+ final FileAppender fa = (FileAppender) entry.getValue();
assertEquals("target/myapp.log", fa.getFileName());
}
}