Author: niallp Date: Thu Oct 12 17:37:09 2006 New Revision: 463529 URL: http://svn.apache.org/viewvc?view=rev&rev=463529 Log: IO-94 - Re-name MockInputStream/MockReader to NullInputStream/NullReader
Added: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/NullInputStream.java - copied, changed from r463147, jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/MockInputStream.java jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/NullReader.java - copied, changed from r463147, jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/MockReader.java jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/NullInputStreamTest.java - copied, changed from r463147, jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/MockInputStreamTestCase.java jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/NullReaderTest.java - copied, changed from r463147, jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/MockReaderTestCase.java Removed: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/MockInputStream.java jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/MockReader.java jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/MockInputStreamTestCase.java jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/MockReaderTestCase.java Modified: jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/PackageTestSuite.java Modified: jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt?view=diff&rev=463529&r1=463528&r2=463529 ============================================================================== --- jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt (original) +++ jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt Thu Oct 12 17:37:09 2006 @@ -146,6 +146,12 @@ - NullWriter - New writer that acts as a sink for all data, as per /dev/null +- NullInputStream + - New input stream that emulates a stream of a specified size + +- NullReader + - New reader that emulates a reader of a specified size + Feedback -------- Copied: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/NullInputStream.java (from r463147, jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/MockInputStream.java) URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/NullInputStream.java?view=diff&rev=463529&p1=jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/MockInputStream.java&r1=463147&p2=jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/NullInputStream.java&r2=463529 ============================================================================== --- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/MockInputStream.java (original) +++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/NullInputStream.java Thu Oct 12 17:37:09 2006 @@ -21,9 +21,10 @@ import java.io.InputStream; /** - * A mock [EMAIL PROTECTED] InputStream} for testing purposes. + * A functional, light weight [EMAIL PROTECTED] InputStream} that emulates + * a stream of a specified size. * <p> - * This implementation provides a light weight mock + * This implementation provides a light weight * object for testing with an [EMAIL PROTECTED] InputStream} * where the contents don't matter. * <p> @@ -33,15 +34,33 @@ * large numbers of bytes - significantly speeding up * test execution times. * <p> - * Alternatively, if some kind of data is required as part - * of a test the <code>processByte()</code> and + * This implementation returns zero from the method that + * reads a byte and leaves the array unchanged in the read + * methods that are passed a byte array. + * If alternative data is required the <code>processByte()</code> and * <code>processBytes()</code> methods can be implemented to generate - * test data. + * data, for example: + * + * <pre> + * public class TestInputStream extends NullInputStream { + * public TestInputStream(int size) { + * super(size); + * } + * protected int processByte() { + * return ... // return required value here + * } + * protected void processBytes(byte[] bytes, int offset, int length) { + * for (int i = offset; i < length; i++) { + * bytes[i] = ... // set array value here + * } + * } + * } + * </pre> * * @since Commons IO 1.3 * @version $Revision$ */ -public class MockInputStream extends InputStream { +public class NullInputStream extends InputStream { private long size; private long position; @@ -52,27 +71,27 @@ private boolean markSupported; /** - * Create a mock [EMAIL PROTECTED] InputStream} of the specified size + * Create an [EMAIL PROTECTED] InputStream} that emulates a specified size * which supports marking and does not throw EOFException. * - * @param size The size of the mock input stream. + * @param size The size of the input stream to emulate. */ - public MockInputStream(long size) { + public NullInputStream(long size) { this(size, true, false); } /** - * Create a mock [EMAIL PROTECTED] InputStream} of the specified - * size and option settings. + * Create an [EMAIL PROTECTED] InputStream} that emulates a specified + * size with option settings. * - * @param size The size of the mock input stream. + * @param size The size of the input stream to emulate. * @param markSupported Whether this instance will support * the <code>mark()</code> functionality. * @param throwEofException Whether this implementation * will throw an [EMAIL PROTECTED] EOFException} or return -1 when the * end of file is reached. */ - public MockInputStream(long size, boolean markSupported, boolean throwEofException) { + public NullInputStream(long size, boolean markSupported, boolean throwEofException) { this.size = size; this.markSupported = markSupported; this.throwEofException = throwEofException; @@ -88,9 +107,9 @@ } /** - * Return the size of this Mock [EMAIL PROTECTED] InputStream} + * Return the size this [EMAIL PROTECTED] InputStream} emulates. * - * @return the size of the mock input stream. + * @return The size of the input stream to emulate. */ public long getSize() { return size; Copied: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/NullReader.java (from r463147, jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/MockReader.java) URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/NullReader.java?view=diff&rev=463529&p1=jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/MockReader.java&r1=463147&p2=jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/NullReader.java&r2=463529 ============================================================================== --- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/MockReader.java (original) +++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/NullReader.java Thu Oct 12 17:37:09 2006 @@ -21,10 +21,11 @@ import java.io.Reader; /** - * A mock [EMAIL PROTECTED] Reader} for testing purposes. + * A functional, light weight [EMAIL PROTECTED] Reader} that emulates + * a reader of a specified size. * <p> - * This implementation provides a light weight mock - * object for testing with a [EMAIL PROTECTED] Reader} + * This implementation provides a light weight + * object for testing with an [EMAIL PROTECTED] Reader} * where the contents don't matter. * <p> * One use case would be for testing the handling of @@ -33,15 +34,33 @@ * large numbers of characters - significantly speeding up * test execution times. * <p> - * Alternatively, if some kind of data is required as part - * of a test the <code>processChar()</code> and + * This implementation returns a space from the method that + * reads a character and leaves the array unchanged in the read + * methods that are passed a character array. + * If alternative data is required the <code>processChar()</code> and * <code>processChars()</code> methods can be implemented to generate - * test data. + * data, for example: + * + * <pre> + * public class TestReader extends NullReader { + * public TestReader(int size) { + * super(size); + * } + * protected char processChar() { + * return ... // return required value here + * } + * protected void processChars(char[] chars, int offset, int length) { + * for (int i = offset; i < length; i++) { + * chars[i] = ... // set array value here + * } + * } + * } + * </pre> * * @since Commons IO 1.3 * @version $Revision$ */ -public class MockReader extends Reader { +public class NullReader extends Reader { private long size; private long position; @@ -52,27 +71,27 @@ private boolean markSupported; /** - * Create a mock [EMAIL PROTECTED] Reader} of the specified size + * Create a [EMAIL PROTECTED] Reader} that emulates a specified size * which supports marking and does not throw EOFException. * - * @param size The size of the mock Reader. + * @param size The size of the reader to emulate. */ - public MockReader(long size) { + public NullReader(long size) { this(size, true, false); } /** - * Create a mock [EMAIL PROTECTED] Reader} of the specified - * size and option settings. + * Create a [EMAIL PROTECTED] Reader} that emulates a specified + * size with option settings. * - * @param size The size of the mock Reader. + * @param size The size of the reader to emulate. * @param markSupported Whether this instance will support * the <code>mark()</code> functionality. * @param throwEofException Whether this implementation * will throw an [EMAIL PROTECTED] EOFException} or return -1 when the * end of file is reached. */ - public MockReader(long size, boolean markSupported, boolean throwEofException) { + public NullReader(long size, boolean markSupported, boolean throwEofException) { this.size = size; this.markSupported = markSupported; this.throwEofException = throwEofException; @@ -88,9 +107,9 @@ } /** - * Return the size of this Mock [EMAIL PROTECTED] Reader} + * Return the size this [EMAIL PROTECTED] Reader} emulates. * - * @return the size of the mock Reader. + * @return The size of the reader to emulate. */ public long getSize() { return size; Copied: jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/NullInputStreamTest.java (from r463147, jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/MockInputStreamTestCase.java) URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/NullInputStreamTest.java?view=diff&rev=463529&p1=jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/MockInputStreamTestCase.java&r1=463147&p2=jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/NullInputStreamTest.java&r2=463529 ============================================================================== --- jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/MockInputStreamTestCase.java (original) +++ jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/NullInputStreamTest.java Thu Oct 12 17:37:09 2006 @@ -23,14 +23,14 @@ import junit.framework.TestCase; /** - * JUnit Test Case for [EMAIL PROTECTED] MockInputStream}. + * JUnit Test Case for [EMAIL PROTECTED] NullInputStream}. * * @version $Id$ */ -public class MockInputStreamTestCase extends TestCase { +public class NullInputStreamTest extends TestCase { /** Constructor */ - public MockInputStreamTestCase(String name) { + public NullInputStreamTest(String name) { super(name); } @@ -49,7 +49,7 @@ */ public void testRead() throws Exception { int size = 5; - InputStream input = new TestMockInputStream(size); + InputStream input = new TestNullInputStream(size); for (int i = 0; i < size; i++) { assertEquals("Check Size [" + i + "]", (size - i), input.available()); assertEquals("Check Value [" + i + "]", i, input.read()); @@ -78,7 +78,7 @@ */ public void testReadByteArray() throws Exception { byte[] bytes = new byte[10]; - InputStream input = new TestMockInputStream(15); + InputStream input = new TestNullInputStream(15); // Read into array int count1 = input.read(bytes); @@ -124,7 +124,7 @@ * (rather than return -1). */ public void testEOFException() throws Exception { - InputStream input = new TestMockInputStream(2, false, true); + InputStream input = new TestNullInputStream(2, false, true); assertEquals("Read 1", 0, input.read()); assertEquals("Read 2", 1, input.read()); try { @@ -141,7 +141,7 @@ public void testMarkAndReset() throws Exception { int position = 0; int readlimit = 10; - InputStream input = new TestMockInputStream(100, true, false); + InputStream input = new TestNullInputStream(100, true, false); assertTrue("Mark Should be Supported", input.markSupported()); @@ -192,7 +192,7 @@ * Test <code>mark()</code> not supported. */ public void testMarkNotSupported() throws Exception { - InputStream input = new TestMockInputStream(100, false, true); + InputStream input = new TestNullInputStream(100, false, true); assertFalse("Mark Should NOT be Supported", input.markSupported()); try { @@ -214,7 +214,7 @@ * Test <code>skip()</code> method. */ public void testSkip() throws Exception { - InputStream input = new TestMockInputStream(10, true, false); + InputStream input = new TestNullInputStream(10, true, false); assertEquals("Read 1", 0, input.read()); assertEquals("Read 2", 1, input.read()); assertEquals("Skip 1", 5, input.skip(5)); @@ -232,13 +232,13 @@ } - // ------------- Test MockInputStream implementation ------------- + // ------------- Test NullInputStream implementation ------------- - private static final class TestMockInputStream extends MockInputStream { - public TestMockInputStream(int size) { + private static final class TestNullInputStream extends NullInputStream { + public TestNullInputStream(int size) { super(size); } - public TestMockInputStream(int size, boolean markSupported, boolean throwEofException) { + public TestNullInputStream(int size, boolean markSupported, boolean throwEofException) { super(size, markSupported, throwEofException); } protected int processByte() { Copied: jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/NullReaderTest.java (from r463147, jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/MockReaderTestCase.java) URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/NullReaderTest.java?view=diff&rev=463529&p1=jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/MockReaderTestCase.java&r1=463147&p2=jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/NullReaderTest.java&r2=463529 ============================================================================== --- jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/MockReaderTestCase.java (original) +++ jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/NullReaderTest.java Thu Oct 12 17:37:09 2006 @@ -23,14 +23,14 @@ import junit.framework.TestCase; /** - * JUnit Test Case for [EMAIL PROTECTED] MockReader}. + * JUnit Test Case for [EMAIL PROTECTED] NullReader}. * * @version $Id$ */ -public class MockReaderTestCase extends TestCase { +public class NullReaderTest extends TestCase { /** Constructor */ - public MockReaderTestCase(String name) { + public NullReaderTest(String name) { super(name); } @@ -49,7 +49,7 @@ */ public void testRead() throws Exception { int size = 5; - TestMockReader reader = new TestMockReader(size); + TestNullReader reader = new TestNullReader(size); for (int i = 0; i < size; i++) { assertEquals("Check Value [" + i + "]", i, reader.read()); } @@ -75,7 +75,7 @@ */ public void testReadCharArray() throws Exception { char[] chars = new char[10]; - Reader reader = new TestMockReader(15); + Reader reader = new TestNullReader(15); // Read into array int count1 = reader.read(chars); @@ -121,7 +121,7 @@ * (rather than return -1). */ public void testEOFException() throws Exception { - Reader reader = new TestMockReader(2, false, true); + Reader reader = new TestNullReader(2, false, true); assertEquals("Read 1", 0, reader.read()); assertEquals("Read 2", 1, reader.read()); try { @@ -138,7 +138,7 @@ public void testMarkAndReset() throws Exception { int position = 0; int readlimit = 10; - Reader reader = new TestMockReader(100, true, false); + Reader reader = new TestNullReader(100, true, false); assertTrue("Mark Should be Supported", reader.markSupported()); @@ -189,7 +189,7 @@ * Test <code>mark()</code> not supported. */ public void testMarkNotSupported() throws Exception { - Reader reader = new TestMockReader(100, false, true); + Reader reader = new TestNullReader(100, false, true); assertFalse("Mark Should NOT be Supported", reader.markSupported()); try { @@ -211,7 +211,7 @@ * Test <code>skip()</code> method. */ public void testSkip() throws Exception { - Reader reader = new TestMockReader(10, true, false); + Reader reader = new TestNullReader(10, true, false); assertEquals("Read 1", 0, reader.read()); assertEquals("Read 2", 1, reader.read()); assertEquals("Skip 1", 5, reader.skip(5)); @@ -229,13 +229,13 @@ } - // ------------- Test MockReader implementation ------------- + // ------------- Test NullReader implementation ------------- - private static final class TestMockReader extends MockReader { - public TestMockReader(int size) { + private static final class TestNullReader extends NullReader { + public TestNullReader(int size) { super(size); } - public TestMockReader(int size, boolean markSupported, boolean throwEofException) { + public TestNullReader(int size, boolean markSupported, boolean throwEofException) { super(size, markSupported, throwEofException); } protected int processChar() { Modified: jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/PackageTestSuite.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/PackageTestSuite.java?view=diff&rev=463529&r1=463528&r2=463529 ============================================================================== --- jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/PackageTestSuite.java (original) +++ jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/input/PackageTestSuite.java Thu Oct 12 17:37:09 2006 @@ -35,8 +35,8 @@ TestSuite suite = new TestSuite("IO Utilities - input"); suite.addTest(new TestSuite(ClassLoaderObjectInputStreamTest.class)); suite.addTest(new TestSuite(CountingInputStreamTest.class)); - suite.addTest(new TestSuite(MockInputStreamTestCase.class)); - suite.addTest(new TestSuite(MockReaderTestCase.class)); + suite.addTest(new TestSuite(NullInputStreamTest.class)); + suite.addTest(new TestSuite(NullReaderTest.class)); suite.addTest(new TestSuite(SwappedDataInputStreamTest.class)); return suite; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]