Skip to content

Commit dbaf495

Browse files
author
Gary Gregory
committed
Reuse own code.
1 parent f8e63a0 commit dbaf495

1 file changed

Lines changed: 7 additions & 38 deletions

File tree

src/test/java/org/apache/commons/io/IOUtilsTest.java

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import org.apache.commons.io.output.AppendableWriter;
6666
import org.apache.commons.io.output.CountingOutputStream;
6767
import org.apache.commons.io.output.NullOutputStream;
68+
import org.apache.commons.io.output.NullWriter;
6869
import org.apache.commons.io.output.StringBuilderWriter;
6970
import org.apache.commons.io.test.TestUtils;
7071
import org.apache.commons.io.test.ThrowOnCloseReader;
@@ -251,49 +252,17 @@ public int read(final char[] cbuf, final int off, final int len) throws IOExcept
251252

252253
@Test
253254
public void testAsBufferedWriter() {
254-
final Writer is = new Writer() {
255-
@Override
256-
public void close() throws IOException {
257-
}
258-
259-
@Override
260-
public void flush() throws IOException {
261-
}
262-
263-
@Override
264-
public void write(final char[] cbuf, final int off, final int len) throws IOException {
265-
}
266-
267-
@Override
268-
public void write(final int b) throws IOException {
269-
}
270-
};
271-
final BufferedWriter bis = IOUtils.buffer(is);
272-
assertNotSame(is, bis);
255+
final Writer nullWriter = NullWriter.INSTANCE;
256+
final BufferedWriter bis = IOUtils.buffer(nullWriter);
257+
assertNotSame(nullWriter, bis);
273258
assertSame(bis, IOUtils.buffer(bis));
274259
}
275260

276261
@Test
277262
public void testAsBufferedWriterWithBufferSize() {
278-
final Writer w = new Writer() {
279-
@Override
280-
public void close() throws IOException {
281-
}
282-
283-
@Override
284-
public void flush() throws IOException {
285-
}
286-
287-
@Override
288-
public void write(final char[] cbuf, final int off, final int len) throws IOException {
289-
}
290-
291-
@Override
292-
public void write(final int b) throws IOException {
293-
}
294-
};
295-
final BufferedWriter bw = IOUtils.buffer(w, 2024);
296-
assertNotSame(w, bw);
263+
final Writer nullWriter = NullWriter.INSTANCE;
264+
final BufferedWriter bw = IOUtils.buffer(nullWriter, 2024);
265+
assertNotSame(nullWriter, bw);
297266
assertSame(bw, IOUtils.buffer(bw));
298267
assertSame(bw, IOUtils.buffer(bw, 1024));
299268
}

0 commit comments

Comments
 (0)