http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadContextTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadContextTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadContextTest.java index 0b5ff64..76bf257 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadContextTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadContextTest.java @@ -56,10 +56,10 @@ public class AsyncLoggerThreadContextTest { final File file = new File("target", "AsyncLoggerTest.log"); // System.out.println(f.getAbsolutePath()); file.delete(); - + ThreadContext.push("stackvalue"); ThreadContext.put("KEY", "mapvalue"); - + final Logger log = LogManager.getLogger("com.foo.Bar"); final String msg = "Async logger msg"; log.info(msg, new InternalError("this is not a real error"));
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerUseAfterShutdownTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerUseAfterShutdownTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerUseAfterShutdownTest.java index 2e4ab33..f553137 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerUseAfterShutdownTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerUseAfterShutdownTest.java @@ -57,7 +57,7 @@ public class AsyncLoggerUseAfterShutdownTest { log.info(msg, new InternalError("this is not a real error")); CoreLoggerContexts.stopLoggerContext(); // stop async thread - // call the #logMessage() method to bypass the isEnabled check: + // call the #logMessage() method to bypass the isEnabled check: // before the LOG4J2-639 fix this would throw a NPE ((AbstractLogger) log).logMessage("com.foo.Bar", Level.INFO, null, new SimpleMessage("msg"), null); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/async/BlockingAppender.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/BlockingAppender.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/BlockingAppender.java index 6c8423f..c8e5ecd 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/BlockingAppender.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/BlockingAppender.java @@ -64,7 +64,7 @@ public class BlockingAppender extends AbstractAppender { // block until the test class tells us to continue try { countDownLatch.await(); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { throw new RuntimeException(e); } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/async/QueueFullAbstractTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/QueueFullAbstractTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/QueueFullAbstractTest.java index d0542dc..187a08f 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/QueueFullAbstractTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/QueueFullAbstractTest.java @@ -40,7 +40,7 @@ public abstract class QueueFullAbstractTest { protected BlockingAppender blockingAppender; protected Unlocker unlocker; - protected static void TRACE(Object msg) { + protected static void TRACE(final Object msg) { if (TRACE) { System.out.println(msg); } @@ -48,7 +48,7 @@ public abstract class QueueFullAbstractTest { class Unlocker extends Thread { final CountDownLatch countDownLatch; - Unlocker(CountDownLatch countDownLatch) { + Unlocker(final CountDownLatch countDownLatch) { this.countDownLatch = countDownLatch; } @Override @@ -57,7 +57,7 @@ public abstract class QueueFullAbstractTest { countDownLatch.await(); TRACE("Unlocker activated. Sleeping 500 millis before taking action..."); Thread.sleep(500); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { throw new RuntimeException(e); } TRACE("Unlocker signalling BlockingAppender to proceed..."); @@ -66,9 +66,9 @@ public abstract class QueueFullAbstractTest { } class DomainObject { - private Logger innerLogger = LogManager.getLogger(DomainObject.class); + private final Logger innerLogger = LogManager.getLogger(DomainObject.class); final int count; - DomainObject(int loggingCount) { + DomainObject(final int loggingCount) { this.count = loggingCount; } @@ -86,34 +86,34 @@ public abstract class QueueFullAbstractTest { static Stack transform(final List<LogEvent> logEvents) { final List<String> filtered = new ArrayList<>(logEvents.size()); - for (LogEvent event : logEvents) { + for (final LogEvent event : logEvents) { filtered.add(event.getMessage().getFormattedMessage()); } Collections.reverse(filtered); - Stack<String> result = new Stack<>(); + final Stack<String> result = new Stack<>(); result.addAll(filtered); return result; } - static long asyncRemainingCapacity(Logger logger) { + static long asyncRemainingCapacity(final Logger logger) { if (logger instanceof AsyncLogger) { try { - Field f = field(AsyncLogger.class, "loggerDisruptor"); + final Field f = field(AsyncLogger.class, "loggerDisruptor"); return ((AsyncLoggerDisruptor) f.get(logger)).getDisruptor().getRingBuffer().remainingCapacity(); - } catch (Exception ex) { + } catch (final Exception ex) { throw new RuntimeException(ex); } } else { - LoggerConfig loggerConfig = ((org.apache.logging.log4j.core.Logger) logger).get(); + final LoggerConfig loggerConfig = ((org.apache.logging.log4j.core.Logger) logger).get(); if (loggerConfig instanceof AsyncLoggerConfig) { try { - Object delegate = field(AsyncLoggerConfig.class, "delegate").get(loggerConfig); + final Object delegate = field(AsyncLoggerConfig.class, "delegate").get(loggerConfig); return ((Disruptor) field(AsyncLoggerConfigDisruptor.class, "disruptor").get(delegate)).getRingBuffer().remainingCapacity(); - } catch (Exception ex) { + } catch (final Exception ex) { throw new RuntimeException(ex); } } else { - Appender async = loggerConfig.getAppenders().get("async"); + final Appender async = loggerConfig.getAppenders().get("async"); if (async instanceof AsyncAppender) { return ((AsyncAppender) async).getQueueCapacity(); } @@ -121,8 +121,8 @@ public abstract class QueueFullAbstractTest { } throw new IllegalStateException("Neither Async Loggers nor AsyncAppender are configured"); } - private static Field field(Class<?> c, String name) throws NoSuchFieldException { - Field f = c.getDeclaredField(name); + private static Field field(final Class<?> c, final String name) throws NoSuchFieldException { + final Field f = c.getDeclaredField(name); f.setAccessible(true); return f; } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigLoggingFromToStringTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigLoggingFromToStringTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigLoggingFromToStringTest.java index 307a93d..d11c2ff 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigLoggingFromToStringTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigLoggingFromToStringTest.java @@ -94,10 +94,10 @@ public class QueueFullAsyncLoggerConfigLoggingFromToStringTest extends QueueFull final Stack<String> actual = transform(blockingAppender.logEvents); assertEquals("Logging in toString() #0", actual.pop()); - List<StatusData> statusDataList = StatusLogger.getLogger().getStatusData(); + final List<StatusData> statusDataList = StatusLogger.getLogger().getStatusData(); assertEquals("Jumped the queue: queue full", "Logging in toString() #128", actual.pop()); - StatusData mostRecentStatusData = statusDataList.get(statusDataList.size() - 1); + final StatusData mostRecentStatusData = statusDataList.get(statusDataList.size() - 1); assertEquals("Expected warn level status message", Level.WARN, mostRecentStatusData.getLevel()); assertThat(mostRecentStatusData.getFormattedStatus(), containsString( "Log4j2 logged an event out of order to prevent deadlock caused by domain " + http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java index 099d660..02a1f8a 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java @@ -58,7 +58,7 @@ public class RingBufferLogEventTest { final LogEvent logEvent = new RingBufferLogEvent(); Assert.assertNotSame(logEvent, logEvent.toImmutable()); } - + @Test public void testGetLevelReturnsOffIfNullLevelSet() { final RingBufferLogEvent evt = new RingBufferLogEvent(); @@ -192,8 +192,8 @@ public class RingBufferLogEventTest { final Marker marker = MarkerManager.getMarker("marked man"); final String fqcn = "f.q.c.n"; final Level level = Level.TRACE; - ReusableMessageFactory factory = new ReusableMessageFactory(); - Message message = factory.newMessage("Hello {}!", "World"); + final ReusableMessageFactory factory = new ReusableMessageFactory(); + final Message message = factory.newMessage("Hello {}!", "World"); try { final Throwable t = new InternalError("not a real error"); final ContextStack contextStack = new MutableThreadContextStack(Arrays.asList("a", "b")); @@ -221,8 +221,8 @@ public class RingBufferLogEventTest { final Marker marker = MarkerManager.getMarker("marked man"); final String fqcn = "f.q.c.n"; final Level level = Level.TRACE; - ReusableMessageFactory factory = new ReusableMessageFactory(); - Message message = factory.newMessage("Hello {}!", "World"); + final ReusableMessageFactory factory = new ReusableMessageFactory(); + final Message message = factory.newMessage("Hello {}!", "World"); try { final Throwable t = new InternalError("not a real error"); final ContextStack contextStack = new MutableThreadContextStack(Arrays.asList("a", "b")); @@ -255,7 +255,7 @@ public class RingBufferLogEventTest { final RingBufferLogEvent evt = new RingBufferLogEvent(); evt.forEachParameter(new ParameterConsumer<Void>() { @Override - public void accept(Object parameter, int parameterIndex, Void state) { + public void accept(final Object parameter, final int parameterIndex, final Void state) { fail("Should not have been called"); } }, null); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/Histogram.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/Histogram.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/Histogram.java index bf0823b..39cde5f 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/Histogram.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/Histogram.java @@ -130,7 +130,7 @@ public final class Histogram // do a classic binary search to find the high value while (low < high) { - int mid = low + ((high - low) >> 1); + final int mid = low + ((high - low) >> 1); if (upperBounds[mid] < value) { low = mid + 1; @@ -287,10 +287,10 @@ public final class Histogram { if (0L != counts[i]) { - long upperBound = Math.min(upperBounds[i], maxValue); - long midPoint = lowerBound + ((upperBound - lowerBound) / 2L); + final long upperBound = Math.min(upperBounds[i], maxValue); + final long midPoint = lowerBound + ((upperBound - lowerBound) / 2L); - BigDecimal intervalTotal = new BigDecimal(midPoint).multiply(new BigDecimal(counts[i])); + final BigDecimal intervalTotal = new BigDecimal(midPoint).multiply(new BigDecimal(counts[i])); total = total.add(intervalTotal); } @@ -360,7 +360,7 @@ public final class Histogram @Override public String toString() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append("Histogram{"); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java index 2be6499..e9934fc 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java @@ -206,10 +206,10 @@ public class PerfTestDriver { public static void main(final String[] args) throws Exception { final long start = System.nanoTime(); - + final List<Setup> tests = selectTests(); runPerfTests(args, tests); - + System.out.printf("Done. Total duration: %.1f minutes%n", (System.nanoTime() - start) / (60.0 * 1000.0 * 1000.0 * 1000.0)); @@ -218,7 +218,7 @@ public class PerfTestDriver { private static List<Setup> selectTests() throws IOException { final List<Setup> tests = new ArrayList<>(); - + // final String CACHEDCLOCK = "-Dlog4j.Clock=CachedClock"; final String SYSCLOCK = "-Dlog4j.Clock=SystemClock"; final String ALL_ASYNC = "-DLog4jContextSelector=" + AsyncLoggerContextSelector.class.getName(); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CompositeConfigurationTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CompositeConfigurationTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CompositeConfigurationTest.java index cb7b497..2eb61b2 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CompositeConfigurationTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/CompositeConfigurationTest.java @@ -96,7 +96,7 @@ public class CompositeConfigurationTest { appendersMap.size()); assertTrue(appendersMap.get("STDOUT") instanceof ConsoleAppender); - Filter loggerFilter = config.getLogger("cat1").getFilter(); + final Filter loggerFilter = config.getLogger("cat1").getFilter(); assertTrue(loggerFilter instanceof RegexFilter); assertEquals(loggerFilter.getOnMatch(), Filter.Result.DENY); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java index a9b48e7..a7cfe17 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/ConfigurationTest.java @@ -111,13 +111,13 @@ public class ConfigurationTest { final Configuration config = this.ctx.getConfiguration(); assertEquals(config.getRootLogger(), config.getLoggerConfig(Strings.EMPTY)); } - + @Test(expected = NullPointerException.class) public void testGetLoggerConfigNull() throws Exception { final Configuration config = this.ctx.getConfiguration(); assertEquals(config.getRootLogger(), config.getLoggerConfig(null)); } - + @Test public void testLogger() throws Exception { final Logger logger = this.ctx.getLogger(LOGGER_NAME); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/config/JiraLog4j2_2134Test.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/JiraLog4j2_2134Test.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/JiraLog4j2_2134Test.java index b94a5a9..67217f6 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/JiraLog4j2_2134Test.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/JiraLog4j2_2134Test.java @@ -38,23 +38,23 @@ public class JiraLog4j2_2134Test { @Test public void testRefresh() { - Logger log = LogManager.getLogger(this.getClass()); + final Logger log = LogManager.getLogger(this.getClass()); final LoggerContext ctx = (LoggerContext) LogManager.getContext(false); final Configuration config = ctx.getConfiguration(); - PatternLayout layout = PatternLayout.newBuilder() + final PatternLayout layout = PatternLayout.newBuilder() // @formatter:off .withPattern(PatternLayout.SIMPLE_CONVERSION_PATTERN) .withConfiguration(config) .build(); final Layout<? extends Serializable> layout1 = layout; // @formatter:on - Appender appender = FileAppender.newBuilder().withFileName("target/test.log").setLayout(layout1) + final Appender appender = FileAppender.newBuilder().withFileName("target/test.log").setLayout(layout1) .setConfiguration(config).withBufferSize(4000).setName("File").build(); // appender.start(); config.addAppender(appender); - AppenderRef ref = AppenderRef.createAppenderRef("File", null, null); - AppenderRef[] refs = new AppenderRef[] { ref }; - LoggerConfig loggerConfig = LoggerConfig.createLogger(false, Level.INFO, "testlog4j2refresh", "true", refs, + final AppenderRef ref = AppenderRef.createAppenderRef("File", null, null); + final AppenderRef[] refs = new AppenderRef[] { ref }; + final LoggerConfig loggerConfig = LoggerConfig.createLogger(false, Level.INFO, "testlog4j2refresh", "true", refs, null, config, null); loggerConfig.addAppender(appender, null, null); config.addLogger("testlog4j2refresh", loggerConfig); @@ -66,7 +66,7 @@ public class JiraLog4j2_2134Test { @Test public void testRefreshMinimalCodeStart() { - Logger log = LogManager.getLogger(this.getClass()); + final Logger log = LogManager.getLogger(this.getClass()); final LoggerContext ctx = (LoggerContext) LogManager.getContext(false); final Configuration config = ctx.getConfiguration(); ctx.start(config); @@ -76,7 +76,7 @@ public class JiraLog4j2_2134Test { @Test public void testRefreshMinimalCodeStopStart() { - Logger log = LogManager.getLogger(this.getClass()); + final Logger log = LogManager.getLogger(this.getClass()); final LoggerContext ctx = (LoggerContext) LogManager.getContext(false); ctx.stop(); ctx.start(); @@ -86,7 +86,7 @@ public class JiraLog4j2_2134Test { @Test public void testRefreshMinimalCodeStopStartConfig() { - Logger log = LogManager.getLogger(this.getClass()); + final Logger log = LogManager.getLogger(this.getClass()); final LoggerContext ctx = (LoggerContext) LogManager.getContext(false); final Configuration config = ctx.getConfiguration(); ctx.stop(); @@ -98,18 +98,18 @@ public class JiraLog4j2_2134Test { @SuppressWarnings("deprecation") @Test public void testRefreshDeprecatedApis() { - Logger log = LogManager.getLogger(this.getClass()); + final Logger log = LogManager.getLogger(this.getClass()); final LoggerContext ctx = (LoggerContext) LogManager.getContext(false); final Configuration config = ctx.getConfiguration(); - PatternLayout layout = PatternLayout.createLayout(PatternLayout.SIMPLE_CONVERSION_PATTERN, null, config, null, + final PatternLayout layout = PatternLayout.createLayout(PatternLayout.SIMPLE_CONVERSION_PATTERN, null, config, null, null, false, false, null, null); - Appender appender = FileAppender.createAppender("target/test.log", "false", "false", "File", "true", "false", + final Appender appender = FileAppender.createAppender("target/test.log", "false", "false", "File", "true", "false", "false", "4000", layout, null, "false", null, config); appender.start(); config.addAppender(appender); - AppenderRef ref = AppenderRef.createAppenderRef("File", null, null); - AppenderRef[] refs = new AppenderRef[] { ref }; - LoggerConfig loggerConfig = LoggerConfig.createLogger("false", Level.INFO, "testlog4j2refresh", "true", refs, + final AppenderRef ref = AppenderRef.createAppenderRef("File", null, null); + final AppenderRef[] refs = new AppenderRef[] { ref }; + final LoggerConfig loggerConfig = LoggerConfig.createLogger("false", Level.INFO, "testlog4j2refresh", "true", refs, null, config, null); loggerConfig.addAppender(appender, null, null); config.addLogger("testlog4j2refresh", loggerConfig); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/config/LoggerConfigTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/LoggerConfigTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/LoggerConfigTest.java index a7cceff..ab4acdb 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/LoggerConfigTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/LoggerConfigTest.java @@ -79,7 +79,7 @@ public class LoggerConfigTest { }; final LoggerConfig loggerConfig = createForProperties(all); final List<Property> list = loggerConfig.getPropertyList(); - assertEquals("map and list contents equal", new HashSet<>(list), + assertEquals("map and list contents equal", new HashSet<>(list), new HashSet<>(loggerConfig.getPropertyList())); final Object[] actualListHolder = new Object[1]; http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/config/NestedLoggerConfigTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/NestedLoggerConfigTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/NestedLoggerConfigTest.java index bbc9837..3f39648 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/NestedLoggerConfigTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/NestedLoggerConfigTest.java @@ -18,28 +18,17 @@ package org.apache.logging.log4j.core.config; import com.google.common.collect.ImmutableList; import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.Marker; -import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.core.config.xml.XmlConfiguration; -import org.apache.logging.log4j.core.impl.Log4jLogEvent.Builder; -import org.apache.logging.log4j.core.impl.LogEventFactory; -import org.apache.logging.log4j.message.Message; -import org.apache.logging.log4j.message.SimpleMessage; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import java.io.IOException; import java.io.InputStream; -import java.nio.file.Path; -import java.util.HashSet; import java.util.List; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; /** * Tests for LoggerConfig hierarchies. @@ -54,13 +43,13 @@ public class NestedLoggerConfigTest { private final String prefix; - public NestedLoggerConfigTest(String prefix) { + public NestedLoggerConfigTest(final String prefix) { this.prefix = prefix; } @Test public void testInheritParentDefaultLevel() throws IOException { - Configuration configuration = loadConfiguration(prefix + "default-level.xml"); + final Configuration configuration = loadConfiguration(prefix + "default-level.xml"); try { assertEquals(Level.ERROR, configuration.getLoggerConfig("com.foo").getLevel()); } finally { @@ -70,7 +59,7 @@ public class NestedLoggerConfigTest { @Test public void testInheritParentLevel() throws IOException { - Configuration configuration = loadConfiguration(prefix + "inherit-level.xml"); + final Configuration configuration = loadConfiguration(prefix + "inherit-level.xml"); try { assertEquals(Level.TRACE, configuration.getLoggerConfig("com.foo").getLevel()); } finally { @@ -78,10 +67,10 @@ public class NestedLoggerConfigTest { } } - private Configuration loadConfiguration(String resourcePath) throws IOException { - InputStream in = getClass().getClassLoader().getResourceAsStream(resourcePath); + private Configuration loadConfiguration(final String resourcePath) throws IOException { + final InputStream in = getClass().getClassLoader().getResourceAsStream(resourcePath); try { - Configuration configuration = new XmlConfiguration(new LoggerContext("test"), new ConfigurationSource(in)); + final Configuration configuration = new XmlConfiguration(new LoggerContext("test"), new ConfigurationSource(in)); configuration.initialize(); configuration.start(); return configuration; http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java index 33e0ee1..ed2db6e 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java @@ -47,7 +47,7 @@ public class ResolverUtilCustomProtocolTest { @Rule public RuleChain chain = RuleChain.outerRule(new CleanFolders(ResolverUtilTest.WORK_DIR)); - + static class NoopURLStreamHandlerFactory implements URLStreamHandlerFactory { @Override http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java index 1c6371b..a9de08a 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java @@ -51,7 +51,7 @@ public class ResolverUtilTest { @Rule public RuleChain chain = RuleChain.outerRule(new CleanFolders(WORK_DIR)); - + @Test public void testExtractPathFromJarUrl() throws Exception { final URL url = new URL("jar:file:/C:/Users/me/.m2/repository/junit/junit/4.11/junit-4.11.jar!/org/junit/Test.class"); @@ -193,29 +193,29 @@ public class ResolverUtilTest { if (!parent.exists()) { assertTrue("Create customplugin" + suffix + " folder KO", f.getParentFile().mkdirs()); } - + final String content = new String(Files.readAllBytes(orig.toPath())) .replaceAll("FixedString", "FixedString" + suffix) .replaceAll("customplugin", "customplugin" + suffix); Files.write(f.toPath(), content.getBytes()); - + PluginManagerPackagesTest.compile(f); return workDir; } static void createJar(final URI jarURI, final File workDir, final File f) throws Exception { - final Map<String, String> env = new HashMap<>(); + final Map<String, String> env = new HashMap<>(); env.put("create", "true"); final URI uri = URI.create("jar:file://" + jarURI.getRawPath()); - try (FileSystem zipfs = FileSystems.newFileSystem(uri, env)) { + try (FileSystem zipfs = FileSystems.newFileSystem(uri, env)) { final Path path = zipfs.getPath(workDir.toPath().relativize(f.toPath()).toString()); if (path.getParent() != null) { Files.createDirectories(path.getParent()); } Files.copy(f.toPath(), - path, - StandardCopyOption.REPLACE_EXISTING ); - } + path, + StandardCopyOption.REPLACE_EXISTING ); + } } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithTypedBuilderTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithTypedBuilderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithTypedBuilderTest.java index ae236b4..2b0ebd1 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithTypedBuilderTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/validation/validators/ValidatingPluginWithTypedBuilderTest.java @@ -48,7 +48,7 @@ public class ValidatingPluginWithTypedBuilderTest { @Test public void testNullDefaultValue() throws Exception { // @formatter:off - final ValidatingPluginWithTypedBuilder validatingPlugin = (ValidatingPluginWithTypedBuilder) + final ValidatingPluginWithTypedBuilder validatingPlugin = (ValidatingPluginWithTypedBuilder) new PluginBuilder(plugin). withConfiguration(new NullConfiguration()). withConfigurationNode(node).build(); @@ -60,7 +60,7 @@ public class ValidatingPluginWithTypedBuilderTest { public void testNonNullValue() throws Exception { node.getAttributes().put("name", "foo"); // @formatter:off - final ValidatingPluginWithTypedBuilder validatingPlugin = (ValidatingPluginWithTypedBuilder) + final ValidatingPluginWithTypedBuilder validatingPlugin = (ValidatingPluginWithTypedBuilder) new PluginBuilder(plugin). withConfiguration(new NullConfiguration()). withConfigurationNode(node).build(); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilterTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilterTest.java index 0488d0f..fce48e5 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilterTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/DynamicThresholdFilterTest.java @@ -45,8 +45,8 @@ import org.junit.Test; public class DynamicThresholdFilterTest { @Rule - public final ThreadContextMapRule threadContextRule = new ThreadContextMapRule(); - + public final ThreadContextMapRule threadContextRule = new ThreadContextMapRule(); + @After public void cleanup() { final LoggerContext ctx = LoggerContext.getContext(false); @@ -88,11 +88,11 @@ public class DynamicThresholdFilterTest { filter.start(); assertTrue(filter.isStarted()); final Object [] replacements = {"one", "two", "three"}; - assertSame(Filter.Result.ACCEPT, filter.filter(null, Level.DEBUG, null, "some test message", replacements)); - assertSame(Filter.Result.ACCEPT, filter.filter(null, Level.DEBUG, null, "some test message", "one", "two", "three")); + assertSame(Filter.Result.ACCEPT, filter.filter(null, Level.DEBUG, null, "some test message", replacements)); + assertSame(Filter.Result.ACCEPT, filter.filter(null, Level.DEBUG, null, "some test message", "one", "two", "three")); ThreadContext.clearMap(); } - + @Test public void testConfig() { try (final LoggerContext ctx = Configurator.initialize("Test1", http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/LevelRangeFilterTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/LevelRangeFilterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/LevelRangeFilterTest.java index b99c6a9..336d3ce 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/LevelRangeFilterTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/LevelRangeFilterTest.java @@ -56,5 +56,5 @@ public class LevelRangeFilterTest { assertTrue(filter.isStarted()); assertSame(Filter.Result.NEUTRAL, filter.filter(null, Level.ERROR, null, (Object) null, (Throwable) null)); } - + } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/FactoryTestStringMap.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/FactoryTestStringMap.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/FactoryTestStringMap.java index 47872fa..aacdf2d 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/FactoryTestStringMap.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/FactoryTestStringMap.java @@ -63,7 +63,7 @@ public class FactoryTestStringMap implements IndexedStringMap { } @Override - public String getKeyAt(int index) { + public String getKeyAt(final int index) { return null; } @@ -73,12 +73,12 @@ public class FactoryTestStringMap implements IndexedStringMap { } @Override - public <V> V getValueAt(int index) { + public <V> V getValueAt(final int index) { return null; } @Override - public int indexOfKey(String key) { + public int indexOfKey(final String key) { return 0; } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventNanoTimeTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventNanoTimeTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventNanoTimeTest.java index 93d60c4..caae76b 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventNanoTimeTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/Log4jLogEventNanoTimeTest.java @@ -62,7 +62,7 @@ public class Log4jLogEventNanoTimeTest { Log4jLogEvent.setNanoClock(new DummyNanoClock(DUMMYNANOTIME)); log.info("Use dummy nano clock"); assertTrue("using SystemNanoClock", Log4jLogEvent.getNanoClock() instanceof DummyNanoClock); - + CoreLoggerContexts.stopLoggerContext(file); // stop async thread String line1; @@ -82,7 +82,7 @@ public class Log4jLogEventNanoTimeTest { assertEquals(line1Parts[0], line1Parts[1]); final long loggedNanoTime = Long.parseLong(line1Parts[0]); assertTrue("used system nano time", loggedNanoTime - before < TimeUnit.SECONDS.toNanos(1)); - + final String[] line2Parts = line2.split(" AND "); assertEquals("Use dummy nano clock", line2Parts[2]); assertEquals(String.valueOf(DUMMYNANOTIME), line2Parts[0]); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java index 273502a..033cc9d 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/MutableLogEventTest.java @@ -63,7 +63,7 @@ public class MutableLogEventTest { try { Class.forName("java.io.ObjectInputFilter"); useObjectInputStream = true; - } catch (ClassNotFoundException ex) { + } catch (final ClassNotFoundException ex) { // Ignore the exception } } @@ -116,7 +116,7 @@ public class MutableLogEventTest { @Test public void testInitFromReusableCopiesFormatString() { - Message message = ReusableMessageFactory.INSTANCE.newMessage("msg in a {}", "bottle"); + final Message message = ReusableMessageFactory.INSTANCE.newMessage("msg in a {}", "bottle"); final Log4jLogEvent source = Log4jLogEvent.newBuilder() // .setContextData(CONTEXT_DATA) // .setContextStack(STACK) // @@ -138,17 +138,17 @@ public class MutableLogEventTest { assertEquals("format", "msg in a {}", mutable.getFormat()); assertEquals("formatted", "msg in a bottle", mutable.getFormattedMessage()); assertEquals("parameters", new String[] {"bottle"}, mutable.getParameters()); - Message memento = mutable.memento(); + final Message memento = mutable.memento(); assertEquals("format", "msg in a {}", memento.getFormat()); assertEquals("formatted", "msg in a bottle", memento.getFormattedMessage()); assertEquals("parameters", new String[] {"bottle"}, memento.getParameters()); - Message eventMementoMessage = mutable.createMemento().getMessage(); + final Message eventMementoMessage = mutable.createMemento().getMessage(); assertEquals("format", "msg in a {}", eventMementoMessage.getFormat()); assertEquals("formatted", "msg in a bottle", eventMementoMessage.getFormattedMessage()); assertEquals("parameters", new String[] {"bottle"}, eventMementoMessage.getParameters()); - Message log4JLogEventMessage = new Log4jLogEvent.Builder(mutable).build().getMessage(); + final Message log4JLogEventMessage = new Log4jLogEvent.Builder(mutable).build().getMessage(); assertEquals("format", "msg in a {}", log4JLogEventMessage.getFormat()); assertEquals("formatted", "msg in a bottle", log4JLogEventMessage.getFormattedMessage()); assertEquals("parameters", new String[] {"bottle"}, log4JLogEventMessage.getParameters()); @@ -156,8 +156,8 @@ public class MutableLogEventTest { @Test public void testInitFromReusableObjectCopiesParameter() { - Object param = new Object(); - Message message = ReusableMessageFactory.INSTANCE.newMessage(param); + final Object param = new Object(); + final Message message = ReusableMessageFactory.INSTANCE.newMessage(param); final Log4jLogEvent source = Log4jLogEvent.newBuilder() .setContextData(CONTEXT_DATA) .setContextStack(STACK) @@ -180,7 +180,7 @@ public class MutableLogEventTest { assertNull("format", mutable.getFormat()); assertEquals("formatted", param.toString(), mutable.getFormattedMessage()); assertEquals("parameters", new Object[] {param}, mutable.getParameters()); - Message memento = mutable.memento(); + final Message memento = mutable.memento(); assertNull("format", memento.getFormat()); assertEquals("formatted", param.toString(), memento.getFormattedMessage()); assertEquals("parameters", new Object[] {param}, memento.getParameters()); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/NestedLoggingFromThrowableMessageTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/NestedLoggingFromThrowableMessageTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/NestedLoggingFromThrowableMessageTest.java index 912f1a8..2f1bc04 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/NestedLoggingFromThrowableMessageTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/NestedLoggingFromThrowableMessageTest.java @@ -76,8 +76,8 @@ public class NestedLoggingFromThrowableMessageTest { CoreLoggerContexts.stopLoggerContext(false, file1); CoreLoggerContexts.stopLoggerContext(false, file2); - Set<String> lines1 = readUniqueLines(file1); - Set<String> lines2 = readUniqueLines(file2); + final Set<String> lines1 = readUniqueLines(file1); + final Set<String> lines2 = readUniqueLines(file2); assertEquals("Expected the same data from both appenders", lines1, lines2); assertEquals(2, lines1.size()); @@ -85,9 +85,9 @@ public class NestedLoggingFromThrowableMessageTest { assertTrue(lines1.contains("ERROR NestedLoggingFromThrowableMessageTest Test message")); } - private static Set<String> readUniqueLines(File input) throws IOException { - Set<String> lines = new HashSet<>(); - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(input))); + private static Set<String> readUniqueLines(final File input) throws IOException { + final Set<String> lines = new HashSet<>(); + final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(input))); try { String line; while ((line = reader.readLine()) != null) { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/NestedLoggingFromToStringTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/NestedLoggingFromToStringTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/NestedLoggingFromToStringTest.java index d0c35cb..e95e308 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/NestedLoggingFromToStringTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/NestedLoggingFromToStringTest.java @@ -50,7 +50,7 @@ public class NestedLoggingFromToStringTest { public static void beforeClass() { System.setProperty("log4j2.is.webapp", "false"); } - + @Rule public LoggerContextRule context = new LoggerContextRule("log4j-sync-to-list.xml"); private ListAppender listAppender; http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjectorTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjectorTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjectorTest.java index f553d3a..2f913f7 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjectorTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThreadContextDataInjectorTest.java @@ -78,13 +78,13 @@ public class ThreadContextDataInjectorTest { } private void testContextDataInjector() { - ReadOnlyThreadContextMap readOnlythreadContextMap = getThreadContextMap(); + final ReadOnlyThreadContextMap readOnlythreadContextMap = getThreadContextMap(); assertThat("thread context map class name", (readOnlythreadContextMap == null) ? null : readOnlythreadContextMap.getClass().getName(), is(equalTo(readOnlythreadContextMapClassName))); - ContextDataInjector contextDataInjector = createInjector(); - StringMap stringMap = contextDataInjector.injectContextData(null, new SortedArrayStringMap()); + final ContextDataInjector contextDataInjector = createInjector(); + final StringMap stringMap = contextDataInjector.injectContextData(null, new SortedArrayStringMap()); assertThat("thread context map", ThreadContext.getContext(), allOf(hasEntry("foo", "bar"), not(hasKey("baz")))); assertThat("context map", stringMap.toMap(), allOf(hasEntry("foo", "bar"), not(hasKey("baz")))); @@ -106,7 +106,7 @@ public class ThreadContextDataInjectorTest { } } - private void prepareThreadContext(boolean isThreadContextMapInheritable) { + private void prepareThreadContext(final boolean isThreadContextMapInheritable) { System.setProperty("log4j2.isThreadContextMapInheritable", Boolean.toString(isThreadContextMapInheritable)); PropertiesUtil.getProperties().reload(); ThreadContextTest.reinitThreadContext(); @@ -130,7 +130,7 @@ public class ThreadContextDataInjectorTest { testContextDataInjector(); } }).get(); - } catch (ExecutionException ee) { + } catch (final ExecutionException ee) { throw ee.getCause(); } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableFormatOptionsTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableFormatOptionsTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableFormatOptionsTest.java index d099da1..be2fd7f 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableFormatOptionsTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableFormatOptionsTest.java @@ -37,7 +37,7 @@ public final class ThrowableFormatOptionsTest { /** * Runs a given test comparing against the expected values. - * + * * @param options * The list of options to parse. * @param expectedLines http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/jmx/ServerTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/jmx/ServerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/jmx/ServerTest.java index 2533869..57c8910 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/jmx/ServerTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/jmx/ServerTest.java @@ -33,7 +33,7 @@ public class ServerTest { final String ctx = "WebAppClassLoader=1320771902@4eb9613e"; // LOG4J2-492 final String ctxName = Server.escape(ctx); assertEquals("\"WebAppClassLoader=1320771902@4eb9613e\"", ctxName); - new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); + new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); // no MalformedObjectNameException = success } @@ -42,7 +42,7 @@ public class ServerTest { final String ctx = "a,b,c"; final String ctxName = Server.escape(ctx); assertEquals("\"a,b,c\"", ctxName); - new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); + new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); // no MalformedObjectNameException = success } @@ -51,7 +51,7 @@ public class ServerTest { final String ctx = "a:b:c"; final String ctxName = Server.escape(ctx); assertEquals("\"a:b:c\"", ctxName); - new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); + new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); // no MalformedObjectNameException = success } @@ -60,7 +60,7 @@ public class ServerTest { final String ctx = "a?c"; final String ctxName = Server.escape(ctx); assertEquals("\"a\\?c\"", ctxName); - new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); + new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); // no MalformedObjectNameException = success } @@ -69,7 +69,7 @@ public class ServerTest { final String ctx = "a*c"; final String ctxName = Server.escape(ctx); assertEquals("\"a\\*c\"", ctxName); - new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); + new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); // no MalformedObjectNameException = success } @@ -78,7 +78,7 @@ public class ServerTest { final String ctx = "a\\c"; final String ctxName = Server.escape(ctx); assertEquals("\"a\\\\c\"", ctxName); - new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); + new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); // no MalformedObjectNameException = success } @@ -87,7 +87,7 @@ public class ServerTest { final String ctx = "a\"c"; final String ctxName = Server.escape(ctx); assertEquals("\"a\\\"c\"", ctxName); - new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); + new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); // no MalformedObjectNameException = success } @@ -96,7 +96,7 @@ public class ServerTest { final String ctx = "a c"; final String ctxName = Server.escape(ctx); assertEquals("a c", ctxName); - new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); + new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); // no MalformedObjectNameException = success } @@ -105,7 +105,7 @@ public class ServerTest { final String ctx = "a\rc"; final String ctxName = Server.escape(ctx); assertEquals("ac", ctxName); - new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); + new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); // no MalformedObjectNameException = success } @@ -114,7 +114,7 @@ public class ServerTest { final String ctx = "a\nc"; final String ctxName = Server.escape(ctx); assertEquals("\"a\\nc\"", ctxName); - new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); + new ObjectName(String.format(LoggerContextAdminMBean.PATTERN, ctxName)); // no MalformedObjectNameException = success } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvLogEventLayoutTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvLogEventLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvLogEventLayoutTest.java index 0ee8861..078ed02 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvLogEventLayoutTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/CsvLogEventLayoutTest.java @@ -49,7 +49,7 @@ public class CsvLogEventLayoutTest { static ConfigurationFactory cf = new BasicConfigurationFactory(); @Rule - public final ThreadContextRule threadContextRule = new ThreadContextRule(); + public final ThreadContextRule threadContextRule = new ThreadContextRule(); @AfterClass public static void cleanupClass() { @@ -127,7 +127,7 @@ public class CsvLogEventLayoutTest { final String quote = del == ',' ? "\"" : ""; Assert.assertTrue(event0, event0.contains(del + quote + "one=1, two=2, three=3" + quote + del)); Assert.assertTrue(event1, event1.contains(del + "INFO" + del)); - + if (hasHeaderSerializer && header == null) { Assert.fail(); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java index 095bec6..e18bceb 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java @@ -45,9 +45,9 @@ import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals; import static org.junit.Assert.assertEquals; public class GelfLayoutTest { - + static ConfigurationFactory configFactory = new BasicConfigurationFactory(); - + private static final String HOSTNAME = "TheHost"; private static final String KEY1 = "Key1"; private static final String KEY2 = "Key2"; @@ -61,7 +61,7 @@ public class GelfLayoutTest { private static final String VALUE1 = "Value1"; @Rule - public final ThreadContextRule threadContextRule = new ThreadContextRule(); + public final ThreadContextRule threadContextRule = new ThreadContextRule(); @AfterClass public static void cleanupClass() { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/HtmlLayoutTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/HtmlLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/HtmlLayoutTest.java index 80acb1f..20a8dde 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/HtmlLayoutTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/HtmlLayoutTest.java @@ -46,7 +46,7 @@ public class HtmlLayoutTest { static ConfigurationFactory cf = new BasicConfigurationFactory(); @Rule - public final ThreadContextRule threadContextRule = new ThreadContextRule(); + public final ThreadContextRule threadContextRule = new ThreadContextRule(); @BeforeClass public static void setupClass() { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/JsonLayoutTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/JsonLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/JsonLayoutTest.java index 6eb5c4f..9dfade0 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/JsonLayoutTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/JsonLayoutTest.java @@ -391,7 +391,7 @@ public class JsonLayoutTest { .setCharset(StandardCharsets.UTF_8) .setIncludeStacktrace(true) .build(); - Message message = ReusableMessageFactory.INSTANCE.newMessage("Testing {}", new TestObj()); + final Message message = ReusableMessageFactory.INSTANCE.newMessage("Testing {}", new TestObj()); try { final Log4jLogEvent expected = Log4jLogEvent.newBuilder() .setLoggerName("a.B") @@ -400,7 +400,7 @@ public class JsonLayoutTest { .setMessage(message) .setThreadName("threadName") .setTimeMillis(1).build(); - MutableLogEvent mutableLogEvent = new MutableLogEvent(); + final MutableLogEvent mutableLogEvent = new MutableLogEvent(); mutableLogEvent.initFrom(expected); final String str = layout.toSerializable(mutableLogEvent); final String expectedMessage = "Testing " + TestObj.TO_STRING_VALUE; @@ -426,9 +426,9 @@ public class JsonLayoutTest { .setCharset(StandardCharsets.UTF_8) .setIncludeStacktrace(true) .build(); - Message message = ReusableMessageFactory.INSTANCE.newMessage("Testing {}", new TestObj()); + final Message message = ReusableMessageFactory.INSTANCE.newMessage("Testing {}", new TestObj()); try { - RingBufferLogEvent ringBufferEvent = new RingBufferLogEvent(); + final RingBufferLogEvent ringBufferEvent = new RingBufferLogEvent(); ringBufferEvent.setValues( null, "a.B", null, "f.q.c.n", Level.DEBUG, message, null, new SortedArrayStringMap(), ThreadContext.EMPTY_STACK, 1L, @@ -499,19 +499,19 @@ public class JsonLayoutTest { // @formatter:off return layout.toSerializable(expected); } - + @Test public void testObjectMessageAsJsonString() { final String str = prepareJSONForObjectMessageAsJsonObjectTests(1234, false); assertTrue(str, str.contains("\"message\":\"" + this.getClass().getCanonicalName() + "$TestClass@")); } - + @Test public void testObjectMessageAsJsonObject() { final String str = prepareJSONForObjectMessageAsJsonObjectTests(1234, true); assertTrue(str, str.contains("\"message\":{\"value\":1234}")); } - + private String prepareJSONForObjectMessageAsJsonObjectTests(final int value, final boolean objectMessageAsJsonObject) { final TestClass testClass = new TestClass(); testClass.setValue(value); @@ -551,11 +551,11 @@ public class JsonLayoutTest { final String str = layout.toSerializable(LogEventFixtures.createLogEvent()); assertFalse(str.endsWith("\0")); } - + private String toPropertySeparator(final boolean compact) { return compact ? ":" : " : "; } - + private static class TestClass { private int value; @@ -563,7 +563,7 @@ public class JsonLayoutTest { return value; } - public void setValue(int value) { + public void setValue(final int value) { this.value = value; } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_1482_Test.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_1482_Test.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_1482_Test.java index abd1852..3c94d58 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_1482_Test.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_1482_Test.java @@ -42,7 +42,7 @@ import org.junit.experimental.categories.Category; public abstract class Log4j2_1482_Test { static final String CONFIG_LOCATION = "log4j2-1482.xml"; - + static final String FOLDER = "target/log4j2-1482"; private static final int LOOP_COUNT = 10; http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_2195_Test.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_2195_Test.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_2195_Test.java index 958e38a..5112e5d 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_2195_Test.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Log4j2_2195_Test.java @@ -41,20 +41,20 @@ public class Log4j2_2195_Test { @Test public void test() { logger.info("This is a test.", new Exception("Test exception!")); - ListAppender listAppender = loggerContextRule.getListAppender("ListAppender"); + final ListAppender listAppender = loggerContextRule.getListAppender("ListAppender"); Assert.assertNotNull(listAppender); - List<String> events = listAppender.getMessages(); + final List<String> events = listAppender.getMessages(); Assert.assertNotNull(events); Assert.assertEquals(1, events.size()); - String logEvent = events.get(0); + final String logEvent = events.get(0); Assert.assertNotNull(logEvent); Assert.assertFalse("\"org.junit\" should not be here", logEvent.contains("org.junit")); Assert.assertFalse("\"org.eclipse\" should not be here", logEvent.contains("org.eclipse")); // - Layout<? extends Serializable> layout = listAppender.getLayout(); - PatternLayout pLayout = (PatternLayout) layout; + final Layout<? extends Serializable> layout = listAppender.getLayout(); + final PatternLayout pLayout = (PatternLayout) layout; Assert.assertNotNull(pLayout); - Serializer eventSerializer = pLayout.getEventSerializer(); + final Serializer eventSerializer = pLayout.getEventSerializer(); Assert.assertNotNull(eventSerializer); // Assert.assertTrue("Missing \"|\"", logEvent.contains("|")); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Rfc5424LayoutTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Rfc5424LayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Rfc5424LayoutTest.java index db70075..0b9b50d 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Rfc5424LayoutTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/Rfc5424LayoutTest.java @@ -73,7 +73,7 @@ public class Rfc5424LayoutTest { static ConfigurationFactory cf = new BasicConfigurationFactory(); @Rule - public final ThreadContextRule threadContextRule = new ThreadContextRule(); + public final ThreadContextRule threadContextRule = new ThreadContextRule(); @BeforeClass public static void setupClass() { @@ -195,15 +195,15 @@ public class Rfc5424LayoutTest { final StructuredDataMessage msg2 = new StructuredDataMessage("Extra@18060", null, "Audit"); msg2.put("Item1", "Hello"); msg2.put("Item2", "World"); - List<StructuredDataMessage> messages = new ArrayList<>(); + final List<StructuredDataMessage> messages = new ArrayList<>(); messages.add(msg); messages.add(msg2); final StructuredDataCollectionMessage collectionMessage = new StructuredDataCollectionMessage(messages); root.info(MarkerManager.getMarker("EVENT"), collectionMessage); - List<String> list = appender.getMessages(); - String result = list.get(0); + final List<String> list = appender.getMessages(); + final String result = list.get(0); assertTrue("Expected line to contain " + collectionLine1 + ", Actual " + result, result.contains(collectionLine1)); assertTrue("Expected line to contain " + collectionLine2 + ", Actual " + result, http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SerializedLayoutTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SerializedLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SerializedLayoutTest.java index c01c82e..da20507 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SerializedLayoutTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SerializedLayoutTest.java @@ -59,14 +59,14 @@ public class SerializedLayoutTest { static boolean useObjectInputStream = false; @Rule - public final ThreadContextRule threadContextRule = new ThreadContextRule(); + public final ThreadContextRule threadContextRule = new ThreadContextRule(); @BeforeClass public static void setupClass() { try { Class.forName("java.io.ObjectInputFilter"); useObjectInputStream = true; - } catch (ClassNotFoundException ex) { + } catch (final ClassNotFoundException ex) { // Ignore the exception } ConfigurationFactory.setConfigurationFactory(cf); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SyslogLayoutTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SyslogLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SyslogLayoutTest.java index b5bea03..d9bd5b0 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SyslogLayoutTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SyslogLayoutTest.java @@ -55,7 +55,7 @@ public class SyslogLayoutTest { static ConfigurationFactory cf = new BasicConfigurationFactory(); @Rule - public final ThreadContextRule threadContextRule = new ThreadContextRule(); + public final ThreadContextRule threadContextRule = new ThreadContextRule(); @BeforeClass public static void setupClass() { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/XmlLayoutTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/XmlLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/XmlLayoutTest.java index 4ee8f1e..9d97f6a 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/XmlLayoutTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/XmlLayoutTest.java @@ -61,7 +61,7 @@ public class XmlLayoutTest { private static final String markerTag = "<Marker name=\"EVENT\"/>"; @Rule - public final ThreadContextRule threadContextRule = new ThreadContextRule(); + public final ThreadContextRule threadContextRule = new ThreadContextRule(); @AfterClass public static void cleanupClass() { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MainInputArgumentsJmxLookupTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MainInputArgumentsJmxLookupTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MainInputArgumentsJmxLookupTest.java index be1f587..22583d3 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MainInputArgumentsJmxLookupTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MainInputArgumentsJmxLookupTest.java @@ -22,9 +22,9 @@ import org.junit.Test; /** * Tests {@link JmxRuntimeInputArgumentsLookup} from the command line, not a JUnit test. - * + * * From an IDE or CLI: --file foo.txt - * + * * @since 2.1 */ public class MainInputArgumentsJmxLookupTest { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MainInputArgumentsLookupTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MainInputArgumentsLookupTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MainInputArgumentsLookupTest.java index 6150afd..966c6fd 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MainInputArgumentsLookupTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MainInputArgumentsLookupTest.java @@ -23,9 +23,9 @@ import org.apache.logging.log4j.core.config.Configurator; /** * Tests {@link org.apache.logging.log4j.core.lookup.MainMapLookup#MAIN_SINGLETON} from the command line, not a real * JUnit test. - * + * * From an IDE or CLI: --file foo.txt - * + * * @since 2.4 */ public class MainInputArgumentsLookupTest { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MainInputArgumentsMapLookup.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MainInputArgumentsMapLookup.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MainInputArgumentsMapLookup.java index f6bad22..1ec64a8 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MainInputArgumentsMapLookup.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MainInputArgumentsMapLookup.java @@ -20,7 +20,7 @@ import java.util.Map; /** * Work in progress, saved for future experimentation. - * + * * TODO The goal is to use the Sun debugger API to find the main arg values on the stack. */ public class MainInputArgumentsMapLookup extends MapLookup { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MarkerLookupConfigTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MarkerLookupConfigTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MarkerLookupConfigTest.java index 62f8897..e3ce8d4 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MarkerLookupConfigTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MarkerLookupConfigTest.java @@ -31,7 +31,7 @@ import org.junit.Test; /** * Tests {@link MarkerLookup} with a configuration file. - * + * * @since 2.4 */ public class MarkerLookupConfigTest { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MarkerLookupTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MarkerLookupTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MarkerLookupTest.java index d26f895..fac33d4 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MarkerLookupTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/MarkerLookupTest.java @@ -29,7 +29,7 @@ import org.junit.Test; /** * Tests {@link MarkerLookup}. - * + * * @since 2.4 */ public class MarkerLookupTest { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/net/mock/MockTcpSyslogServer.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/mock/MockTcpSyslogServer.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/mock/MockTcpSyslogServer.java index ea41e61..919eebc 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/mock/MockTcpSyslogServer.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/mock/MockTcpSyslogServer.java @@ -46,7 +46,7 @@ public class MockTcpSyslogServer extends MockSyslogServer { thread.interrupt(); try { thread.join(100); - } catch (InterruptedException ie) { + } catch (final InterruptedException ie) { System.out.println("Shutdown of TCP server thread failed."); } } @@ -76,7 +76,7 @@ public class MockTcpSyslogServer extends MockSyslogServer { System.out.println("Message too long"); } } - } catch (BindException be) { + } catch (final BindException be) { be.printStackTrace(); } finally { if (socket != null) { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/net/mock/MockTlsSyslogServer.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/mock/MockTlsSyslogServer.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/mock/MockTlsSyslogServer.java index a445464..b116e40 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/mock/MockTlsSyslogServer.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/mock/MockTlsSyslogServer.java @@ -67,7 +67,7 @@ public class MockTlsSyslogServer extends MockSyslogServer { if (thread != null) { try { thread.join(100); - } catch (InterruptedException ie) { + } catch (final InterruptedException ie) { System.out.println("Shutdown of TLS server thread failed."); } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/net/mock/MockUdpSyslogServer.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/mock/MockUdpSyslogServer.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/mock/MockUdpSyslogServer.java index a74940b..a41b26b 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/mock/MockUdpSyslogServer.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/mock/MockUdpSyslogServer.java @@ -42,7 +42,7 @@ public class MockUdpSyslogServer extends MockSyslogServer { thread.interrupt(); try { thread.join(100); - } catch (InterruptedException ie) { + } catch (final InterruptedException ie) { System.out.println("Shutdown of Log4j UDP server thread failed."); } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/FilePasswordProviderTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/FilePasswordProviderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/FilePasswordProviderTest.java index 26cda80..13ca8a4 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/FilePasswordProviderTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/FilePasswordProviderTest.java @@ -31,7 +31,7 @@ public class FilePasswordProviderTest { final Path path = Files.createTempFile("testPass", ".txt"); Files.write(path, PASSWORD.getBytes(Charset.defaultCharset())); - char[] actual = new FilePasswordProvider(path.toString()).getPassword(); + final char[] actual = new FilePasswordProvider(path.toString()).getPassword(); Files.delete(path); assertArrayEquals(PASSWORD.toCharArray(), actual); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/MemoryPasswordProviderTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/MemoryPasswordProviderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/MemoryPasswordProviderTest.java index df4b5f2..99b3097 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/MemoryPasswordProviderTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/net/ssl/MemoryPasswordProviderTest.java @@ -29,16 +29,16 @@ public class MemoryPasswordProviderTest { @Test public void testConstructorDoesNotModifyOriginalParameterArray() { - char[] initial = "123".toCharArray(); + final char[] initial = "123".toCharArray(); new MemoryPasswordProvider(initial); assertArrayEquals("123".toCharArray(), initial); } @Test public void testGetPasswordReturnsCopyOfConstructorArray() { - char[] initial = "123".toCharArray(); - MemoryPasswordProvider provider = new MemoryPasswordProvider(initial); - char[] actual = provider.getPassword(); + final char[] initial = "123".toCharArray(); + final MemoryPasswordProvider provider = new MemoryPasswordProvider(initial); + final char[] actual = provider.getPassword(); assertArrayEquals("123".toCharArray(), actual); assertNotSame(initial, actual); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java index 728254a..affb5b2 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DatePatternConverterTest.java @@ -150,8 +150,8 @@ public class DatePatternConverterTest { } } - private String precisePattern(final String pattern, int precision) { - String seconds = pattern.substring(0, pattern.indexOf("SSS")); + private String precisePattern(final String pattern, final int precision) { + final String seconds = pattern.substring(0, pattern.indexOf("SSS")); return seconds + "nnnnnnnnn".substring(0, precision); } @@ -162,7 +162,7 @@ public class DatePatternConverterTest { final StringBuilder milli = new StringBuilder(); final LogEvent event = new MyLogEvent(); - for (String timeZone : new String[]{"PDT", null}) { // Pacific Daylight Time=UTC-8:00 + for (final String timeZone : new String[]{"PDT", null}) { // Pacific Daylight Time=UTC-8:00 for (final FixedDateFormat.FixedFormat format : FixedDateFormat.FixedFormat.values()) { for (int i = 1; i <= 9; i++) { if (format.getPattern().endsWith("n")) { @@ -178,7 +178,7 @@ public class DatePatternConverterTest { final String[] milliOptions = {format.getPattern(), timeZone}; DatePatternConverter.newInstance(milliOptions).format(event, milli); milli.setLength(milli.length() - 3); // truncate millis - String expected = milli.append("987123456".substring(0, i)).toString(); + final String expected = milli.append("987123456".substring(0, i)).toString(); assertEquals(expected, precise.toString()); //System.out.println(preciseOptions[0] + ": " + precise); @@ -208,7 +208,7 @@ public class DatePatternConverterTest { final String[] milliOptions = {format.getPattern()}; DatePatternConverter.newInstance(milliOptions).format(event, milli); milli.setLength(milli.length() - 3); // truncate millis - String expected = milli.append("987123456").toString(); + final String expected = milli.append("987123456").toString(); assertEquals(expected, precise.toString()); //System.out.println(preciseOptions[0] + ": " + precise); @@ -228,7 +228,7 @@ public class DatePatternConverterTest { @Override public Instant getInstant() { - MutableInstant result = new MutableInstant(); + final MutableInstant result = new MutableInstant(); result.initFromEpochMilli(getTimeMillis(), 123456); return result; } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DisableAnsiTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DisableAnsiTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DisableAnsiTest.java index 7fea6fe..b841ea4 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DisableAnsiTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/DisableAnsiTest.java @@ -55,5 +55,5 @@ public class DisableAnsiTest { assertEquals("Incorrect number of messages. Should be 1 is " + msgs.size(), 1, msgs.size()); assertTrue("Replacement failed - expected ending " + EXPECTED + ", actual " + msgs.get(0), msgs.get(0).endsWith(EXPECTED)); } - + } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverterTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverterTest.java index 445b893..bcb9b1c 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverterTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/ExtendedThrowablePatternConverterTest.java @@ -159,7 +159,7 @@ public class ExtendedThrowablePatternConverterTest { final String expected = sw.toString(); //.replaceAll("\r", Strings.EMPTY); assertEquals(expected, result); } - + @Test public void testFiltersAndSeparator() { final ExtendedThrowablePatternConverter exConverter = ExtendedThrowablePatternConverter.newInstance(null, http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/HighlightConverterTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/HighlightConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/HighlightConverterTest.java index c3b1ba6..442c5ab 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/HighlightConverterTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/HighlightConverterTest.java @@ -53,10 +53,10 @@ public class HighlightConverterTest { converter.format(event, buffer); assertEquals("\u001B[32mINFO : message in a bottle\u001B[m", buffer.toString()); } - + @Test public void testLevelNamesBad() { - String colorName = "red"; + final String colorName = "red"; final String[] options = { "%-5level: %msg", PatternParser.NO_CONSOLE_NO_ANSI + "=false, " + PatternParser.DISABLE_ANSI + "=false, " + "BAD_LEVEL_A=" + colorName + ", BAD_LEVEL_B=" + colorName }; final HighlightConverter converter = HighlightConverter.newInstance(null, options); @@ -67,7 +67,7 @@ public class HighlightConverterTest { @Test public void testLevelNamesGood() { - String colorName = "red"; + final String colorName = "red"; final String[] options = { "%-5level: %msg", PatternParser.NO_CONSOLE_NO_ANSI + "=false, " + PatternParser.DISABLE_ANSI + "=false, " + "DEBUG=" + colorName + ", TRACE=" + colorName }; final HighlightConverter converter = HighlightConverter.newInstance(null, options); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MdcPatternConverterTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MdcPatternConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MdcPatternConverterTest.java index 00e97f7..4cb6c7d 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MdcPatternConverterTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MdcPatternConverterTest.java @@ -36,7 +36,7 @@ import org.junit.Test; public class MdcPatternConverterTest { @Rule - public final ThreadContextMapRule threadContextRule = new ThreadContextMapRule(); + public final ThreadContextMapRule threadContextRule = new ThreadContextMapRule(); @Before public void setup() {