byte outBuf[] = new byte[100];
// testing getChecksum for an empty file
FileOutputStream outEmp = new FileOutputStream("empty.txt");
outEmp.close();
InputStream inEmp = new FileInputStream("empty.txt");
CheckedInputStream checkEmpty = new CheckedInputStream(inEmp, new CRC32());
while (checkEmpty.read() >= 0) {
}
assertEquals("the checkSum value of an empty file is not zero", 0, checkEmpty
.getChecksum().getValue());
inEmp.close();
// testing getChecksum for the file checkInput
InputStream checkInput = Support_Resources.getStream("hyts_checkInput.txt");
CheckedInputStream checkIn = new CheckedInputStream(checkInput, new CRC32());
while (checkIn.read() >= 0) {
}
// ran JDK and found that the checkSum value of this is 2036203193
// System.out.print(" " + checkIn.getChecksum().getValue());
assertEquals("the checksum value is incorrect", 2036203193, checkIn.getChecksum()
.getValue());
checkInput.close();
// testing getChecksum for file checkInput
checkInput = Support_Resources.getStream("hyts_checkInput.txt");
CheckedInputStream checkIn2 = new CheckedInputStream(checkInput, new CRC32());
checkIn2.read(outBuf, 0, 10);
// ran JDK and found that the checkSum value of this is 2235765342
// System.out.print(" " + checkIn2.getChecksum().getValue());
assertEquals("the checksum value is incorrect", 2235765342L, checkIn2.getChecksum()
.getValue());
checkInput.close();
}