@Test public void testInputStreamMaxSizeZero() throws Exception { byte[] data = data(); MockServletInputStream mock = new MockServletInputStream(data); MonitorInputStream in = new MonitorInputStream(mock, 0); byte[] read = read(in); assertEquals(data.length, read.length); byte[] buffer = in.getData(); assertEquals(0, buffer.length); // ? why does this report 1 off ? assertEquals(data.length - 1, in.getBytesRead()); }
@Test public void testInputStream() throws Exception { byte[] data = data(); MockServletInputStream mock = new MockServletInputStream(data); MonitorInputStream in = new MonitorInputStream(mock, 1024); byte[] read = read(in); assertEquals(data.length, read.length); byte[] buffer = in.getData(); assertEquals(1024, buffer.length); for (int i = 0; i < buffer.length; i++) { assertEquals(data[i], buffer[i]); } // ? why does this report 1 off ? assertEquals(data.length - 1, in.getBytesRead()); }