http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 4dcd828..7e7c9a9 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 @@ -74,7 +74,7 @@ public class GelfLayoutTest { Logger root = ctx.getRootLogger(); - private void testCompressedLayout(final CompressionType compressionType, boolean includeStacktrace) throws IOException { + private void testCompressedLayout(final CompressionType compressionType, final boolean includeStacktrace) throws IOException { for (final Appender appender : root.getAppenders().values()) { root.removeAppender(appender); }
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java index d114bb8..5b51e96 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java @@ -44,7 +44,7 @@ import static org.junit.Assert.*; */ public class PatternLayoutTest { public class FauxLogger { - public String formatEvent(LogEvent event, Layout<?> layout) { + public String formatEvent(final LogEvent event, final Layout<?> layout) { return new String(layout.toByteArray(event)); } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternSelectorTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternSelectorTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternSelectorTest.java index 5fb0d74..82f710f 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternSelectorTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternSelectorTest.java @@ -1,65 +1,65 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache license, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the license for the specific language governing permissions and - * limitations under the license. - */ -package org.apache.logging.log4j.core.layout; - -import static org.junit.Assert.assertTrue; - -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.MarkerManager; -import org.apache.logging.log4j.core.Layout; -import org.apache.logging.log4j.core.LogEvent; -import org.apache.logging.log4j.core.LoggerContext; -import org.apache.logging.log4j.core.impl.Log4jLogEvent; -import org.apache.logging.log4j.message.SimpleMessage; -import org.junit.Test; - -public class PatternSelectorTest { - - public class FauxLogger { - public String formatEvent(LogEvent event, Layout<?> layout) { - return new String(layout.toByteArray(event)); - } - } - - LoggerContext ctx = LoggerContext.getContext(); - - @Test - public void testPatternSelector() throws Exception { - PatternMatch[] patterns = new PatternMatch[1]; - patterns[0] = new PatternMatch("FLOW", "%d %-5p [%t]: ====== %C{1}.%M:%L %m ======%n"); - PatternSelector selector = MarkerPatternSelector.createSelector(patterns, "%d %-5p [%t]: %m%n", true, true, ctx.getConfiguration()); - final PatternLayout layout = PatternLayout.newBuilder().withPatternSelector(selector) - .withConfiguration(ctx.getConfiguration()).build(); - final LogEvent event1 = Log4jLogEvent.newBuilder() // - .setLoggerName(this.getClass().getName()).setLoggerFqcn("org.apache.logging.log4j.core.layout.PatternSelectorTest$FauxLogger") - .setMarker(MarkerManager.getMarker("FLOW")) - .setLevel(Level.TRACE) // - .setIncludeLocation(true) - .setMessage(new SimpleMessage("entry")).build(); - final String result1 = new FauxLogger().formatEvent(event1, layout); - final String expectSuffix1 = String.format("====== PatternSelectorTest.testPatternSelector:53 entry ======%n"); - assertTrue("Unexpected result: " + result1, result1.endsWith(expectSuffix1)); - final LogEvent event2 = Log4jLogEvent.newBuilder() // - .setLoggerName(this.getClass().getName()).setLoggerFqcn("org.apache.logging.log4j.core.Logger") // - .setLevel(Level.INFO) // - .setMessage(new SimpleMessage("Hello, world 1!")).build(); - final String result2 = new String(layout.toByteArray(event2)); - final String expectSuffix2 = String.format("Hello, world 1!%n"); - assertTrue("Unexpected result: " + result2, result2.endsWith(expectSuffix2)); - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ +package org.apache.logging.log4j.core.layout; + +import static org.junit.Assert.assertTrue; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.MarkerManager; +import org.apache.logging.log4j.core.Layout; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.impl.Log4jLogEvent; +import org.apache.logging.log4j.message.SimpleMessage; +import org.junit.Test; + +public class PatternSelectorTest { + + public class FauxLogger { + public String formatEvent(final LogEvent event, final Layout<?> layout) { + return new String(layout.toByteArray(event)); + } + } + + LoggerContext ctx = LoggerContext.getContext(); + + @Test + public void testPatternSelector() throws Exception { + PatternMatch[] patterns = new PatternMatch[1]; + patterns[0] = new PatternMatch("FLOW", "%d %-5p [%t]: ====== %C{1}.%M:%L %m ======%n"); + PatternSelector selector = MarkerPatternSelector.createSelector(patterns, "%d %-5p [%t]: %m%n", true, true, ctx.getConfiguration()); + final PatternLayout layout = PatternLayout.newBuilder().withPatternSelector(selector) + .withConfiguration(ctx.getConfiguration()).build(); + final LogEvent event1 = Log4jLogEvent.newBuilder() // + .setLoggerName(this.getClass().getName()).setLoggerFqcn("org.apache.logging.log4j.core.layout.PatternSelectorTest$FauxLogger") + .setMarker(MarkerManager.getMarker("FLOW")) + .setLevel(Level.TRACE) // + .setIncludeLocation(true) + .setMessage(new SimpleMessage("entry")).build(); + final String result1 = new FauxLogger().formatEvent(event1, layout); + final String expectSuffix1 = String.format("====== PatternSelectorTest.testPatternSelector:53 entry ======%n"); + assertTrue("Unexpected result: " + result1, result1.endsWith(expectSuffix1)); + final LogEvent event2 = Log4jLogEvent.newBuilder() // + .setLoggerName(this.getClass().getName()).setLoggerFqcn("org.apache.logging.log4j.core.Logger") // + .setLevel(Level.INFO) // + .setMessage(new SimpleMessage("Hello, world 1!")).build(); + final String result2 = new String(layout.toByteArray(event2)); + final String expectSuffix2 = String.format("Hello, world 1!%n"); + assertTrue("Unexpected result: " + result2, result2.endsWith(expectSuffix2)); + } + +} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SpyByteBufferDestination.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SpyByteBufferDestination.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SpyByteBufferDestination.java index 5d8f3b5..b7e7ff8 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SpyByteBufferDestination.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/SpyByteBufferDestination.java @@ -42,7 +42,7 @@ public class SpyByteBufferDestination implements ByteBufferDestination { } } - public SpyByteBufferDestination(int bufferSize, int destinationSize) { + public SpyByteBufferDestination(final int bufferSize, final int destinationSize) { buffer = ByteBuffer.wrap(new byte[bufferSize]); drained = ByteBuffer.wrap(new byte[destinationSize]); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/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 3455d30..4a5669c 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 @@ -55,7 +55,7 @@ public class DatePatternConverterTest { return Arrays.asList(new Object[][]{{Boolean.TRUE}, {Boolean.FALSE}}); } - public DatePatternConverterTest(Boolean threadLocalEnabled) throws Exception { + public DatePatternConverterTest(final Boolean threadLocalEnabled) throws Exception { // Setting the system property does not work: the Constant field has already been initialized... //System.setProperty("log4j2.enable.threadlocals", threadLocalEnabled.toString()); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/EqualsIgnoreCaseReplacementConverterTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/EqualsIgnoreCaseReplacementConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/EqualsIgnoreCaseReplacementConverterTest.java index 26200eb..ff03b72 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/EqualsIgnoreCaseReplacementConverterTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/EqualsIgnoreCaseReplacementConverterTest.java @@ -46,7 +46,7 @@ public class EqualsIgnoreCaseReplacementConverterTest { testReplacement("%logger", "aaa[" + EqualsIgnoreCaseReplacementConverterTest.class.getName() + "]zzz"); } - private void testReplacement(String tag, String expectedValue) { + private void testReplacement(final String tag, final String expectedValue) { final LogEvent event = Log4jLogEvent.newBuilder() // .setLoggerName(EqualsIgnoreCaseReplacementConverterTest.class.getName()) // .setLevel(Level.DEBUG) // http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java index c3e064e..69e0ec3 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest.java @@ -290,7 +290,7 @@ public class PatternParserTest { testFirstConverter(pattern, ThreadPriorityPatternConverter.class); } - private void testFirstConverter(final String pattern, Class<?> checkClass) { + private void testFirstConverter(final String pattern, final Class<?> checkClass) { final List<PatternFormatter> formatters = parser.parse(pattern); assertNotNull(formatters); final String msg = formatters.toString(); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/VariablesNotEmptyReplacementConverterTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/VariablesNotEmptyReplacementConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/VariablesNotEmptyReplacementConverterTest.java index 15be1ea..dd6f1b6 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/VariablesNotEmptyReplacementConverterTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/VariablesNotEmptyReplacementConverterTest.java @@ -61,7 +61,7 @@ public class VariablesNotEmptyReplacementConverterTest { testReplacement("%logger", "[" + VariablesNotEmptyReplacementConverterTest.class.getName() + "]"); } - private void testReplacement(String tag, String expectedValue) { + private void testReplacement(final String tag, final String expectedValue) { final LogEvent event = Log4jLogEvent.newBuilder() // .setLoggerName(VariablesNotEmptyReplacementConverterTest.class.getName()) // .setLevel(Level.DEBUG) // http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/core/util/WatchManagerTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/WatchManagerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/WatchManagerTest.java index 4953ac8..8b98134 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/WatchManagerTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/WatchManagerTest.java @@ -79,12 +79,12 @@ public class WatchManagerTest { private final Queue<File> queue; - public TestWatcher(Queue<File> queue) { + public TestWatcher(final Queue<File> queue) { this.queue = queue; } @Override - public void fileModified(File file) { + public void fileModified(final File file) { System.out.println(file.toString() + " was modified"); queue.add(file); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java index 9fc0ece..8c15ef2 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/junit/LoggerContextRule.java @@ -122,7 +122,7 @@ public class LoggerContextRule implements TestRule { * @param cls The target Appender class * @return the named Appender or {@code null} if it wasn't defined in the configuration. */ - public <T extends Appender> T getAppender(final String name, Class<T> cls) { + public <T extends Appender> T getAppender(final String name, final Class<T> cls) { return cls.cast(getConfiguration().getAppenders().get(name)); } @@ -200,7 +200,7 @@ public class LoggerContextRule implements TestRule { * @return the named Appender. * @throws AssertionError if the Appender doesn't exist. */ - public <T extends Appender> T getRequiredAppender(final String name, Class<T> cls) { + public <T extends Appender> T getRequiredAppender(final String name, final Class<T> cls) { final T appender = getAppender(name, cls); assertNotNull("Appender named " + name + " was null.", appender); return appender; http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/EncodingListAppender.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/EncodingListAppender.java b/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/EncodingListAppender.java index c7c07e5..1174174 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/EncodingListAppender.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/test/appender/EncodingListAppender.java @@ -33,11 +33,11 @@ import java.nio.ByteBuffer; */ public class EncodingListAppender extends ListAppender { - public EncodingListAppender(String name) { + public EncodingListAppender(final String name) { super(name); } - public EncodingListAppender(String name, Filter filter, Layout<? extends Serializable> layout, boolean newline, boolean raw) { + public EncodingListAppender(final String name, final Filter filter, final Layout<? extends Serializable> layout, final boolean newline, final boolean raw) { super(name, filter, layout, newline, raw); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7a5dcd43/log4j-jul/src/test/java/org/apache/logging/log4j/jul/AbstractLoggerTest.java ---------------------------------------------------------------------- diff --git a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/AbstractLoggerTest.java b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/AbstractLoggerTest.java index fb767b0..f81d3fa 100644 --- a/log4j-jul/src/test/java/org/apache/logging/log4j/jul/AbstractLoggerTest.java +++ b/log4j-jul/src/test/java/org/apache/logging/log4j/jul/AbstractLoggerTest.java @@ -126,7 +126,7 @@ public abstract class AbstractLoggerTest { testMessage("message{%s}"); } - private void testMessage(String string) { + private void testMessage(final String string) { final Logger root = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); root.info("Test info " + string); root.config("Test info " + string); @@ -173,7 +173,7 @@ public abstract class AbstractLoggerTest { testLambdaMessages("message{%s}"); } - private void testLambdaMessages(String string) { + private void testLambdaMessages(final String string) { // TODO FOR JAVA 8 // final Logger root = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); // root.info(() -> "Test info " + string);
