http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java index cd85071..577d26a 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/MessagePatternConverterTest.java @@ -149,13 +149,13 @@ public class MessagePatternConverterTest { @Test public void testMapMessageFormatJson() throws Exception { final MessagePatternConverter converter = MessagePatternConverter.newInstance(null, new String[]{"json"}); - Message msg = new StringMapMessage() + final Message msg = new StringMapMessage() .with("key", "val"); - LogEvent event = Log4jLogEvent.newBuilder() // + final LogEvent event = Log4jLogEvent.newBuilder() // .setLoggerName("MyLogger") // .setLevel(Level.DEBUG) // .setMessage(msg).build(); - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); converter.format(event, sb); assertEquals("Unexpected result", "{\"key\":\"val\"}", sb.toString()); } @@ -163,13 +163,13 @@ public class MessagePatternConverterTest { @Test public void testMapMessageFormatXml() throws Exception { final MessagePatternConverter converter = MessagePatternConverter.newInstance(null, new String[]{"xml"}); - Message msg = new StringMapMessage() + final Message msg = new StringMapMessage() .with("key", "val"); - LogEvent event = Log4jLogEvent.newBuilder() // + final LogEvent event = Log4jLogEvent.newBuilder() // .setLoggerName("MyLogger") // .setLevel(Level.DEBUG) // .setMessage(msg).build(); - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); converter.format(event, sb); assertEquals("Unexpected result", "<Map>\n <Entry key=\"key\">val</Entry>\n</Map>", sb.toString()); } @@ -177,13 +177,13 @@ public class MessagePatternConverterTest { @Test public void testMapMessageFormatDefault() throws Exception { final MessagePatternConverter converter = MessagePatternConverter.newInstance(null, null); - Message msg = new StringMapMessage() + final Message msg = new StringMapMessage() .with("key", "val"); - LogEvent event = Log4jLogEvent.newBuilder() // + final LogEvent event = Log4jLogEvent.newBuilder() // .setLoggerName("MyLogger") // .setLevel(Level.DEBUG) // .setMessage(msg).build(); - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); converter.format(event, sb); assertEquals("Unexpected result", "key=\"val\"", sb.toString()); } @@ -191,13 +191,13 @@ public class MessagePatternConverterTest { @Test public void testStructuredDataFormatFull() throws Exception { final MessagePatternConverter converter = MessagePatternConverter.newInstance(null, new String[]{"FULL"}); - Message msg = new StructuredDataMessage("id", "message", "type") + final Message msg = new StructuredDataMessage("id", "message", "type") .with("key", "val"); - LogEvent event = Log4jLogEvent.newBuilder() // + final LogEvent event = Log4jLogEvent.newBuilder() // .setLoggerName("MyLogger") // .setLevel(Level.DEBUG) // .setMessage(msg).build(); - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); converter.format(event, sb); assertEquals("Unexpected result", "type [id key=\"val\"] message", sb.toString()); }
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NdcPatternConverterTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NdcPatternConverterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NdcPatternConverterTest.java index 92557ec..4088a17 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NdcPatternConverterTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NdcPatternConverterTest.java @@ -31,7 +31,7 @@ import org.junit.Test; public class NdcPatternConverterTest { @Rule - public final ThreadContextStackRule threadContextRule = new ThreadContextStackRule(); + public final ThreadContextStackRule threadContextRule = new ThreadContextStackRule(); @Test public void testEmpty() { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NoConsoleNoAnsiTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NoConsoleNoAnsiTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NoConsoleNoAnsiTest.java index cc9ac03..ee29c6f 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NoConsoleNoAnsiTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/NoConsoleNoAnsiTest.java @@ -57,5 +57,5 @@ public class NoConsoleNoAnsiTest { 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/PatternParserTest2.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest2.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest2.java index 45c0a8b..22f9c28 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest2.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/PatternParserTest2.java @@ -74,7 +74,7 @@ public class PatternParserTest2 { /** * Format file name. - * + * * @param buf string buffer to which formatted file name is appended, may not be null. * @param objects objects to be evaluated in formatting, may not be null. */ http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementTest.java index f357111..16b08d9 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/RegexReplacementTest.java @@ -46,7 +46,7 @@ public class RegexReplacementTest { public static LoggerContextRule context = new LoggerContextRule(CONFIG); @Rule - public final ThreadContextMapRule threadContextRule = new ThreadContextMapRule(); + public final ThreadContextMapRule threadContextRule = new ThreadContextMapRule(); @Before public void setUp() throws Exception { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/time/MutableInstantTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/time/MutableInstantTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/time/MutableInstantTest.java index 63d3138..6bebbd1 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/time/MutableInstantTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/time/MutableInstantTest.java @@ -26,7 +26,7 @@ public class MutableInstantTest { @Test public void testGetEpochSecond() { - MutableInstant instant = new MutableInstant(); + final MutableInstant instant = new MutableInstant(); assertEquals("initial", 0, instant.getEpochSecond()); instant.initFromEpochSecond(123, 456); @@ -35,7 +35,7 @@ public class MutableInstantTest { instant.initFromEpochMilli(123456, 789012); assertEquals("returns converted value when initialized from milllis", 123, instant.getEpochSecond()); - MutableInstant other = new MutableInstant(); + final MutableInstant other = new MutableInstant(); other.initFromEpochSecond(788, 456); instant.initFrom(other); @@ -44,7 +44,7 @@ public class MutableInstantTest { @Test public void testGetNanoOfSecond() { - MutableInstant instant = new MutableInstant(); + final MutableInstant instant = new MutableInstant(); assertEquals("initial", 0, instant.getNanoOfSecond()); instant.initFromEpochSecond(123, 456); @@ -53,7 +53,7 @@ public class MutableInstantTest { instant.initFromEpochMilli(123456, 789012); assertEquals("returns converted value when initialized from milllis", 456789012, instant.getNanoOfSecond()); - MutableInstant other = new MutableInstant(); + final MutableInstant other = new MutableInstant(); other.initFromEpochSecond(788, 456); instant.initFrom(other); @@ -62,7 +62,7 @@ public class MutableInstantTest { @Test public void testGetEpochMillisecond() { - MutableInstant instant = new MutableInstant(); + final MutableInstant instant = new MutableInstant(); assertEquals("initial", 0, instant.getEpochMillisecond()); instant.initFromEpochMilli(123, 456); @@ -71,7 +71,7 @@ public class MutableInstantTest { instant.initFromEpochSecond(123, 456789012); assertEquals("returns converted value when initialized from seconds", 123456, instant.getEpochMillisecond()); - MutableInstant other = new MutableInstant(); + final MutableInstant other = new MutableInstant(); other.initFromEpochMilli(788, 456); instant.initFrom(other); @@ -80,7 +80,7 @@ public class MutableInstantTest { @Test public void getGetNanoOfMillisecond() { - MutableInstant instant = new MutableInstant(); + final MutableInstant instant = new MutableInstant(); assertEquals("initial", 0, instant.getNanoOfMillisecond()); instant.initFromEpochMilli(123, 456); @@ -89,7 +89,7 @@ public class MutableInstantTest { instant.initFromEpochSecond(123, 456789012); assertEquals("returns converted value when initialized from milllis", 789012, instant.getNanoOfMillisecond()); - MutableInstant other = new MutableInstant(); + final MutableInstant other = new MutableInstant(); other.initFromEpochMilli(788, 456); instant.initFrom(other); @@ -103,12 +103,12 @@ public class MutableInstantTest { @Test public void testInitFromInstantCopiesValues() { - MutableInstant other = new MutableInstant(); + final MutableInstant other = new MutableInstant(); other.initFromEpochSecond(788, 456); assertEquals("epochSec", 788, other.getEpochSecond()); assertEquals("NanosOfSec", 456, other.getNanoOfSecond()); - MutableInstant instant = new MutableInstant(); + final MutableInstant instant = new MutableInstant(); instant.initFrom(other); assertEquals("epochSec", 788, instant.getEpochSecond()); @@ -117,7 +117,7 @@ public class MutableInstantTest { @Test public void testInitFromEpochMillis() { - MutableInstant instant = new MutableInstant(); + final MutableInstant instant = new MutableInstant(); instant.initFromEpochMilli(123456, 789012); assertEquals("epochSec", 123, instant.getEpochSecond()); assertEquals("NanoOfSec", 456789012, instant.getNanoOfSecond()); @@ -127,26 +127,26 @@ public class MutableInstantTest { @Test(expected = IllegalArgumentException.class) public void testInitFromEpochMillisRejectsNegativeNanoOfMilli() { - MutableInstant instant = new MutableInstant(); + final MutableInstant instant = new MutableInstant(); instant.initFromEpochMilli(123456, -1); } @Test(expected = IllegalArgumentException.class) public void testInitFromEpochMillisRejectsTooLargeNanoOfMilli() { - MutableInstant instant = new MutableInstant(); + final MutableInstant instant = new MutableInstant(); instant.initFromEpochMilli(123456, 1000_000); } @Test public void testInitFromEpochMillisAcceptsTooMaxNanoOfMilli() { - MutableInstant instant = new MutableInstant(); + final MutableInstant instant = new MutableInstant(); instant.initFromEpochMilli(123456, 999_999); assertEquals("NanoOfMilli", 999_999, instant.getNanoOfMillisecond()); } @Test public void testInitFromEpochSecond() { - MutableInstant instant = new MutableInstant(); + final MutableInstant instant = new MutableInstant(); instant.initFromEpochSecond(123, 456789012); assertEquals("epochSec", 123, instant.getEpochSecond()); assertEquals("NanoOfSec", 456789012, instant.getNanoOfSecond()); @@ -156,26 +156,26 @@ public class MutableInstantTest { @Test(expected = IllegalArgumentException.class) public void testInitFromEpochSecondRejectsNegativeNanoOfMilli() { - MutableInstant instant = new MutableInstant(); + final MutableInstant instant = new MutableInstant(); instant.initFromEpochSecond(123456, -1); } @Test(expected = IllegalArgumentException.class) public void testInitFromEpochSecondRejectsTooLargeNanoOfMilli() { - MutableInstant instant = new MutableInstant(); + final MutableInstant instant = new MutableInstant(); instant.initFromEpochSecond(123456, 1000_000_000); } @Test public void testInitFromEpochSecondAcceptsTooMaxNanoOfMilli() { - MutableInstant instant = new MutableInstant(); + final MutableInstant instant = new MutableInstant(); instant.initFromEpochSecond(123456, 999_999_999); assertEquals("NanoOfSec", 999_999_999, instant.getNanoOfSecond()); } @Test public void testInstantToMillisAndNanos() { - long[] values = new long[2]; + final long[] values = new long[2]; MutableInstant.instantToMillisAndNanos(123456, 999_999_999, values); assertEquals(123456_999, values[0]); assertEquals(999_999, values[1]); @@ -183,9 +183,9 @@ public class MutableInstantTest { @Test public void testInitFromClock() { - MutableInstant instant = new MutableInstant(); + final MutableInstant instant = new MutableInstant(); - PreciseClock clock = new FixedPreciseClock(123456, 789012); + final PreciseClock clock = new FixedPreciseClock(123456, 789012); instant.initFrom(clock); assertEquals(123456, instant.getEpochMillisecond()); @@ -196,10 +196,10 @@ public class MutableInstantTest { @Test public void testEquals() { - MutableInstant instant = new MutableInstant(); + final MutableInstant instant = new MutableInstant(); instant.initFromEpochSecond(123, 456789012); - MutableInstant instant2 = new MutableInstant(); + final MutableInstant instant2 = new MutableInstant(); instant2.initFromEpochMilli(123456, 789012); assertEquals(instant, instant2); @@ -207,10 +207,10 @@ public class MutableInstantTest { @Test public void testHashCode() { - MutableInstant instant = new MutableInstant(); + final MutableInstant instant = new MutableInstant(); instant.initFromEpochSecond(123, 456789012); - MutableInstant instant2 = new MutableInstant(); + final MutableInstant instant2 = new MutableInstant(); instant2.initFromEpochMilli(123456, 789012); assertEquals(instant.hashCode(), instant2.hashCode()); @@ -222,7 +222,7 @@ public class MutableInstantTest { @Test public void testToString() { - MutableInstant instant = new MutableInstant(); + final MutableInstant instant = new MutableInstant(); instant.initFromEpochSecond(123, 456789012); assertEquals("MutableInstant[epochSecond=123, nano=456789012]", instant.toString()); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateCustomLoggerTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateCustomLoggerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateCustomLoggerTest.java index 0642253..15f43d0 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateCustomLoggerTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateCustomLoggerTest.java @@ -47,7 +47,7 @@ import org.junit.Test; import static org.junit.Assert.*; public class GenerateCustomLoggerTest { - + @BeforeClass public static void beforeClass() { System.setProperty("log4j2.loggerContextFactory", "org.apache.logging.log4j.TestLoggerContextFactory"); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateExtendedLoggerTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateExtendedLoggerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateExtendedLoggerTest.java index 914ada8..b97ef91 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateExtendedLoggerTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/tools/GenerateExtendedLoggerTest.java @@ -49,7 +49,7 @@ import org.junit.Test; import static org.junit.Assert.*; public class GenerateExtendedLoggerTest { - + @BeforeClass public static void beforeClass() { System.setProperty("log4j2.loggerContextFactory", "org.apache.logging.log4j.TestLoggerContextFactory"); @@ -142,7 +142,7 @@ public class GenerateExtendedLoggerTest { final Method method = cls.getDeclaredMethod(name, String.class); method.invoke(extendedLogger, "This is message " + n++); } - + // This logger extends o.a.l.log4j.spi.ExtendedLogger, // so all the standard logging methods can be used as well final ExtendedLogger logger = (ExtendedLogger) extendedLogger; @@ -158,7 +158,7 @@ public class GenerateExtendedLoggerTest { for (int i = 0; i < lines.size() - 6; i++) { assertEquals(" " + levels.get(i).name + " This is message " + i, lines.get(i)); } - + // test that the standard logging methods still work int i = lines.size() - 6; assertEquals(" TRACE trace message", lines.get(i++)); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FastDateParserSDFTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FastDateParserSDFTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FastDateParserSDFTest.java index 247dad8..55102a2 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FastDateParserSDFTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FastDateParserSDFTest.java @@ -36,8 +36,8 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; /** - * Compare FastDateParser with SimpleDateFormat - * + * Compare FastDateParser with SimpleDateFormat + * * Copied from Apache Commons Lang 3 on 2016-11-16. */ @RunWith(Parameterized.class) @@ -186,9 +186,9 @@ public class FastDateParserSDFTest { fdfE = e.getClass(); } if (valid) { - assertEquals(locale.toString()+" "+formattedDate +"\n",expectedTime, actualTime); + assertEquals(locale.toString()+" "+formattedDate +"\n",expectedTime, actualTime); } else { - assertEquals(locale.toString()+" "+formattedDate + " expected same Exception ", sdfE, fdfE); + assertEquals(locale.toString()+" "+formattedDate + " expected same Exception ", sdfE, fdfE); } } private void checkParsePosition(final String formattedDate) { @@ -205,12 +205,12 @@ public class FastDateParserSDFTest { final int length = formattedDate.length(); if (endIndex != length) { // Error in test data - throw new RuntimeException("Test data error: expected SDF parse to consume entire string; endindex " + endIndex + " != " + length); + throw new RuntimeException("Test data error: expected SDF parse to consume entire string; endindex " + endIndex + " != " + length); } } else { final int errorIndex = sdfP.getErrorIndex(); if (errorIndex == -1) { - throw new RuntimeException("Test data error: expected SDF parse to fail, but got " + expectedTime); + throw new RuntimeException("Test data error: expected SDF parse to fail, but got " + expectedTime); } } @@ -227,6 +227,6 @@ public class FastDateParserSDFTest { assertNotEquals("Test data error: expected FDF parse to fail, but got " + actualTime, -1, fdferrorIndex); assertTrue("FDF error index ("+ fdferrorIndex + ") should approxiamate SDF index (" + sdferrorIndex + ")", sdferrorIndex - fdferrorIndex <= 4); - } + } } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FastDateParserTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FastDateParserTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FastDateParserTest.java index 546780b..00588df 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FastDateParserTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FastDateParserTest.java @@ -39,7 +39,7 @@ import org.junit.Test; /** * Unit tests {@link org.apache.commons.lang3.time.FastDateParser}. - * + * * Copied from Apache Commons Lang 3 on 2016-11-16. */ public class FastDateParserTest { @@ -343,7 +343,7 @@ public class FastDateParserTest { } } } - + @Test public void testJpLocales() { @@ -421,7 +421,7 @@ public class FastDateParserTest { testSdfAndFdp("''yyyyMMdd'A''B'HHmmssSSS''", "'20030210A'B153320989'", false); // OK testSdfAndFdp("''''yyyyMMdd'A''B'HHmmssSSS''", "''20030210A'B153320989'", false); // OK testSdfAndFdp("'$\\Ed'" ,"$\\Ed", false); // OK - + // quoted charaters are case sensitive testSdfAndFdp("'QED'", "QED", false); testSdfAndFdp("'QED'", "qed", true); @@ -429,7 +429,7 @@ public class FastDateParserTest { testSdfAndFdp("yyyy-MM-dd 'QED'", "2003-02-10 QED", false); testSdfAndFdp("yyyy-MM-dd 'QED'", "2003-02-10 qed", true); } - + @Test public void testLANG_832() throws Exception { testSdfAndFdp("'d'd" ,"d3", false); // OK @@ -593,19 +593,19 @@ public class FastDateParserTest { final DateParser parser= getInstance(yMdHmsSZ, REYKJAVIK); assertEquals(REYKJAVIK, parser.getTimeZone()); } - + @Test public void testLang996() throws ParseException { final Calendar expected = Calendar.getInstance(NEW_YORK, Locale.US); expected.clear(); expected.set(2014, Calendar.MAY, 14); - final DateParser fdp = getInstance("ddMMMyyyy", NEW_YORK, Locale.US); + final DateParser fdp = getInstance("ddMMMyyyy", NEW_YORK, Locale.US); assertEquals(expected.getTime(), fdp.parse("14may2014")); assertEquals(expected.getTime(), fdp.parse("14MAY2014")); assertEquals(expected.getTime(), fdp.parse("14May2014")); } - + @Test(expected = IllegalArgumentException.class) public void test1806Argument() { getInstance("XXXX"); @@ -624,8 +624,8 @@ public class FastDateParserTest { } private static enum Expected1806 { - India(INDIA, "+05", "+0530", "+05:30", true), - Greenwich(GMT, "Z", "Z", "Z", false), + India(INDIA, "+05", "+0530", "+05:30", true), + Greenwich(GMT, "Z", "Z", "Z", false), NewYork(NEW_YORK, "-05", "-0500", "-05:00", false); private Expected1806(final TimeZone zone, final String one, final String two, final String three, final boolean hasHalfHourOffset) { @@ -642,17 +642,17 @@ public class FastDateParserTest { final String three; final long offset; } - + @Test public void test1806() throws ParseException { final String formatStub = "yyyy-MM-dd'T'HH:mm:ss.SSS"; final String dateStub = "2001-02-04T12:08:56.235"; - + for (final Expected1806 trial : Expected1806.values()) { final Calendar cal = initializeCalendar(trial.zone); final String message = trial.zone.getDisplayName()+";"; - + DateParser parser = getInstance(formatStub+"X", trial.zone); assertEquals(message+trial.one, cal.getTime().getTime(), parser.parse(dateStub+trial.one).getTime()-trial.offset); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FastDateParser_MoreOrLessTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FastDateParser_MoreOrLessTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FastDateParser_MoreOrLessTest.java index 0caa8be..e95631a 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FastDateParser_MoreOrLessTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/util/datetime/FastDateParser_MoreOrLessTest.java @@ -31,15 +31,15 @@ import org.junit.Test; public class FastDateParser_MoreOrLessTest { private static final TimeZone NEW_YORK = TimeZone.getTimeZone("America/New_York"); - + @Test public void testInputHasPrecedingCharacters() { final FastDateParser parser = new FastDateParser("MM/dd", TimeZone.getDefault(), Locale.getDefault()); final ParsePosition parsePosition = new ParsePosition(0); final Date date = parser.parse("A 3/23/61", parsePosition); Assert.assertNull(date); - Assert.assertEquals(0, parsePosition.getIndex()); - Assert.assertEquals(0, parsePosition.getErrorIndex()); + Assert.assertEquals(0, parsePosition.getIndex()); + Assert.assertEquals(0, parsePosition.getErrorIndex()); } @Test @@ -54,7 +54,7 @@ public class FastDateParser_MoreOrLessTest { calendar.setTime(date); Assert.assertEquals(1961, calendar.get(Calendar.YEAR)); Assert.assertEquals(2, calendar.get(Calendar.MONTH)); - Assert.assertEquals(23, calendar.get(Calendar.DATE)); + Assert.assertEquals(23, calendar.get(Calendar.DATE)); } @Test @@ -67,9 +67,9 @@ public class FastDateParser_MoreOrLessTest { final Calendar calendar = Calendar.getInstance(); calendar.setTime(date); Assert.assertEquals(2, calendar.get(Calendar.MONTH)); - Assert.assertEquals(23, calendar.get(Calendar.DATE)); + Assert.assertEquals(23, calendar.get(Calendar.DATE)); } - + @Test public void testInputHasWrongCharacters() { final FastDateParser parser = new FastDateParser("MM-dd-yyy", TimeZone.getDefault(), Locale.getDefault()); @@ -77,7 +77,7 @@ public class FastDateParser_MoreOrLessTest { Assert.assertNull(parser.parse("03/23/1961", parsePosition)); Assert.assertEquals(2, parsePosition.getErrorIndex()); } - + @Test public void testInputHasLessCharacters() { final FastDateParser parser = new FastDateParser("MM/dd/yyy", TimeZone.getDefault(), Locale.getDefault()); @@ -85,21 +85,21 @@ public class FastDateParser_MoreOrLessTest { Assert.assertNull(parser.parse("03/23", parsePosition)); Assert.assertEquals(5, parsePosition.getErrorIndex()); } - + @Test public void testInputHasWrongTimeZone() { final FastDateParser parser = new FastDateParser("mm:ss z", NEW_YORK, Locale.US); - + final String input = "11:23 Pacific Standard Time"; final ParsePosition parsePosition = new ParsePosition(0); Assert.assertNotNull(parser.parse(input, parsePosition)); Assert.assertEquals(input.length(), parsePosition.getIndex()); - + parsePosition.setIndex(0); Assert.assertNull(parser.parse( "11:23 Pacific Standard ", parsePosition)); Assert.assertEquals(6, parsePosition.getErrorIndex()); } - + @Test public void testInputHasWrongDay() { final FastDateParser parser = new FastDateParser("EEEE, MM/dd/yyy", NEW_YORK, Locale.US); @@ -107,7 +107,7 @@ public class FastDateParser_MoreOrLessTest { final ParsePosition parsePosition = new ParsePosition(0); Assert.assertNotNull(parser.parse(input, parsePosition)); Assert.assertEquals(input.length(), parsePosition.getIndex()); - + parsePosition.setIndex(0); Assert.assertNull(parser.parse( "Thorsday, 03/23/61", parsePosition)); Assert.assertEquals(0, parsePosition.getErrorIndex()); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java index 65458ba..36d4b63 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java @@ -26,7 +26,7 @@ import java.nio.file.Path; * <p> * For example: * </p> - * + * * <pre> * @Rule * public CleanFiles files = new CleanFiles("path/to/file.txt"); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/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 2d591d3..09ce947 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 @@ -48,7 +48,7 @@ public class LoggerContextRule implements TestRule, LoggerContextAccessor { public static LoggerContextRule createShutdownTimeoutLoggerContextRule(final String config) { return new LoggerContextRule(config, 10, TimeUnit.SECONDS); } - + private static final String SYS_PROP_KEY_CLASS_NAME = "org.apache.logging.log4j.junit.LoggerContextRule#ClassName"; private static final String SYS_PROP_KEY_DISPLAY_NAME = "org.apache.logging.log4j.junit.LoggerContextRule#DisplayName"; private final String configLocation; @@ -278,7 +278,7 @@ public class LoggerContextRule implements TestRule, LoggerContextAccessor { public void reconfigure() { loggerContext.reconfigure(); } - + @Override public String toString() { final StringBuilder builder = new StringBuilder(); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/message/MutableLogEventWithReusableParamMsgTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/message/MutableLogEventWithReusableParamMsgTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/message/MutableLogEventWithReusableParamMsgTest.java index 1371ed2..2d3688d 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/message/MutableLogEventWithReusableParamMsgTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/message/MutableLogEventWithReusableParamMsgTest.java @@ -53,8 +53,8 @@ public class MutableLogEventWithReusableParamMsgTest { evt.setMessage(msg); evt.clear(); - Message mementoMessage = evt.memento(); - Message mementoMessageSecondInvocation = evt.memento(); + final Message mementoMessage = evt.memento(); + final Message mementoMessageSecondInvocation = evt.memento(); // MutableLogEvent.memento should be cached assertThat(mementoMessage, sameInstance(mementoMessageSecondInvocation)); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/test/java/org/apache/logging/log4j/test/RuleChainFactory.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/test/RuleChainFactory.java b/log4j-core/src/test/java/org/apache/logging/log4j/test/RuleChainFactory.java index 30629b2..6c3c435 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/test/RuleChainFactory.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/test/RuleChainFactory.java @@ -27,7 +27,7 @@ public class RuleChainFactory { /** * Creates a {@link RuleChain} where the rules are evaluated in the order you pass in. - * + * * @param testRules * test rules to evaluate * @return a new rule chain. http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java ---------------------------------------------------------------------- diff --git a/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java b/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java index d4c5219..79afa21 100644 --- a/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java +++ b/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeAppender.java @@ -75,7 +75,7 @@ public final class FlumeAppender extends AbstractAppender implements FlumeEventF private FlumeAppender(final String name, final Filter filter, final Layout<? extends Serializable> layout, final boolean ignoreExceptions, final String includes, final String excludes, final String required, final String mdcPrefix, final String eventPrefix, final boolean compress, final FlumeEventFactory factory, - final AbstractFlumeManager manager, Property[] properties) { + final AbstractFlumeManager manager, final Property[] properties) { super(name, filter, layout, ignoreExceptions, properties); this.manager = manager; this.mdcIncludes = includes; http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEventFactory.java ---------------------------------------------------------------------- diff --git a/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEventFactory.java b/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEventFactory.java index a95fd6b..7a79f35 100644 --- a/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEventFactory.java +++ b/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumeEventFactory.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.core.LogEvent; * Factory to create Flume events. */ public interface FlumeEventFactory { - + /** * Creates a Flume event. * @param event The Log4j LogEvent. http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumePersistentAppenderTest.java ---------------------------------------------------------------------- diff --git a/log4j-flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumePersistentAppenderTest.java b/log4j-flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumePersistentAppenderTest.java index d559904..30ae580 100644 --- a/log4j-flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumePersistentAppenderTest.java +++ b/log4j-flume-ng/src/test/java/org/apache/logging/log4j/flume/appender/FlumePersistentAppenderTest.java @@ -278,7 +278,7 @@ public class FlumePersistentAppenderTest { fields[i]); } } - + @Test public void testRFC5424Layout() throws IOException { @@ -346,12 +346,13 @@ public class FlumePersistentAppenderTest { } } } - + @Test public void testLogInterrupted() { final ExecutorService executor = Executors.newSingleThreadExecutor(); executor.execute(new Runnable() { - public void run() { + @Override + public void run() { executor.shutdownNow(); final Logger logger = LogManager.getLogger("EventLogger"); final Marker marker = MarkerManager.getMarker("EVENT"); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/ByteStreamLogger.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/ByteStreamLogger.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/ByteStreamLogger.java index 114f35a..e53e038 100644 --- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/ByteStreamLogger.java +++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/ByteStreamLogger.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.spi.ExtendedLogger; /** - * + * * @since 2.1 */ public class ByteStreamLogger { @@ -114,7 +114,7 @@ public class ByteStreamLogger { this.logger.logIfEnabled(fqcn, this.level, this.marker, this.msg.toString()); this.msg.setLength(0); } - + private void logEnd(final String fqcn) { if (this.msg.length() > 0) { log(fqcn); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/CharStreamLogger.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/CharStreamLogger.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/CharStreamLogger.java index 8bd5d24..a904480 100644 --- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/CharStreamLogger.java +++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/CharStreamLogger.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.spi.ExtendedLogger; /** - * + * * @since 2.1 */ public class CharStreamLogger { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedInputStream.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedInputStream.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedInputStream.java index 54d9796..f7a7e55 100644 --- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedInputStream.java +++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedInputStream.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.spi.ExtendedLogger; /** - * + * * @since 2.1 */ public class LoggerBufferedInputStream extends BufferedInputStream { @@ -48,17 +48,17 @@ public class LoggerBufferedInputStream extends BufferedInputStream { public void close() throws IOException { super.close(); } - + @Override public synchronized int read() throws IOException { return super.read(); } - + @Override public int read(final byte[] b) throws IOException { return super.read(b, 0, b.length); } - + @Override public synchronized int read(final byte[] b, final int off, final int len) throws IOException { return super.read(b, off, len); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedReader.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedReader.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedReader.java index 584e61a..e63f612 100644 --- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedReader.java +++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerBufferedReader.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.spi.ExtendedLogger; /** - * + * * @since 2.1 */ public class LoggerBufferedReader extends BufferedReader { @@ -42,27 +42,27 @@ public class LoggerBufferedReader extends BufferedReader { final Level level, final Marker marker) { super(new LoggerReader(reader, logger, fqcn == null ? FQCN : fqcn, level, marker), size); } - + @Override public void close() throws IOException { super.close(); } - + @Override public int read() throws IOException { return super.read(); } - + @Override public int read(final char[] cbuf) throws IOException { return super.read(cbuf, 0, cbuf.length); } - + @Override public int read(final char[] cbuf, final int off, final int len) throws IOException { return super.read(cbuf, off, len); } - + @Override public int read(final CharBuffer target) throws IOException { final int len = target.remaining(); @@ -73,7 +73,7 @@ public class LoggerBufferedReader extends BufferedReader { } return charsRead; } - + @Override public String readLine() throws IOException { return super.readLine(); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterOutputStream.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterOutputStream.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterOutputStream.java index b608502..d3d476b 100644 --- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterOutputStream.java +++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterOutputStream.java @@ -31,7 +31,7 @@ import org.apache.logging.log4j.spi.ExtendedLogger; * that follows the {@link java.io.OutputStream} methods in spirit, but doesn't require output to any external stream. * This class should <em>not</em> be used as a stream for an underlying logger unless it's being used as a bridge. * Otherwise, infinite loops may occur! - * + * * @since 2.1 */ public class LoggerFilterOutputStream extends FilterOutputStream { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterWriter.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterWriter.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterWriter.java index 4b0991f..d2da1ce 100644 --- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterWriter.java +++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerFilterWriter.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.spi.ExtendedLogger; /** * Logs each line written to a pre-defined level. Can also be configured with a Marker. This class provides an interface * that follows the {@link java.io.Writer} methods in spirit, but doesn't require output to any external out. - * + * * @since 2.1 */ public class LoggerFilterWriter extends FilterWriter { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerInputStream.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerInputStream.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerInputStream.java index 5366f19..ee77251 100644 --- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerInputStream.java +++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerInputStream.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.spi.ExtendedLogger; /** * Logs each line read to a pre-defined level. Can also be configured with a Marker. - * + * * @since 2.1 */ public class LoggerInputStream extends FilterInputStream { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerOutputStream.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerOutputStream.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerOutputStream.java index b8ea392..1267966 100644 --- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerOutputStream.java +++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerOutputStream.java @@ -30,7 +30,7 @@ import org.apache.logging.log4j.spi.ExtendedLogger; * that follows the {@link java.io.OutputStream} methods in spirit, but doesn't require output to any external stream. * This class should <em>not</em> be used as a stream for an underlying logger unless it's being used as a bridge. * Otherwise, infinite loops may occur! - * + * * @since 2.1 */ public class LoggerOutputStream extends OutputStream { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintStream.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintStream.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintStream.java index 30bac34..5aa1e82 100644 --- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintStream.java +++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerPrintStream.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.spi.ExtendedLogger; * that follows the {@link java.io.PrintStream} methods in spirit, but doesn't require output to any external stream. * This class should <em>not</em> be used as a stream for an underlying logger unless it's being used as a bridge. * Otherwise, infinite loops may occur! - * + * * @since 2.1 */ public class LoggerPrintStream extends PrintStream { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerReader.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerReader.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerReader.java index 265e8e7..6fb9579 100644 --- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerReader.java +++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerReader.java @@ -28,7 +28,7 @@ import org.apache.logging.log4j.spi.ExtendedLogger; /** * Logs each line read to a pre-defined level. Can also be configured with a Marker. - * + * * @since 2.1 */ public class LoggerReader extends FilterReader { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerWriter.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerWriter.java b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerWriter.java index 8fba24c..235d4eb 100644 --- a/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerWriter.java +++ b/log4j-iostreams/src/main/java/org/apache/logging/log4j/io/LoggerWriter.java @@ -27,7 +27,7 @@ import org.apache.logging.log4j.spi.ExtendedLogger; /** * Logs each line written to a pre-defined level. Can also be configured with a Marker. This class provides an interface * that follows the {@link java.io.Writer} methods in spirit, but doesn't require output to any external writer. - * + * * @since 2.1 */ public class LoggerWriter extends Writer { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerOutputStreamTest.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerOutputStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerOutputStreamTest.java index 188b422..9f83788 100644 --- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerOutputStreamTest.java +++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerOutputStreamTest.java @@ -28,7 +28,7 @@ import static org.mockito.BDDMockito.then; import static org.mockito.Mockito.mock; public abstract class AbstractLoggerOutputStreamTest extends AbstractStreamTest { - + protected OutputStream out; protected ByteArrayOutputStream wrapped; protected abstract ByteArrayOutputStream createOutputStream(); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java index d73fd02..a24e0f9 100644 --- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java +++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java @@ -1,59 +1,59 @@ -/* - * 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.io; - -import java.util.List; - -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.junit.LoggerContextRule; -import org.apache.logging.log4j.spi.ExtendedLogger; -import org.junit.Before; -import org.junit.ClassRule; - -import static org.hamcrest.core.StringStartsWith.startsWith; -import static org.junit.Assert.*; - -public abstract class AbstractStreamTest { - - protected static ExtendedLogger getExtendedLogger() { - return ctx.getLogger("UnitTestLogger"); - } - - protected final static String NEWLINE = System.lineSeparator(); - protected final static Level LEVEL = Level.ERROR; - protected final static String FIRST = "first"; - - protected final static String LAST = "last"; - - @ClassRule - public static LoggerContextRule ctx = new LoggerContextRule("log4j2-streams-unit-test.xml"); - - protected void assertMessages(final String... messages) { - final List<String> actualMsgs = ctx.getListAppender("UnitTest").getMessages(); - assertEquals("Unexpected number of results.", messages.length, actualMsgs.size()); - for (int i = 0; i < messages.length; i++) { - final String start = LEVEL.name() + ' ' + messages[i]; - assertThat(actualMsgs.get(i), startsWith(start)); - } - } - - @Before - public void clearAppender() { - ctx.getListAppender("UnitTest").clear(); - } -} +/* + * 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.io; + +import java.util.List; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.junit.LoggerContextRule; +import org.apache.logging.log4j.spi.ExtendedLogger; +import org.junit.Before; +import org.junit.ClassRule; + +import static org.hamcrest.core.StringStartsWith.startsWith; +import static org.junit.Assert.*; + +public abstract class AbstractStreamTest { + + protected static ExtendedLogger getExtendedLogger() { + return ctx.getLogger("UnitTestLogger"); + } + + protected final static String NEWLINE = System.lineSeparator(); + protected final static Level LEVEL = Level.ERROR; + protected final static String FIRST = "first"; + + protected final static String LAST = "last"; + + @ClassRule + public static LoggerContextRule ctx = new LoggerContextRule("log4j2-streams-unit-test.xml"); + + protected void assertMessages(final String... messages) { + final List<String> actualMsgs = ctx.getListAppender("UnitTest").getMessages(); + assertEquals("Unexpected number of results.", messages.length, actualMsgs.size()); + for (int i = 0; i < messages.length; i++) { + final String start = LEVEL.name() + ' ' + messages[i]; + assertThat(actualMsgs.get(i), startsWith(start)); + } + } + + @Before + public void clearAppender() { + ctx.getListAppender("UnitTest").clear(); + } +} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/IoBuilderCallerInfoTesting.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/IoBuilderCallerInfoTesting.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/IoBuilderCallerInfoTesting.java index d81e173..e255542 100644 --- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/IoBuilderCallerInfoTesting.java +++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/IoBuilderCallerInfoTesting.java @@ -1,55 +1,55 @@ -/* - * 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.io; - -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.core.Logger; -import org.apache.logging.log4j.junit.LoggerContextRule; -import org.apache.logging.log4j.test.appender.ListAppender; -import org.junit.Before; -import org.junit.ClassRule; - -import static org.junit.Assert.*; - -public class IoBuilderCallerInfoTesting { - - protected static Logger getExtendedLogger() { - return ctx.getLogger("ClassAndMethodLogger"); - } - - protected static Logger getLogger() { - return getExtendedLogger(); - } - - protected final static Level LEVEL = Level.WARN; - - @ClassRule - public static LoggerContextRule ctx = new LoggerContextRule("log4j2-streams-calling-info.xml"); - - public void assertMessages(final String msg, final int size, final String methodName) { - final ListAppender appender = ctx.getListAppender("ClassAndMethod"); - assertEquals(msg + ".size", size, appender.getMessages().size()); - for (final String message : appender.getMessages()) { - assertEquals(msg + " has incorrect caller info", this.getClass().getName() + '.' + methodName, message); - } - } - - @Before - public void clearAppender() { - ctx.getListAppender("ClassAndMethod").clear(); - } -} +/* + * 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.io; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.core.Logger; +import org.apache.logging.log4j.junit.LoggerContextRule; +import org.apache.logging.log4j.test.appender.ListAppender; +import org.junit.Before; +import org.junit.ClassRule; + +import static org.junit.Assert.*; + +public class IoBuilderCallerInfoTesting { + + protected static Logger getExtendedLogger() { + return ctx.getLogger("ClassAndMethodLogger"); + } + + protected static Logger getLogger() { + return getExtendedLogger(); + } + + protected final static Level LEVEL = Level.WARN; + + @ClassRule + public static LoggerContextRule ctx = new LoggerContextRule("log4j2-streams-calling-info.xml"); + + public void assertMessages(final String msg, final int size, final String methodName) { + final ListAppender appender = ctx.getListAppender("ClassAndMethod"); + assertEquals(msg + ".size", size, appender.getMessages().size()); + for (final String message : appender.getMessages()) { + assertEquals(msg + " has incorrect caller info", this.getClass().getName() + '.' + methodName, message); + } + } + + @Before + public void clearAppender() { + ctx.getListAppender("ClassAndMethod").clear(); + } +} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamCallerInfoTest.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamCallerInfoTest.java index 5975407..e00bb1b 100644 --- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamCallerInfoTest.java +++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamCallerInfoTest.java @@ -34,7 +34,7 @@ public class LoggerBufferedInputStreamCallerInfoTest extends IoBuilderCallerInfo this.logIn.close(); assertMessages("after close", 4, "close"); } - + @Test public void read() throws Exception { this.logIn.read(); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderCallerInfoTest.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderCallerInfoTest.java index 6f83dbb..4f07e56 100644 --- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderCallerInfoTest.java +++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderCallerInfoTest.java @@ -28,7 +28,7 @@ import org.junit.Test; public class LoggerBufferedReaderCallerInfoTest extends IoBuilderCallerInfoTesting { BufferedReader logReader; - + @Test public void close() throws Exception { this.logReader.readLine(); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamCallerInfoTest.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamCallerInfoTest.java index 36f70f3..d6b4efc 100644 --- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamCallerInfoTest.java +++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamCallerInfoTest.java @@ -45,7 +45,7 @@ public class LoggerInputStreamCallerInfoTest extends IoBuilderCallerInfoTesting this.logIn.close(); assertMessages("after close size", 4, "read"); } - + @Before public void setupStreams() { final InputStream srcInputStream = new ByteArrayInputStream("a\nb\nc\nd".getBytes()); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamTest.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamTest.java index 9242eef..65bc2db 100644 --- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamTest.java +++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamTest.java @@ -45,7 +45,7 @@ public class LoggerInputStreamTest extends AbstractStreamTest { this.read = new ByteArrayOutputStream(); this.in = createInputStream(); } - + @Test public void testClose_HasRemainingData() throws IOException { final byte[] bytes = new byte[1024]; http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamCallerInfoTest.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamCallerInfoTest.java index 1b5eb85..66002ca 100644 --- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamCallerInfoTest.java +++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamCallerInfoTest.java @@ -25,19 +25,19 @@ import org.junit.Test; public class LoggerOutputStreamCallerInfoTest extends IoBuilderCallerInfoTesting { private OutputStream logOut; - + @Before public void setupStreams() { this.logOut = IoBuilder.forLogger(getExtendedLogger()).setLevel(Level.WARN).buildOutputStream(); } - + @Test public void write() throws Exception { this.logOut.write('a'); assertMessages("before write int", 0, "write"); this.logOut.write('\n'); assertMessages("after write int", 1, "write"); - + this.logOut.write("b\n".getBytes()); assertMessages("after write byte array", 2, "write"); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamCallerInfoTest.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamCallerInfoTest.java index 723336f..e79ddaf 100644 --- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamCallerInfoTest.java +++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamCallerInfoTest.java @@ -34,7 +34,7 @@ public class LoggerPrintStreamCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.close(); assertMessages("after close size", 2, "close"); } - + @Test public void print_boolean() throws Exception { this.logOut.print(true); @@ -42,7 +42,7 @@ public class LoggerPrintStreamCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.println(true); assertMessages("println", 1, "print_boolean"); } - + @Test public void print_char() throws Exception { this.logOut.print('a'); @@ -50,7 +50,7 @@ public class LoggerPrintStreamCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.println('b'); assertMessages("println", 1, "print_char"); } - + @Test public void print_chararray() throws Exception { this.logOut.print("a".toCharArray()); @@ -58,7 +58,7 @@ public class LoggerPrintStreamCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.println("b".toCharArray()); assertMessages("println", 1, "print_chararray"); } - + @Test public void print_double() throws Exception { this.logOut.print(1D); @@ -66,7 +66,7 @@ public class LoggerPrintStreamCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.println(2D); assertMessages("println", 1, "print_double"); } - + @Test public void print_float() throws Exception { this.logOut.print(1f); @@ -74,7 +74,7 @@ public class LoggerPrintStreamCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.println(2f); assertMessages("println", 1, "print_float"); } - + @Test public void print_int() throws Exception { this.logOut.print(1); @@ -82,7 +82,7 @@ public class LoggerPrintStreamCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.println(2); assertMessages("println", 1, "print_int"); } - + @Test public void print_long() throws Exception { this.logOut.print(1L); @@ -90,7 +90,7 @@ public class LoggerPrintStreamCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.println(2L); assertMessages("println", 1, "print_long"); } - + @Test public void print_object() throws Exception { this.logOut.print((Object) 'a'); @@ -98,19 +98,19 @@ public class LoggerPrintStreamCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.println((Object) 'b'); assertMessages("println", 1, "print_object"); } - + @Test public void print_printf() throws Exception { this.logOut.printf("a\n"); assertMessages("println", 1, "print_printf"); } - + @Test public void print_printf_locale() throws Exception { this.logOut.printf(Locale.getDefault(), "a\n"); assertMessages("println", 1, "print_printf_locale"); } - + @Test public void print_string() throws Exception { this.logOut.print("a"); @@ -118,26 +118,26 @@ public class LoggerPrintStreamCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.println("b"); assertMessages("println", 1, "print_string"); } - + @Before public void setupStreams() { this.logOut = IoBuilder.forLogger(getLogger()) .setLevel(Level.WARN) .buildPrintStream(); } - + @Test public void write_bytes() throws Exception { this.logOut.write("b\n".getBytes()); assertMessages("write", 1, "write_bytes"); } - + @Test public void write_bytes_offset() throws Exception { this.logOut.write("c\n".getBytes(), 0, 2); assertMessages("write", 1, "write_bytes_offset"); } - + @Test public void write_int() throws Exception { this.logOut.write('a'); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterCallerInfoTest.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterCallerInfoTest.java index ca6ce01..52c87c8 100644 --- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterCallerInfoTest.java +++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterCallerInfoTest.java @@ -26,7 +26,7 @@ import org.junit.Test; public class LoggerPrintWriterCallerInfoTest extends IoBuilderCallerInfoTesting { private PrintWriter logOut; - + @Test public void close() throws Exception { this.logOut.print("a\nb"); @@ -34,7 +34,7 @@ public class LoggerPrintWriterCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.close(); assertMessages("after close size", 2, "close"); } - + @Test public void print_boolean() throws Exception { this.logOut.print(true); @@ -42,7 +42,7 @@ public class LoggerPrintWriterCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.println(true); assertMessages("println", 1, "print_boolean"); } - + @Test public void print_char() throws Exception { this.logOut.print('a'); @@ -50,7 +50,7 @@ public class LoggerPrintWriterCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.println('b'); assertMessages("println", 1, "print_char"); } - + @Test public void print_chararray() throws Exception { this.logOut.print("a".toCharArray()); @@ -58,7 +58,7 @@ public class LoggerPrintWriterCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.println("b".toCharArray()); assertMessages("println", 1, "print_chararray"); } - + @Test public void print_double() throws Exception { this.logOut.print(1D); @@ -66,7 +66,7 @@ public class LoggerPrintWriterCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.println(2D); assertMessages("println", 1, "print_double"); } - + @Test public void print_float() throws Exception { this.logOut.print(1f); @@ -74,7 +74,7 @@ public class LoggerPrintWriterCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.println(2f); assertMessages("println", 1, "print_float"); } - + @Test public void print_int() throws Exception { this.logOut.print(1); @@ -82,7 +82,7 @@ public class LoggerPrintWriterCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.println(2); assertMessages("println", 1, "print_int"); } - + @Test public void print_long() throws Exception { this.logOut.print(1L); @@ -90,7 +90,7 @@ public class LoggerPrintWriterCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.println(2L); assertMessages("println", 1, "print_long"); } - + @Test public void print_object() throws Exception { this.logOut.print((Object) 'a'); @@ -98,19 +98,19 @@ public class LoggerPrintWriterCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.println((Object) 'b'); assertMessages("println", 1, "print_object"); } - + @Test public void print_printf() throws Exception { this.logOut.printf("a\n"); assertMessages("println", 1, "print_printf"); } - + @Test public void print_printf_locale() throws Exception { this.logOut.printf(Locale.getDefault(), "a\n"); assertMessages("println", 1, "print_printf_locale"); } - + @Test public void print_string() throws Exception { this.logOut.print("a"); @@ -118,26 +118,26 @@ public class LoggerPrintWriterCallerInfoTest extends IoBuilderCallerInfoTesting this.logOut.println("b"); assertMessages("println", 1, "print_string"); } - + @Before public void setupStreams() { this.logOut = IoBuilder.forLogger(getLogger()) .setLevel(Level.WARN) .buildPrintWriter(); } - + @Test public void write_bytes() throws Exception { this.logOut.write("b\n".toCharArray()); assertMessages("write", 1, "write_bytes"); } - + @Test public void write_bytes_offset() throws Exception { this.logOut.write("c\n".toCharArray(), 0, 2); assertMessages("write", 1, "write_bytes_offset"); } - + @Test public void write_int() throws Exception { this.logOut.write('a'); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterJdbcH2Test.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterJdbcH2Test.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterJdbcH2Test.java index 712ec62..dad446d 100644 --- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterJdbcH2Test.java +++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterJdbcH2Test.java @@ -1,96 +1,96 @@ -/* - * 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.io; - -import java.io.PrintWriter; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; - -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.junit.LoggerContextRule; -import org.apache.logging.log4j.test.appender.ListAppender; -import org.apache.logging.log4j.util.Strings; -import org.h2.jdbcx.JdbcDataSource; -import org.junit.Assert; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Ignore; -import org.junit.Test; - -public class LoggerPrintWriterJdbcH2Test { - - @ClassRule - public static LoggerContextRule context = new LoggerContextRule("log4j2-jdbc-driver-manager.xml"); - - private static final String H2_URL = "jdbc:h2:mem:Log4j"; - - private static final String PASSWORD = Strings.EMPTY; - - private static final String USER_ID = "sa"; - - private ListAppender listAppender; - - private PrintWriter createLoggerPrintWriter() { - return IoBuilder.forLogger(context.getLogger()).setLevel(Level.ALL).buildPrintWriter(); - } - - private ListAppender getListAppender() { - return listAppender; - } - - protected Connection newConnection() throws SQLException { - return DriverManager.getConnection(H2_URL, USER_ID, PASSWORD); - } - - private void setListAppender(final ListAppender listAppender) { - this.listAppender = listAppender; - } - - @Before - public void setUp() throws Exception { - this.setListAppender(context.getListAppender("List").clear()); - Assert.assertEquals(0, this.getListAppender().getMessages().size()); - } - - @Test - @Ignore("DataSource#setLogWriter() has no effect in H2, it uses its own internal logging and an SLF4J bridge.") - public void testDataSource_setLogWriter() throws SQLException { - final JdbcDataSource dataSource = new JdbcDataSource(); - dataSource.setUrl(H2_URL); - dataSource.setUser(USER_ID); - dataSource.setPassword(PASSWORD); - dataSource.setLogWriter(createLoggerPrintWriter()); - // dataSource.setLogWriter(new PrintWriter(new OutputStreamWriter(System.out))); - try (final Connection conn = dataSource.getConnection()) { - conn.prepareCall("select 1"); - } - Assert.assertTrue(this.getListAppender().getMessages().size() > 0); - } - - @Test - public void testDriverManager_setLogWriter() throws SQLException { - DriverManager.setLogWriter(createLoggerPrintWriter()); - // DriverManager.setLogWriter(new PrintWriter(new OutputStreamWriter(System.out))); - try (final Connection conn = this.newConnection()) { - conn.rollback(); - } finally { - DriverManager.setLogWriter(null); - } - Assert.assertTrue(this.getListAppender().getMessages().size() > 0); - } -} +/* + * 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.io; + +import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.junit.LoggerContextRule; +import org.apache.logging.log4j.test.appender.ListAppender; +import org.apache.logging.log4j.util.Strings; +import org.h2.jdbcx.JdbcDataSource; +import org.junit.Assert; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; + +public class LoggerPrintWriterJdbcH2Test { + + @ClassRule + public static LoggerContextRule context = new LoggerContextRule("log4j2-jdbc-driver-manager.xml"); + + private static final String H2_URL = "jdbc:h2:mem:Log4j"; + + private static final String PASSWORD = Strings.EMPTY; + + private static final String USER_ID = "sa"; + + private ListAppender listAppender; + + private PrintWriter createLoggerPrintWriter() { + return IoBuilder.forLogger(context.getLogger()).setLevel(Level.ALL).buildPrintWriter(); + } + + private ListAppender getListAppender() { + return listAppender; + } + + protected Connection newConnection() throws SQLException { + return DriverManager.getConnection(H2_URL, USER_ID, PASSWORD); + } + + private void setListAppender(final ListAppender listAppender) { + this.listAppender = listAppender; + } + + @Before + public void setUp() throws Exception { + this.setListAppender(context.getListAppender("List").clear()); + Assert.assertEquals(0, this.getListAppender().getMessages().size()); + } + + @Test + @Ignore("DataSource#setLogWriter() has no effect in H2, it uses its own internal logging and an SLF4J bridge.") + public void testDataSource_setLogWriter() throws SQLException { + final JdbcDataSource dataSource = new JdbcDataSource(); + dataSource.setUrl(H2_URL); + dataSource.setUser(USER_ID); + dataSource.setPassword(PASSWORD); + dataSource.setLogWriter(createLoggerPrintWriter()); + // dataSource.setLogWriter(new PrintWriter(new OutputStreamWriter(System.out))); + try (final Connection conn = dataSource.getConnection()) { + conn.prepareCall("select 1"); + } + Assert.assertTrue(this.getListAppender().getMessages().size() > 0); + } + + @Test + public void testDriverManager_setLogWriter() throws SQLException { + DriverManager.setLogWriter(createLoggerPrintWriter()); + // DriverManager.setLogWriter(new PrintWriter(new OutputStreamWriter(System.out))); + try (final Connection conn = this.newConnection()) { + conn.rollback(); + } finally { + DriverManager.setLogWriter(null); + } + Assert.assertTrue(this.getListAppender().getMessages().size() > 0); + } +} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterTest.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterTest.java index 032e004..37618ac 100644 --- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterTest.java +++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterTest.java @@ -25,7 +25,7 @@ import org.junit.Test; import static org.junit.Assert.*; public class LoggerPrintWriterTest extends AbstractLoggerWriterTest { - private PrintWriter print; + private PrintWriter print; @Override protected StringWriter createWriter() { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderCallerInfoTest.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderCallerInfoTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderCallerInfoTest.java index ae009b2..41393e5 100644 --- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderCallerInfoTest.java +++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderCallerInfoTest.java @@ -26,7 +26,7 @@ import org.junit.Test; public class LoggerReaderCallerInfoTest extends IoBuilderCallerInfoTesting { Reader logReader; - + @Test public void read() throws Exception { this.logReader.read(); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderTest.java ---------------------------------------------------------------------- diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderTest.java index b6383e2..fa48a31 100644 --- a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderTest.java +++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderTest.java @@ -39,7 +39,7 @@ public class LoggerReaderTest extends AbstractStreamTest { .setLevel(LEVEL) .buildReader(); } - + @Before public void createStream() { this.wrapped = new StringReader(FIRST + "\r\n" + LAST); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/Log4jLog.java ---------------------------------------------------------------------- diff --git a/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/Log4jLog.java b/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/Log4jLog.java index 1fb51aa..1e644d5 100644 --- a/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/Log4jLog.java +++ b/log4j-jcl/src/main/java/org/apache/logging/log4j/jcl/Log4jLog.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.spi.ExtendedLogger; * */ public class Log4jLog implements Log, Serializable { - + private static final long serialVersionUID = 1L; private static final String FQCN = Log4jLog.class.getName();