// open the iterator
iterator.open();
// now test walking through the iterator
int count = 0;
Record target = new Record();
while ((target = iterator.next(target)) != null) {
Assert.assertEquals("In initial run, element " + count + " does not match expected value!", count++,
target.getField(0, IntValue.class).getValue());
}
Assert.assertEquals("Too few elements were deserialzied in initial run!", NUM_TESTRECORDS, count);
// test resetting the iterator a few times
for (int j = 0; j < 10; ++j) {
count = 0;
iterator.reset();
target = new Record();
// now we should get the same results
while ((target = iterator.next(target)) != null) {
Assert.assertEquals("After reset nr. " + j + 1 + " element " + count
+ " does not match expected value!", count++, target.getField(0, IntValue.class).getValue());
}
Assert.assertEquals("Too few elements were deserialzied after reset nr. " + j + 1 + "!", NUM_TESTRECORDS,
count);
}
// close the iterator