You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/09/03 07:23:55 UTC
[3/6] Rename log4j-streams to log4j-iostreams.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerWriterTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerWriterTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerWriterTest.java
new file mode 100644
index 0000000..6fe81bc
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractLoggerWriterTest.java
@@ -0,0 +1,138 @@
+/*
+ * 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 static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+
+public abstract class AbstractLoggerWriterTest extends AbstractStreamTest {
+ protected StringWriter wrapped;
+ protected Writer writer;
+
+ @Before
+ public void createStream() {
+ this.wrapped = createWriter();
+ this.writer = createWriterWrapper();
+ }
+
+ protected abstract StringWriter createWriter();
+
+ protected abstract Writer createWriterWrapper();
+
+ @Test
+ public void testClose_HasRemainingData() throws IOException {
+ this.writer.write(FIRST);
+ assertMessages();
+ this.writer.close();
+ assertMessages(FIRST);
+ if (this.wrapped != null) {
+ assertEquals(FIRST, this.wrapped.toString());
+ }
+ }
+
+ @Test
+ public void testClose_NoRemainingData() throws IOException {
+ this.writer.close();
+ assertMessages();
+ if (this.wrapped != null) {
+ assertEquals("", this.wrapped.toString());
+ }
+ }
+
+ @Test
+ public void testFlush() throws IOException {
+ final OutputStream out = EasyMock.createMock(OutputStream.class);
+ out.flush(); // expect the flush to come through to the mocked OutputStream
+ out.close();
+ replay(out);
+
+ final LoggerFilterOutputStream los = new LoggerFilterOutputStream(out, getExtendedLogger(), LEVEL);
+ los.flush();
+ los.close();
+ verify(out);
+ }
+
+ @Test
+ public void testWrite_Character() throws Exception {
+ for (final char c : FIRST.toCharArray()) {
+ this.writer.write(c);
+ assertMessages();
+ }
+ this.writer.write('\n');
+ assertMessages(FIRST);
+ if (this.wrapped != null) {
+ assertEquals(FIRST + '\n', this.wrapped.toString());
+ }
+ }
+
+ @Test
+ public void testWrite_CharArray() throws Exception {
+ final char[] chars = FIRST.toCharArray();
+ this.writer.write(chars);
+ assertMessages();
+ this.writer.write('\n');
+ assertMessages(FIRST);
+ if (this.wrapped != null) {
+ assertEquals(FIRST + '\n', this.wrapped.toString());
+ }
+ }
+
+ @Test
+ public void testWrite_CharArray_Offset_Length() throws Exception {
+ final char[] chars = FIRST.toCharArray();
+ final int middle = chars.length / 2;
+ final int length = chars.length - middle;
+ final String right = new String(chars, middle, length);
+ this.writer.write(chars, middle, length);
+ assertMessages();
+ this.writer.write('\n');
+ assertMessages(right);
+ if (this.wrapped != null) {
+ assertEquals(FIRST.substring(middle, FIRST.length()) + '\n', this.wrapped.toString());
+ }
+ }
+
+ @Test
+ public void testWrite_IgnoresWindowsNewline() throws IOException {
+ this.writer.write(FIRST + "\r\n");
+ this.writer.write(LAST);
+ this.writer.close();
+ assertMessages(FIRST, LAST);
+ if (this.wrapped != null) {
+ assertEquals(FIRST + "\r\n" + LAST, this.wrapped.toString());
+ }
+ }
+
+ @Test
+ public void testWrite_MultipleLines() throws IOException {
+ this.writer.write(FIRST + '\n' + LAST + '\n');
+ assertMessages(FIRST, LAST);
+ if (this.wrapped != null) {
+ assertEquals(FIRST + '\n' + LAST + '\n', this.wrapped.toString());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/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
new file mode 100644
index 0000000..b0bdc27
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/AbstractStreamTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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 static org.hamcrest.core.StringStartsWith.startsWith;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.spi.ExtendedLogger;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.Before;
+import org.junit.ClassRule;
+
+public abstract class AbstractStreamTest {
+
+ protected static Logger getLogger() {
+ return getExtendedLogger();
+ }
+
+ protected static ExtendedLogger getExtendedLogger() {
+ return ctx.getLogger("UnitTestLogger");
+ }
+
+ protected final static String NEWLINE = System.getProperty("line.separator");
+ protected final static Level LEVEL = Level.ERROR;
+ protected final static String FIRST = "first";
+
+ protected final static String LAST = "last";
+
+ @ClassRule
+ public static InitialLoggerContext ctx = new InitialLoggerContext("log4j2-streams-unit-test.xml");
+
+ protected void assertMessages(final String... messages) {
+ final List<String> actualMsgs = ((ListAppender) ctx.getAppender("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() {
+ ((ListAppender) ctx.getAppender("UnitTest")).clear();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/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
new file mode 100644
index 0000000..860f3b8
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamCallerInfoTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class LoggerBufferedInputStreamCallerInfoTest extends LoggerStreamsCallerInfoTesting {
+
+ private LoggerBufferedInputStream logIn;
+
+ @Test
+ public void close() throws Exception {
+ this.logIn.read();
+ assertMessages("before close", 3, "close");
+ this.logIn.close();
+ assertMessages("after close", 4, "close");
+ }
+
+ @Test
+ public void read() throws Exception {
+ this.logIn.read();
+
+ assertMessages("read", 3, "read");
+ this.logIn.close();
+ }
+
+ @Test
+ public void readBytes() throws Exception {
+ this.logIn.read(new byte[2]);
+
+ assertMessages("read", 3, "readBytes");
+ this.logIn.close();
+ }
+
+ @Test
+ public void readBytesOffsetLen() throws Exception {
+ this.logIn.read(new byte[2], 0, 2);
+
+ assertMessages("read", 3, "readBytesOffsetLen");
+ this.logIn.close();
+ }
+
+ @Before
+ public void setupStreams() {
+ final InputStream srcInputStream = new ByteArrayInputStream("a\nb\nc\nd".getBytes());
+ this.logIn = new LoggerBufferedInputStream(srcInputStream, getLogger(), LEVEL);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamTest.java
new file mode 100644
index 0000000..d2ba6b0
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedInputStreamTest.java
@@ -0,0 +1,29 @@
+/*
+ * 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.InputStream;
+
+import org.apache.logging.log4j.Level;
+
+public class LoggerBufferedInputStreamTest extends LoggerInputStreamTest {
+
+ @Override
+ protected InputStream createInputStream() {
+ return new LoggerBufferedInputStream(this.wrapped, getExtendedLogger(), Level.ERROR);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/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
new file mode 100644
index 0000000..2d9ff12
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderCallerInfoTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.Reader;
+import java.io.StringReader;
+import java.nio.CharBuffer;
+
+import org.apache.logging.log4j.Level;
+import org.junit.Before;
+import org.junit.Test;
+
+public class LoggerBufferedReaderCallerInfoTest extends LoggerStreamsCallerInfoTesting {
+
+ LoggerBufferedReader logReader;
+
+ @Test
+ public void close() throws Exception {
+ this.logReader.readLine();
+ assertMessages("before close", 3, "close");
+ this.logReader.close();
+ assertMessages("after close", 4, "close");
+ }
+
+ @Test
+ public void read() throws Exception {
+ this.logReader.read();
+
+ assertMessages("read", 3, "read");
+ this.logReader.close();
+ }
+
+ @Test
+ public void readCbuf() throws Exception {
+ this.logReader.read(new char[2]);
+
+ assertMessages("read", 3, "readCbuf");
+ this.logReader.close();
+ }
+
+ @Test
+ public void readCbufOffset() throws Exception {
+ this.logReader.read(new char[2], 0, 2);
+
+ assertMessages("read", 3, "readCbufOffset");
+ this.logReader.close();
+ }
+
+ @Test
+ public void readCharBuffer() throws Exception {
+ this.logReader.read(CharBuffer.allocate(2));
+
+ assertMessages("read", 3, "readCharBuffer");
+ this.logReader.close();
+ }
+
+ @Test
+ public void readLine() throws Exception {
+ this.logReader.readLine();
+
+ assertMessages("read", 3, "readLine");
+ this.logReader.close();
+ }
+
+ @Before
+ public void setupReader() {
+ final Reader srcReader = new StringReader("a\nb\nc\nd");
+ this.logReader = new LoggerBufferedReader(srcReader, getLogger(), Level.WARN);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderTest.java
new file mode 100644
index 0000000..68e1811
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerBufferedReaderTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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 static org.junit.Assert.assertEquals;
+
+import java.io.BufferedReader;
+import java.io.Reader;
+
+import org.junit.Test;
+
+public class LoggerBufferedReaderTest extends LoggerReaderTest {
+ private BufferedReader bufferedReader;
+
+ @Override
+ protected Reader createReader() {
+ return this.bufferedReader = new LoggerBufferedReader(this.wrapped, getExtendedLogger(), LEVEL);
+ }
+
+ @Test
+ public void testReadLine() throws Exception {
+ assertEquals("first line", FIRST, this.bufferedReader.readLine());
+ assertMessages(FIRST);
+ assertEquals("second line", LAST, this.bufferedReader.readLine());
+ assertMessages(FIRST, LAST);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterOutputStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterOutputStreamTest.java
new file mode 100644
index 0000000..60e48c5
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterOutputStreamTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.ByteArrayOutputStream;
+import java.io.OutputStream;
+
+import org.apache.logging.log4j.Level;
+
+public class LoggerFilterOutputStreamTest extends AbstractLoggerOutputStreamTest {
+
+ @Override
+ protected ByteArrayOutputStream createOutputStream() {
+ return new ByteArrayOutputStream();
+ }
+
+ @Override
+ protected OutputStream createOutputStreamWrapper() {
+ return new LoggerFilterOutputStream(this.wrapped, getExtendedLogger(), Level.ERROR);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterWriterTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterWriterTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterWriterTest.java
new file mode 100644
index 0000000..a58a51e
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerFilterWriterTest.java
@@ -0,0 +1,18 @@
+package org.apache.logging.log4j.io;
+
+import java.io.StringWriter;
+import java.io.Writer;
+
+public class LoggerFilterWriterTest extends AbstractLoggerWriterTest {
+
+ @Override
+ protected StringWriter createWriter() {
+ return new StringWriter();
+ }
+
+ @Override
+ protected Writer createWriterWrapper() {
+ return new LoggerFilterWriter(this.wrapped, getExtendedLogger(), LEVEL);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/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
new file mode 100644
index 0000000..bd812aa
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamCallerInfoTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.apache.logging.log4j.Level;
+import org.junit.Before;
+import org.junit.Test;
+
+public class LoggerInputStreamCallerInfoTest extends LoggerStreamsCallerInfoTesting {
+
+ private LoggerInputStream logIn;
+
+ @Test
+ public void read() throws Exception {
+ this.logIn.read();
+ assertMessages("before read int size", 0, "read");
+ this.logIn.read();
+ assertMessages("after read int size", 1, "read");
+
+ this.logIn.read(new byte[2]);
+ assertMessages("after read bytes size", 2, "read");
+
+ this.logIn.read(new byte[2], 0, 2);
+ assertMessages("after read bytes offset size", 3, "read");
+
+ this.logIn.read();
+ assertMessages("before close size", 3, "read");
+ this.logIn.close();
+ assertMessages("after close size", 4, "read");
+ }
+
+ @Before
+ public void setupStreams() {
+ final InputStream srcInputStream = new ByteArrayInputStream("a\nb\nc\nd".getBytes());
+ this.logIn = new LoggerInputStream(srcInputStream, getLogger(), Level.WARN);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/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
new file mode 100644
index 0000000..cd727a6
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerInputStreamTest.java
@@ -0,0 +1,127 @@
+/*
+ * 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 static org.junit.Assert.assertEquals;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class LoggerInputStreamTest extends AbstractStreamTest {
+ protected ByteArrayInputStream wrapped;
+ protected ByteArrayOutputStream read;
+ protected InputStream in;
+
+ protected InputStream createInputStream() {
+ return new LoggerInputStream(this.wrapped, getExtendedLogger(), LEVEL);
+ }
+
+ @Before
+ public void createStream() {
+ this.wrapped = new ByteArrayInputStream((FIRST + "\r\n" + LAST).getBytes());
+ this.read = new ByteArrayOutputStream();
+ this.in = createInputStream();
+ }
+
+ @Test
+ public void testClose_HasRemainingData() throws IOException {
+ final byte[] bytes = new byte[1024];
+ this.in.read(bytes);
+ assertMessages(FIRST);
+ this.in.close();
+ assertMessages(FIRST, LAST);
+ }
+
+ @Test
+ public void testClose_NoRemainingData() throws IOException {
+ this.wrapped = new ByteArrayInputStream((FIRST + '\n').getBytes());
+ this.in = new LoggerInputStream(this.wrapped, getExtendedLogger(), LEVEL);
+
+ final byte[] bytes = new byte[1024];
+ this.in.read(bytes);
+ assertMessages(FIRST);
+ this.in.close();
+ assertMessages(FIRST);
+ }
+
+ @Test
+ public void testRead_ByteArray() throws Exception {
+ final byte[] bytes = new byte[FIRST.length()];
+ assertEquals("len", bytes.length, this.in.read(bytes));
+ if (!(this.in instanceof BufferedInputStream)) {
+ assertMessages();
+ }
+ this.in.read(bytes);
+ assertMessages(FIRST);
+ }
+
+ @Test
+ public void testRead_ByteArray_Offset_Length() throws Exception {
+ final byte[] bytes = new byte[FIRST.length() * 2];
+ assertEquals("len", FIRST.length(), this.in.read(bytes, 0, FIRST.length()));
+ if (!(this.in instanceof BufferedInputStream)) {
+ assertMessages();
+ }
+ this.in.read(bytes);
+ assertMessages(FIRST);
+ }
+
+ @Test
+ public void testRead_IgnoresWindowsNewline() throws IOException {
+ final byte[] bytes = new byte[1024];
+ final int len = this.in.read(bytes);
+ this.read.write(bytes, 0, len);
+ assertMessages(FIRST);
+ assertEquals(FIRST + "\r\n" + LAST, this.read.toString());
+ this.in.close();
+ assertMessages(FIRST, LAST);
+ }
+
+ @Test
+ public void testRead_int() throws Exception {
+ for (int i = 0; i < FIRST.length(); i++) {
+ this.read.write(this.in.read());
+ }
+ if (!(this.in instanceof BufferedInputStream)) {
+ assertMessages();
+ }
+ assertEquals("carriage return", '\r', this.in.read());
+ if (!(this.in instanceof BufferedInputStream)) {
+ assertMessages();
+ }
+ assertEquals("newline", '\n', this.in.read());
+ assertMessages(FIRST);
+ }
+
+ @Test
+ public void testRead_MultipleLines() throws IOException {
+ this.wrapped = new ByteArrayInputStream((FIRST + "\n" + LAST + '\n').getBytes());
+ this.in = new LoggerInputStream(this.wrapped, getExtendedLogger(), LEVEL);
+
+ final byte[] bytes = new byte[1024];
+ final int len = this.in.read(bytes);
+ this.read.write(bytes, 0, len);
+ assertMessages(FIRST, LAST);
+ assertEquals(FIRST + '\n' + LAST + '\n', this.read.toString());
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/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
new file mode 100644
index 0000000..c013fc6
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamCallerInfoTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.junit.Before;
+import org.junit.Test;
+
+public class LoggerOutputStreamCallerInfoTest extends LoggerStreamsCallerInfoTesting {
+
+ private LoggerOutputStream logOut;
+
+ @Before
+ public void setupStreams() {
+ this.logOut = new LoggerOutputStream(getExtendedLogger(), Level.WARN);
+ }
+
+ @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");
+
+ this.logOut.write("c\n".getBytes(), 0, 2);
+ assertMessages("after write byte array offset size", 3, "write");
+
+ this.logOut.write('d');
+ assertMessages("before close size", 3, "write");
+ this.logOut.close();
+ assertMessages("after close size", 4, "write");
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamTest.java
new file mode 100644
index 0000000..1631336
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerOutputStreamTest.java
@@ -0,0 +1,36 @@
+/*
+ * 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.ByteArrayOutputStream;
+import java.io.OutputStream;
+
+import org.apache.logging.log4j.Level;
+
+public class LoggerOutputStreamTest extends AbstractLoggerOutputStreamTest {
+
+ @Override
+ protected ByteArrayOutputStream createOutputStream() {
+ return null;
+ }
+
+ @Override
+ protected OutputStream createOutputStreamWrapper() {
+ return new LoggerOutputStream(getExtendedLogger(), Level.ERROR);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/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
new file mode 100644
index 0000000..2c533c3
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamCallerInfoTest.java
@@ -0,0 +1,146 @@
+/*
+ * 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.UnsupportedEncodingException;
+import java.util.Locale;
+
+import org.apache.logging.log4j.Level;
+import org.junit.Before;
+import org.junit.Test;
+
+public class LoggerPrintStreamCallerInfoTest extends LoggerStreamsCallerInfoTesting {
+
+ private LoggerPrintStream logOut;
+
+ @Test
+ public void close() throws Exception {
+ this.logOut.print("a\nb");
+ assertMessages("before close size", 1, "close");
+ this.logOut.close();
+ assertMessages("after close size", 2, "close");
+ }
+
+ @Test
+ public void print_boolean() throws Exception {
+ this.logOut.print(true);
+ assertMessages("print", 0, "print_boolean");
+ this.logOut.println(true);
+ assertMessages("println", 1, "print_boolean");
+ }
+
+ @Test
+ public void print_char() throws Exception {
+ this.logOut.print('a');
+ assertMessages("print", 0, "print_char");
+ this.logOut.println('b');
+ assertMessages("println", 1, "print_char");
+ }
+
+ @Test
+ public void print_chararray() throws Exception {
+ this.logOut.print("a".toCharArray());
+ assertMessages("print", 0, "print_chararray");
+ this.logOut.println("b".toCharArray());
+ assertMessages("println", 1, "print_chararray");
+ }
+
+ @Test
+ public void print_double() throws Exception {
+ this.logOut.print(1D);
+ assertMessages("print", 0, "print_double");
+ this.logOut.println(2D);
+ assertMessages("println", 1, "print_double");
+ }
+
+ @Test
+ public void print_float() throws Exception {
+ this.logOut.print(1f);
+ assertMessages("print", 0, "print_float");
+ this.logOut.println(2f);
+ assertMessages("println", 1, "print_float");
+ }
+
+ @Test
+ public void print_int() throws Exception {
+ this.logOut.print(1);
+ assertMessages("print", 0, "print_int");
+ this.logOut.println(2);
+ assertMessages("println", 1, "print_int");
+ }
+
+ @Test
+ public void print_long() throws Exception {
+ this.logOut.print(1L);
+ assertMessages("print", 0, "print_long");
+ this.logOut.println(2L);
+ assertMessages("println", 1, "print_long");
+ }
+
+ @Test
+ public void print_object() throws Exception {
+ this.logOut.print((Object) 'a');
+ assertMessages("print", 0, "print_object");
+ 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");
+ assertMessages("print", 0, "print_string");
+ this.logOut.println("b");
+ assertMessages("println", 1, "print_string");
+ }
+
+ @Before
+ public void setupStreams() throws UnsupportedEncodingException {
+ this.logOut = new LoggerPrintStream(getLogger(), Level.WARN);
+ }
+
+ @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');
+ assertMessages("write int", 0, "write_int");
+ this.logOut.write('\n');
+ assertMessages("write newline", 1, "write_int");
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamTest.java
new file mode 100644
index 0000000..38dd793
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintStreamTest.java
@@ -0,0 +1,122 @@
+/*
+ * 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+
+import org.junit.Test;
+
+public class LoggerPrintStreamTest extends AbstractLoggerOutputStreamTest {
+ private LoggerPrintStream print;
+
+ @Override
+ protected ByteArrayOutputStream createOutputStream() {
+ return new ByteArrayOutputStream();
+ }
+
+ @Override
+ protected OutputStream createOutputStreamWrapper() {
+ return this.print = new LoggerPrintStream(this.wrapped, getExtendedLogger(), LEVEL);
+ }
+
+ @Test
+ public void testFormat() throws Exception {
+ assertSame(this.print, this.print.format("[%s]", FIRST));
+ assertMessages();
+ this.print.println();
+ assertMessages("[" + FIRST + "]");
+ assertEquals("[" + FIRST + "]" + NEWLINE, this.wrapped.toString());
+ }
+
+ @Test
+ public void testPrint_boolean() throws Exception {
+ this.print.print(true);
+ assertMessages();
+ this.print.println();
+ assertMessages("true");
+ assertEquals("true" + NEWLINE, this.wrapped.toString());
+ }
+
+ @Test
+ public void testPrint_char() throws Exception {
+ for (final char c : FIRST.toCharArray()) {
+ this.print.print(c);
+ assertMessages();
+ }
+ this.print.println();
+ assertMessages(FIRST);
+ assertEquals(FIRST + NEWLINE, this.wrapped.toString());
+ }
+
+ @Test
+ public void testPrint_CharacterArray() throws Exception {
+ this.print.print(FIRST.toCharArray());
+ assertMessages();
+ this.print.println();
+ assertMessages(FIRST);
+ assertEquals(FIRST + NEWLINE, this.wrapped.toString());
+ }
+
+ @Test
+ public void testPrint_int() throws Exception {
+ this.print.print(12);
+ assertMessages();
+ this.print.println();
+ assertMessages("12");
+ assertEquals("12" + NEWLINE, this.wrapped.toString());
+ }
+
+ @Test
+ public void testPrint_long() throws Exception {
+ this.print.print(12L);
+ assertMessages();
+ this.print.println();
+ assertMessages("12");
+ assertEquals("12" + NEWLINE, this.wrapped.toString());
+ }
+
+ @Test
+ public void testPrint_Object() throws Exception {
+ this.print.print((Object) FIRST);
+ assertMessages();
+ this.print.println();
+ assertMessages(FIRST);
+ assertEquals(FIRST + NEWLINE, this.wrapped.toString());
+ }
+
+ @Test
+ public void testPrint_String() throws Exception {
+ this.print.print(FIRST);
+ assertMessages();
+ this.print.println();
+ assertMessages(FIRST);
+ assertEquals(FIRST + NEWLINE, this.wrapped.toString());
+ }
+
+ @Test
+ public void testPrintf() throws Exception {
+ assertSame(this.print, this.print.printf("<<<%s>>>", FIRST));
+ assertMessages();
+ this.print.println();
+ assertMessages("<<<" + FIRST + ">>>");
+ assertEquals("<<<" + FIRST + ">>>" + NEWLINE, this.wrapped.toString());
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/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
new file mode 100644
index 0000000..7502040
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterCallerInfoTest.java
@@ -0,0 +1,145 @@
+/*
+ * 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.Locale;
+
+import org.apache.logging.log4j.Level;
+import org.junit.Before;
+import org.junit.Test;
+
+public class LoggerPrintWriterCallerInfoTest extends LoggerStreamsCallerInfoTesting {
+
+ private LoggerPrintWriter logOut;
+
+ @Test
+ public void close() throws Exception {
+ this.logOut.print("a\nb");
+ assertMessages("before close size", 1, "close");
+ this.logOut.close();
+ assertMessages("after close size", 2, "close");
+ }
+
+ @Test
+ public void print_boolean() throws Exception {
+ this.logOut.print(true);
+ assertMessages("print", 0, "print_boolean");
+ this.logOut.println(true);
+ assertMessages("println", 1, "print_boolean");
+ }
+
+ @Test
+ public void print_char() throws Exception {
+ this.logOut.print('a');
+ assertMessages("print", 0, "print_char");
+ this.logOut.println('b');
+ assertMessages("println", 1, "print_char");
+ }
+
+ @Test
+ public void print_chararray() throws Exception {
+ this.logOut.print("a".toCharArray());
+ assertMessages("print", 0, "print_chararray");
+ this.logOut.println("b".toCharArray());
+ assertMessages("println", 1, "print_chararray");
+ }
+
+ @Test
+ public void print_double() throws Exception {
+ this.logOut.print(1D);
+ assertMessages("print", 0, "print_double");
+ this.logOut.println(2D);
+ assertMessages("println", 1, "print_double");
+ }
+
+ @Test
+ public void print_float() throws Exception {
+ this.logOut.print(1f);
+ assertMessages("print", 0, "print_float");
+ this.logOut.println(2f);
+ assertMessages("println", 1, "print_float");
+ }
+
+ @Test
+ public void print_int() throws Exception {
+ this.logOut.print(1);
+ assertMessages("print", 0, "print_int");
+ this.logOut.println(2);
+ assertMessages("println", 1, "print_int");
+ }
+
+ @Test
+ public void print_long() throws Exception {
+ this.logOut.print(1L);
+ assertMessages("print", 0, "print_long");
+ this.logOut.println(2L);
+ assertMessages("println", 1, "print_long");
+ }
+
+ @Test
+ public void print_object() throws Exception {
+ this.logOut.print((Object) 'a');
+ assertMessages("print", 0, "print_object");
+ 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");
+ assertMessages("print", 0, "print_string");
+ this.logOut.println("b");
+ assertMessages("println", 1, "print_string");
+ }
+
+ @Before
+ public void setupStreams() {
+ this.logOut = new LoggerPrintWriter(getLogger(), Level.WARN);
+ }
+
+ @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');
+ assertMessages("write int", 0, "write_int");
+ this.logOut.write('\n');
+ assertMessages("write newline", 1, "write_int");
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/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
new file mode 100644
index 0000000..7b13086
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerPrintWriterTest.java
@@ -0,0 +1,124 @@
+/*
+ * 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import org.junit.Test;
+
+public class LoggerPrintWriterTest extends AbstractLoggerWriterTest {
+ private PrintWriter print;
+
+ @Override
+ protected StringWriter createWriter() {
+ return new StringWriter();
+ }
+
+ @Override
+ protected Writer createWriterWrapper() {
+ this.print = new LoggerPrintWriter(this.wrapped, getExtendedLogger(), LEVEL);
+ return this.print;
+ }
+
+ @Test
+ public void testFormat() throws Exception {
+ assertSame(this.print, this.print.format("[%s]", FIRST));
+ assertMessages();
+ this.print.println();
+ assertMessages("[" + FIRST + "]");
+ assertEquals("[" + FIRST + "]" + NEWLINE, this.wrapped.toString());
+ }
+
+ @Test
+ public void testPrint_boolean() throws Exception {
+ this.print.print(true);
+ assertMessages();
+ this.print.println();
+ assertMessages("true");
+ assertEquals("true" + NEWLINE, this.wrapped.toString());
+ }
+
+ @Test
+ public void testPrint_char() throws Exception {
+ for (final char c : FIRST.toCharArray()) {
+ this.print.print(c);
+ assertMessages();
+ }
+ this.print.println();
+ assertMessages(FIRST);
+ assertEquals(FIRST + NEWLINE, this.wrapped.toString());
+ }
+
+ @Test
+ public void testPrint_CharacterArray() throws Exception {
+ this.print.print(FIRST.toCharArray());
+ assertMessages();
+ this.print.println();
+ assertMessages(FIRST);
+ assertEquals(FIRST + NEWLINE, this.wrapped.toString());
+ }
+
+ @Test
+ public void testPrint_int() throws Exception {
+ this.print.print(12);
+ assertMessages();
+ this.print.println();
+ assertMessages("12");
+ assertEquals("12" + NEWLINE, this.wrapped.toString());
+ }
+
+ @Test
+ public void testPrint_long() throws Exception {
+ this.print.print(12L);
+ assertMessages();
+ this.print.println();
+ assertMessages("12");
+ assertEquals("12" + NEWLINE, this.wrapped.toString());
+ }
+
+ @Test
+ public void testPrint_Object() throws Exception {
+ this.print.print((Object) FIRST);
+ assertMessages();
+ this.print.println();
+ assertMessages(FIRST);
+ assertEquals(FIRST + NEWLINE, this.wrapped.toString());
+ }
+
+ @Test
+ public void testPrint_String() throws Exception {
+ this.print.print(FIRST);
+ assertMessages();
+ this.print.println();
+ assertMessages(FIRST);
+ assertEquals(FIRST + NEWLINE, this.wrapped.toString());
+ }
+
+ @Test
+ public void testPrintf() throws Exception {
+ assertSame(this.print, this.print.printf("<<<%s>>>", FIRST));
+ assertMessages();
+ this.print.println();
+ assertMessages("<<<" + FIRST + ">>>");
+ assertEquals("<<<" + FIRST + ">>>" + NEWLINE, this.wrapped.toString());
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/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
new file mode 100644
index 0000000..5e114e3
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderCallerInfoTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.Reader;
+import java.io.StringReader;
+import java.nio.CharBuffer;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class LoggerReaderCallerInfoTest extends LoggerStreamsCallerInfoTesting {
+
+ LoggerReader logReader;
+
+ @Test
+ public void read() throws Exception {
+ this.logReader.read();
+ assertMessages("before read int size", 0, "read");
+ this.logReader.read();
+ assertMessages("after read int size", 1, "read");
+
+ this.logReader.read(new char[2]);
+ assertMessages("after read bytes size", 2, "read");
+
+ this.logReader.read(new char[2], 0, 2);
+ assertMessages("after read bytes offset size", 3, "read");
+
+ this.logReader.read(CharBuffer.allocate(2));
+ assertMessages("after read charBuffer size", 4, "read");
+
+ this.logReader.read();
+ assertMessages("before close size", 4, "read");
+ this.logReader.close();
+ assertMessages("after close size", 5, "read");
+ }
+
+ @Before
+ public void setupReader() {
+ final Reader srcReader = new StringReader("a\nb\nc\nd\ne");
+ this.logReader = new LoggerReader(srcReader, getLogger(), LEVEL);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/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
new file mode 100644
index 0000000..4f89d7b
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerReaderTest.java
@@ -0,0 +1,141 @@
+/*
+ * 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 static org.junit.Assert.assertEquals;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.nio.CharBuffer;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class LoggerReaderTest extends AbstractStreamTest {
+ protected StringReader wrapped;
+ protected StringWriter read;
+ protected Reader reader;
+
+ protected Reader createReader() {
+ return new LoggerReader(this.wrapped, getExtendedLogger(), LEVEL);
+ }
+
+ @Before
+ public void createStream() {
+ this.wrapped = new StringReader(FIRST + "\r\n" + LAST);
+ this.read = new StringWriter();
+ this.reader = createReader();
+ }
+
+ @Test
+ public void testClose_HasRemainingData() throws IOException {
+ final char[] chars = new char[1024];
+ this.reader.read(chars);
+ if (!(this.reader instanceof BufferedReader)) {
+ assertMessages(FIRST);
+ }
+ this.reader.close();
+ assertMessages(FIRST, LAST);
+ }
+
+ @Test
+ public void testClose_NoRemainingData() throws IOException {
+ this.wrapped = new StringReader(FIRST + '\n');
+ this.reader = createReader();
+
+ final char[] chars = new char[1024];
+ this.reader.read(chars);
+ assertMessages(FIRST);
+ this.reader.close();
+ assertMessages(FIRST);
+ }
+
+ @Test
+ public void testRead_CharArray() throws Exception {
+ final char[] chars = new char[FIRST.length()];
+ assertEquals("len", FIRST.length(), this.reader.read(chars));
+ if (!(this.reader instanceof BufferedReader)) {
+ assertMessages();
+ }
+ this.reader.read(chars);
+ assertMessages(FIRST);
+ }
+
+ @Test
+ public void testRead_CharArray_Offset_Length() throws Exception {
+ final char[] chars = new char[1024];
+ assertEquals("len", FIRST.length(), this.reader.read(chars, 0, FIRST.length()));
+ if (!(this.reader instanceof BufferedReader)) {
+ assertMessages();
+ }
+ this.reader.read(chars);
+ this.reader.close();
+ assertMessages(FIRST, LAST);
+ }
+
+ @Test
+ public void testRead_CharBuffer() throws Exception {
+ final CharBuffer chars = CharBuffer.allocate(1024);
+ assertEquals("len", FIRST.length() + LAST.length() + 2, this.reader.read(chars));
+ this.reader.close();
+ assertMessages(FIRST, LAST);
+ }
+
+ @Test
+ public void testRead_IgnoresWindowsNewline() throws IOException {
+ final char[] chars = new char[1024];
+ final int len = this.reader.read(chars);
+ this.read.write(chars, 0, len);
+ if (!(this.reader instanceof BufferedReader)) {
+ assertMessages(FIRST);
+ }
+ assertEquals(FIRST + "\r\n" + LAST, this.read.toString());
+ this.reader.close();
+ assertMessages(FIRST, LAST);
+ }
+
+ @Test
+ public void testRead_int() throws Exception {
+ for (int i = 0; i < FIRST.length(); i++) {
+ this.read.write(this.reader.read());
+ }
+ if (!(this.reader instanceof BufferedReader)) {
+ assertMessages();
+ }
+ assertEquals("carriage return", '\r', this.reader.read());
+ if (!(this.reader instanceof BufferedReader)) {
+ assertMessages();
+ }
+ assertEquals("newline", '\n', this.reader.read());
+ assertMessages(FIRST);
+ }
+
+ @Test
+ public void testRead_MultipleLines() throws IOException {
+ this.wrapped = new StringReader(FIRST + "\n" + LAST + '\n');
+ this.reader = createReader();
+
+ final char[] chars = new char[1024];
+ final int len = this.reader.read(chars);
+ this.read.write(chars, 0, len);
+ assertMessages(FIRST, LAST);
+ assertEquals(FIRST + '\n' + LAST + '\n', this.read.toString());
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerStreamsCallerInfoTesting.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerStreamsCallerInfoTesting.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerStreamsCallerInfoTesting.java
new file mode 100644
index 0000000..8f050b3
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerStreamsCallerInfoTesting.java
@@ -0,0 +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 static org.junit.Assert.assertEquals;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.junit.InitialLoggerContext;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.Before;
+import org.junit.ClassRule;
+
+public class LoggerStreamsCallerInfoTesting {
+
+ protected static Logger getExtendedLogger() {
+ return ctx.getLogger("ClassAndMethodLogger");
+ }
+
+ protected static Logger getLogger() {
+ return getExtendedLogger();
+ }
+
+ protected final static Level LEVEL = Level.WARN;
+
+ @ClassRule
+ public static InitialLoggerContext ctx = new InitialLoggerContext("log4j2-streams-calling-info.xml");
+
+ public void assertMessages(final String msg, final int size, final String methodName) {
+ final ListAppender appender = (ListAppender) ctx.getAppender("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() {
+ ((ListAppender) ctx.getAppender("ClassAndMethod")).clear();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerWriterTest.java
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerWriterTest.java b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerWriterTest.java
new file mode 100644
index 0000000..3d261be
--- /dev/null
+++ b/log4j-iostreams/src/test/java/org/apache/logging/log4j/io/LoggerWriterTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.StringWriter;
+import java.io.Writer;
+
+public class LoggerWriterTest extends AbstractLoggerWriterTest {
+
+ @Override
+ protected StringWriter createWriter() {
+ return null;
+ }
+
+ @Override
+ protected Writer createWriterWrapper() {
+ return new LoggerWriter(getExtendedLogger(), LEVEL);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-iostreams/src/test/resources/log4j2-streams-calling-info.xml
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/resources/log4j2-streams-calling-info.xml b/log4j-iostreams/src/test/resources/log4j2-streams-calling-info.xml
new file mode 100644
index 0000000..5f8dfd9
--- /dev/null
+++ b/log4j-iostreams/src/test/resources/log4j2-streams-calling-info.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<Configuration name="CallerInformationTest" status="error" packages="org.apache.logging.log4j.test">
+ <Appenders>
+ <List name="ClassAndMethod">
+ <PatternLayout pattern="%class.%method"/>
+ </List>
+ </Appenders>
+ <Loggers>
+ <Logger name="ClassAndMethodLogger" level="info">
+ <AppenderRef ref="ClassAndMethod"/>
+ </Logger>
+ <Root level="off"/>
+ </Loggers>
+</Configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-iostreams/src/test/resources/log4j2-streams-unit-test.xml
----------------------------------------------------------------------
diff --git a/log4j-iostreams/src/test/resources/log4j2-streams-unit-test.xml b/log4j-iostreams/src/test/resources/log4j2-streams-unit-test.xml
new file mode 100644
index 0000000..d6f0211
--- /dev/null
+++ b/log4j-iostreams/src/test/resources/log4j2-streams-unit-test.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<Configuration name="UnitTest" status="error" packages="org.apache.logging.log4j.test">
+ <Appenders>
+ <List name="UnitTest">
+ <PatternLayout pattern="%level %m%n"/>
+ </List>
+ </Appenders>
+ <Loggers>
+ <Logger name="UnitTestLogger" level="info">
+ <AppenderRef ref="UnitTest"/>
+ </Logger>
+ <Root level="off"/>
+ </Loggers>
+</Configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/.gitignore
----------------------------------------------------------------------
diff --git a/log4j-streams/.gitignore b/log4j-streams/.gitignore
deleted file mode 100644
index b79adc7..0000000
Binary files a/log4j-streams/.gitignore and /dev/null differ
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/pom.xml
----------------------------------------------------------------------
diff --git a/log4j-streams/pom.xml b/log4j-streams/pom.xml
deleted file mode 100644
index 5a38cc9..0000000
--- a/log4j-streams/pom.xml
+++ /dev/null
@@ -1,212 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>2.1-SNAPSHOT</version>
- <relativePath>../</relativePath>
- </parent>
- <artifactId>log4j-streams</artifactId>
- <version>2.1-SNAPSHOT</version>
- <packaging>jar</packaging>
- <name>Apache Log4j Streaming Interface</name>
- <description>Provides the ability to convert streams into log statements</description>
- <properties>
- <log4jParentDir>${basedir}/..</log4jParentDir>
- <docLabel>Streaming Documentation</docLabel>
- <projectDir>/slf4j-streams</projectDir>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- <scope>test</scope>
- </dependency>
-
- <!-- TEST DEPENDENCIES -->
-
- <!-- Pull in useful test classes from API -->
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <!-- Include the standard NOTICE and LICENSE -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-remote-resources-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>process</goal>
- </goals>
- <configuration>
- <skip>false</skip>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-changes-plugin</artifactId>
- <version>${changes.plugin.version}</version>
- <reportSets>
- <reportSet>
- <reports>
- <report>changes-report</report>
- </reports>
- </reportSet>
- </reportSets>
- <configuration>
- <issueLinkTemplate>%URL%/show_bug.cgi?id=%ISSUE%</issueLinkTemplate>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>2.7</version>
- <configuration>
- <!--<propertiesLocation>${vfs.parent.dir}/checkstyle.properties</propertiesLocation> -->
- <configLocation>${log4jParentDir}/checkstyle.xml</configLocation>
- <suppressionsLocation>${log4jParentDir}/checkstyle-suppressions.xml</suppressionsLocation>
- <enableRulesSummary>false</enableRulesSummary>
- <propertyExpansion>basedir=${basedir}</propertyExpansion>
- <propertyExpansion>licensedir=${log4jParentDir}/checkstyle-header.txt</propertyExpansion>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>${javadoc.plugin.version}</version>
- <configuration>
- <bottom> <![CDATA[<p align="center">Copyright © {inceptionYear}-{currentYear} {organizationName}. All Rights Reserved.<br />
- Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo,
- and the Apache Log4j logo are trademarks of The Apache Software Foundation.</p>]]></bottom>
- <!-- module link generation is completely broken in the javadoc plugin for a multi-module non-aggregating
- project -->
- <detectOfflineLinks>false</detectOfflineLinks>
- <linksource>true</linksource>
- <tags>
- <tag>
- <name>issue</name>
- <placement>a</placement>
- <head>JIRA issue:</head>
- </tag>
- <tag>
- <name>doubt</name>
- <placement>a</placement>
- <head>Troublesome:</head>
- </tag>
- <tag>
- <name>compare</name>
- <placement>a</placement>
- <head>Compare with:</head>
- </tag>
- </tags>
- </configuration>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>javadoc</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>2.5.2</version>
- <configuration>
- <fork>true</fork>
- <jvmArgs>-Duser.language=en</jvmArgs>
- <threshold>Normal</threshold>
- <effort>Default</effort>
- <excludeFilterFile>${log4jParentDir}/findbugs-exclude-filter.xml</excludeFilterFile>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jxr-plugin</artifactId>
- <version>2.3</version>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>jxr</report>
- </reports>
- </reportSet>
- <reportSet>
- <id>aggregate</id>
- <reports>
- <report>aggregate</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-pmd-plugin</artifactId>
- <version>${pmd.plugin.version}</version>
- <configuration>
- <targetJdk>${maven.compile.target}</targetJdk>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>${cobertura.plugin.version}</version>
- <reportSets>
- <reportSet>
- <!-- Disabled as it makes the site build very slow and causes the performance unit test to fail -->
- <reports />
- </reportSet>
- </reportSets>
- </plugin>
- </plugins>
- </reporting>
-</project>
-
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedInputStream.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedInputStream.java b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedInputStream.java
deleted file mode 100644
index c126dbb..0000000
--- a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedInputStream.java
+++ /dev/null
@@ -1,104 +0,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.streams;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-
-public class LoggerBufferedInputStream extends BufferedInputStream {
- private static final String FQCN = LoggerBufferedInputStream.class.getName();
-
- public LoggerBufferedInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger, final Level level) {
- this(in, charset, logger, FQCN, level, null);
- }
-
- public LoggerBufferedInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger, final Level level, final Marker marker) {
- this(in, charset, logger, FQCN, level, marker);
- }
-
- public LoggerBufferedInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
- super(new LoggerInputStream(in, charset, logger, fqcn, level, marker));
- }
-
- public LoggerBufferedInputStream(final InputStream in, final Charset charset, final int size, final ExtendedLogger logger, final Level level) {
- this(in, charset, size, logger, FQCN, level, null);
- }
-
- public LoggerBufferedInputStream(final InputStream in, final Charset charset, final int size, final ExtendedLogger logger, final Level level, final Marker marker) {
- this(in, charset, size, logger, FQCN, level, marker);
- }
-
- public LoggerBufferedInputStream(final InputStream in, final Charset charset, final int size, final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
- super(new LoggerInputStream(in, charset, logger, fqcn, level, marker), size);
- }
-
- public LoggerBufferedInputStream(final InputStream in, final ExtendedLogger logger, final Level level) {
- this(in, logger, FQCN, level, null);
- }
-
- public LoggerBufferedInputStream(final InputStream in, final ExtendedLogger logger, final Level level, final Marker marker) {
- this(in, logger, FQCN, level, marker);
- }
-
- public LoggerBufferedInputStream(final InputStream in, final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
- this(in, Charset.defaultCharset(), logger, fqcn, level, marker);
- }
-
- public LoggerBufferedInputStream(final InputStream in, final int size, final ExtendedLogger logger, final Level level) {
- this(in, size, logger, FQCN, level, null);
- }
-
- public LoggerBufferedInputStream(final InputStream in, final int size, final ExtendedLogger logger, final Level level, final Marker marker) {
- this(in, size, logger, FQCN, level, marker);
- }
-
- public LoggerBufferedInputStream(final InputStream in, final int size, final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
- this(in, Charset.defaultCharset(), size, logger, fqcn, level, marker);
- }
-
- @Override
- 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);
- }
-
- @Override
- public String toString() {
- return LoggerBufferedInputStream.class.getSimpleName() + "{stream=" + this.in + '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ffc1a38a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedReader.java
----------------------------------------------------------------------
diff --git a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedReader.java b/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedReader.java
deleted file mode 100644
index da770a7..0000000
--- a/log4j-streams/src/main/java/org/apache/logging/log4j/streams/LoggerBufferedReader.java
+++ /dev/null
@@ -1,91 +0,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.streams;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.nio.CharBuffer;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.spi.ExtendedLogger;
-
-public class LoggerBufferedReader extends BufferedReader {
- private static final String FQCN = LoggerBufferedReader.class.getName();
-
- public LoggerBufferedReader(final Reader reader, final ExtendedLogger logger, final Level level) {
- this(reader, logger, FQCN, level, null);
- }
-
- public LoggerBufferedReader(final Reader reader, final ExtendedLogger logger, final Level level, final Marker marker) {
- this(reader, logger, FQCN, level, marker);
- }
-
- public LoggerBufferedReader(final Reader reader, final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
- super(new LoggerReader(reader, logger, FQCN, level, marker));
- }
-
- public LoggerBufferedReader(final Reader reader, final int size, final ExtendedLogger logger, final Level level) {
- this(reader, size, logger, FQCN, level, null);
- }
-
- public LoggerBufferedReader(final Reader reader, final int size, final ExtendedLogger logger, final Level level, final Marker marker) {
- this(reader, size, logger, FQCN, level, marker);
- }
-
- public LoggerBufferedReader(final Reader reader, final int size, final ExtendedLogger logger, final String fqcn, final Level level, final Marker marker) {
- super(new LoggerReader(reader, logger, 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();
- final char[] cbuf = new char[len];
- final int charsRead = read(cbuf, 0, len);
- if (charsRead > 0) {
- target.put(cbuf, 0, charsRead);
- }
- return charsRead;
- }
-
- @Override
- public String readLine() throws IOException {
- return super.readLine();
- }
-}