Program: 44916
Project: 44916
Buggy source:
/** 
 * Tests a <code>BoundedInputStream</code> operating in bounded mode.
 * @throws IOException should not happen
 */
public void testBoundedStream() throws IOException {
  BoundedInputStream bin=new BoundedInputStream(new ByteArrayInputStream(TEST_BYTES),4);
  assertEquals(0,bin.getReadCounter());
  assertEquals(4,bin.getRemainingBytes());
  assertEquals(4,bin.getAllowedBytes());
  assertTrue(bin.read() != -1);
  assertEquals(1,bin.getReadCounter());
  assertEquals(3,bin.getRemainingBytes());
  assertEquals(4,bin.getAllowedBytes());
  assertTrue(bin.read(new byte[1]) != -1);
  assertEquals(2,bin.getReadCounter());
  assertEquals(2,bin.getRemainingBytes());
  assertEquals(4,bin.getAllowedBytes());
  assertTrue(bin.read(new byte[1],0,1) != -1);
  assertEquals(3,bin.getReadCounter());
  assertEquals(1,bin.getRemainingBytes());
  assertEquals(4,bin.getAllowedBytes());
  assertTrue(bin.skip(1) != -1);
  assertEquals(4,bin.getReadCounter());
  assertEquals(0,bin.getRemainingBytes());
  assertEquals(4,bin.getAllowedBytes());
  boolean exceptionThrown=false;
  try {
    bin.read();
  }
 catch (  BoundedInputStream.StreamOutOfBoundException e) {
    exceptionThrown=true;
  }
  assertTrue(exceptionThrown);
  exceptionThrown=false;
  try {
    bin.read(new byte[1]);
  }
 catch (  BoundedInputStream.StreamOutOfBoundException e) {
    exceptionThrown=true;
  }
  assertTrue(exceptionThrown);
  exceptionThrown=false;
  try {
    bin.read(new byte[1],0,1);
  }
 catch (  BoundedInputStream.StreamOutOfBoundException e) {
    exceptionThrown=true;
  }
  assertTrue(exceptionThrown);
  exceptionThrown=false;
  try {
    bin.skip(1);
  }
 catch (  BoundedInputStream.StreamOutOfBoundException e) {
    exceptionThrown=true;
  }
  assertTrue(exceptionThrown);
  assertEquals(4,bin.getReadCounter());
  assertEquals(0,bin.getRemainingBytes());
  assertEquals(4,bin.getAllowedBytes());
}

Fixed version (ground truth):
/** 
 * Tests a <code>BoundedInputStream</code> operating in bounded mode.
 * @throws IOException should not happen
 */
public void testBoundedStream() throws IOException {
  BoundedInputStream bin=new BoundedInputStream(new ByteArrayInputStream(TEST_BYTES),4);
  assertEquals(0,bin.getReadCounter());
  assertEquals(4,bin.getRemainingBytes());
  assertEquals(4,bin.getAllowedBytes());
  assertTrue(bin.read() != -1);
  assertEquals(1,bin.getReadCounter());
  assertEquals(3,bin.getRemainingBytes());
  assertEquals(4,bin.getAllowedBytes());
  assertTrue(bin.read(new byte[1]) != -1);
  assertEquals(2,bin.getReadCounter());
  assertEquals(2,bin.getRemainingBytes());
  assertEquals(4,bin.getAllowedBytes());
  assertTrue(bin.read(new byte[1],0,1) != -1);
  assertEquals(3,bin.getReadCounter());
  assertEquals(1,bin.getRemainingBytes());
  assertEquals(4,bin.getAllowedBytes());
  assertTrue(bin.skip(1) != -1);
  assertEquals(4,bin.getReadCounter());
  assertEquals(0,bin.getRemainingBytes());
  assertEquals(4,bin.getAllowedBytes());
  boolean exceptionThrown=false;
  try {
    bin.read();
  }
 catch (  BoundedInputStream.StreamOutOfBoundException e) {
    exceptionThrown=true;
  }
  assertTrue(exceptionThrown);
  exceptionThrown=false;
  try {
    bin.read(new byte[1]);
  }
 catch (  BoundedInputStream.StreamOutOfBoundException e) {
    exceptionThrown=true;
  }
  assertTrue(exceptionThrown);
  exceptionThrown=false;
  try {
    bin.read(new byte[1],0,1);
  }
 catch (  BoundedInputStream.StreamOutOfBoundException e) {
    exceptionThrown=true;
  }
  assertTrue(exceptionThrown);
  exceptionThrown=false;
  try {
    bin.skip(1);
  }
 catch (  BoundedInputStream.StreamOutOfBoundException e) {
    exceptionThrown=true;
  }
  assertTrue(exceptionThrown);
  assertEquals(4,bin.getReadCounter());
  assertEquals(0,bin.getRemainingBytes());
  assertEquals(4,bin.getAllowedBytes());
  bin=new BoundedInputStream(new ByteArrayInputStream(TEST_BYTES),4);
  assertTrue(bin.read(new byte[6]) != -1);
}