long lastLong = randomDataGenerator.nextLong();
randomDataGenerator = makeRandomDataGenerator(); // restart (make new) PRNG
ListIterator li = testfilesList.listIterator();
while (li.hasNext()) {
testFileName = (UTF8) li.next();
FSInputStream nis = dfsClient.open(testFileName.toString());
byte[] bufferGolden = new byte[bufferSize];
int m = 42;
try {
while (m != -1) {
m = nis.read(buffer);
if (m == buffer.length) {
randomDataGenerator.nextBytes(bufferGolden);
assertBytesEqual(buffer, bufferGolden, buffer.length);
} else if (m > 0) {
byte[] bufferGoldenPartial = new byte[m];
randomDataGenerator.nextBytes(bufferGoldenPartial);
assertBytesEqual(buffer, bufferGoldenPartial, bufferGoldenPartial.length);
}
}
} finally {
nis.close();
}
}
// verify last randomDataGenerator rand val to ensure last file length was checked
long lastLongAgain = randomDataGenerator.nextLong();
assertEquals(lastLong, lastLongAgain);